|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
Functions | |
| template<uint64_t base, uint64_t num_rotated_bits> | |
| std::array< bb::fr, 2 > | get_sparse_table_with_rotation_values (const std::array< uint64_t, 2 > key) |
| Computes the sparse form values for a given key, used as a callback for plookup table queries. | |
| template<uint64_t base, uint64_t bits_per_slice, uint64_t num_rotated_bits> | |
| BasicTable | generate_sparse_table_with_rotation (BasicTableId id, const size_t table_index) |
| Generates a BasicTable that maps integers to their sparse form representation, with optional 32-bit rotation. | |
| template<size_t base, const uint64_t * base_table> | |
| std::array< bb::fr, 2 > | get_sparse_normalization_values (const std::array< uint64_t, 2 > key) |
| Computes the normalized output for a sparse value based on a provided normalization table. | |
| template<size_t base, uint64_t num_bits, const uint64_t * base_table> | |
| BasicTable | generate_sparse_normalization_table (BasicTableId id, const size_t table_index) |
| Generates a BasicTable for normalizing sparse form values back to normal form. | |
|
inline |
Generates a BasicTable for normalizing sparse form values back to normal form.
This table converts sparse arithmetic results into actual bit values. Each sparse digit encodes a sum of bits; the normalization table extracts the XOR result (and optionally other Boolean function results like Ch or Maj).
Table structure (base^num_bits many entries):
num_bits digitsThe num_bits parameter controls how many bits are normalized per lookup. Larger num_bits = fewer lookups needed, but larger table.
| base | The sparse form base |
| num_bits | Number of sparse digits (= original bits) processed per lookup |
| base_table | The per-digit normalization table (e.g., choose_normalization_table) |
Definition at line 162 of file sparse.hpp.
|
inline |
Generates a BasicTable that maps integers to their sparse form representation, with optional 32-bit rotation.
Sparse form is a representation where each bit of a binary integer is mapped to a coefficient in a higher base. For a binary value with bits b_i ∈ {0,1}, the sparse form is: Σ(b_i * base^i). This representation enables efficient XOR computation in circuits: XOR can be computed by adding sparse representations and then "normalizing" (reducing coefficients modulo 2).
Example with base=7: binary 0b101 (decimal 5) → 7^0 + 7^2 = 1 + 49 = 50
The table has three columns:
Step sizes are used when combining multiple lookups to reconstruct larger values:
| base | The base for sparse representation (e.g., 7 for SHA256 tables) |
| bits_per_slice | Number of bits per table entry; table size = 2^bits_per_slice |
| num_rotated_bits | Number of bits to rotate right (0 for no rotation) |
| id | The identifier for this lookup table |
| table_index | Index of this table in the table registry |
Definition at line 80 of file sparse.hpp.
|
inline |
Computes the normalized output for a sparse value based on a provided normalization table.
| base | The sparse form base |
| base_table | The normalization lookup table (maps sparse digit → normalized bit(s)) |
| key | The lookup key; key[0] is the sparse input value, key[1] is unused |
Definition at line 125 of file sparse.hpp.
|
inline |
Computes the sparse form values for a given key, used as a callback for plookup table queries.
Given an input key, returns:
| base | The base for sparse representation |
| num_rotated_bits | Number of bits to rotate right (0 for no rotation) |
| key | Array where key[0] is the input value to convert (key[1] is unused; the array has 2 elements to conform to the standard plookup callback interface) |
Definition at line 36 of file sparse.hpp.