|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
Functions | |
| std::array< bb::fr, 2 > | get_aes_sparse_normalization_values_from_key (const std::array< uint64_t, 2 > key) |
| Normalizes the sparse form by mapping from sparse form to bytes and back to sparse form. | |
| BasicTable | generate_aes_sparse_normalization_table (BasicTableId id, const size_t table_index) |
| Generates a BasicTable for normalizing 4 sparse digits back to valid sparse form. | |
| MultiTable | get_aes_normalization_table (const MultiTableId id=AES_NORMALIZE) |
| Creates a MultiTable for normalizing 8 sparse digits back to binary digits. | |
| MultiTable | get_aes_input_table (const MultiTableId id=AES_INPUT) |
| Creates a MultiTable for converting a 128-bit AES input block into 16 sparse-form bytes. | |
| std::array< bb::fr, 2 > | get_aes_sbox_values_from_key (const std::array< uint64_t, 2 > key) |
| Computes AES S-box substitution and a derived value for MixColumns, returning both in sparse form. | |
| BasicTable | generate_aes_sbox_table (BasicTableId id, const size_t table_index) |
| Generates a plookup table for AES S-box substitution with precomputed MixColumns values. | |
| MultiTable | get_aes_sbox_table (const MultiTableId id=AES_SBOX) |
|
inline |
Generates a plookup table for AES S-box substitution with precomputed MixColumns values.
This table provides the core non-linear operation of AES (SubBytes) combined with a precomputed value needed for MixColumns, all stored in sparse form for efficient XOR operations in circuits.
Table structure (256 entries, one per byte value):
The third column precomputes the value needed for MixColumns multiplication by 3, since 3 = 2 ⊕ 1, so a × 3 = xtime(a) ⊕ a.
Step sizes are all 0 because this table is used for individual byte lookups, not for accumulating multiple slices into a larger value.
| id | The identifier for this lookup table |
| table_index | Index of this table in the table registry |
Definition at line 241 of file aes128.hpp.
|
inline |
Generates a BasicTable for normalizing 4 sparse digits back to valid sparse form.
In sparse-form XOR computation, adding two sparse values can produce digits > 1. For example, if two bits are both 1, their sparse digits add to 2. This table extracts the LSB of each digit to recover the actual XOR result.
The table processes 4 sparse digits at a time (base-9, so 9^4 = 6561 entries). For each digit d ∈ {0..8}, the normalized value is (d & 1):
Table structure:
Example: Input sparse value representing digits [2, 1, 0, 3]
Step sizes of 6561 (= 9^4) allow the MultiTable (AES_NORMALIZE) to combine two 4-digit lookups to normalize a full 8-digit sparse byte.
| id | The BasicTableId to assign (AES_SPARSE_NORMALIZE) |
| table_index | Index of this table in the table registry |
Definition at line 60 of file aes128.hpp.
|
inline |
Creates a MultiTable for converting a 128-bit AES input block into 16 sparse-form bytes.
This table decomposes a 128-bit field element (representing an AES block) into 16 individual bytes and converts each byte to sparse base-9 representation. This is used at the start of AES encryption to prepare the input state for sparse-form arithmetic.
Table structure:
The MultiTable accumulator coefficients (256, 0, 0) indicate:
Usage: Given a 128-bit input packed as a field element, the plookup machinery will:
| id | The MultiTableId to assign (defaults to AES_INPUT) |
Definition at line 165 of file aes128.hpp.
|
inline |
Creates a MultiTable for normalizing 8 sparse digits back to binary digits.
This table decomposes a 8-digit sparse value into 2, 4-digit sparse values (upper and lower) and normalizes each of them. This is used to normalize the sparse form of the input block before the AES S-box lookup.
| id | The MultiTableId to assign (AES_NORMALIZE) |
Definition at line 116 of file aes128.hpp.
|
inline |
Definition at line 267 of file aes128.hpp.
|
inline |
Computes AES S-box substitution and a derived value for MixColumns, returning both in sparse form.
This function performs two operations needed for efficient AES circuit implementation:
1. **S-box substitution**: Converts the sparse input back to a byte, applies the AES S-box
lookup, and returns the result in sparse form.
2. **Swizzled value for MixColumns**: Computes S(x) ⊕ xtime(S(x)), where xtime is
multiplication by 2 in GF(2^8) using the AES irreducible polynomial (x^8 + x^4 + x^3 + x + 1).
This equals S(x) * 3 in GF(2^8), which is used in the MixColumns step.
The xtime operation is: xtime(a) = (a << 1) ⊕ (0x1b if MSB of a is 1, else 0)
where 0x1b represents the reduction polynomial coefficients.
By precomputing both S(x) and S(x) ⊕ xtime(S(x)) in a single lookup, the MixColumns
operation can be performed efficiently using only additions of sparse representations.
| key | Array where key[0] contains the input byte in sparse form (key[1] unused) |
Definition at line 203 of file aes128.hpp.
|
inline |
Normalizes the sparse form by mapping from sparse form to bytes and back to sparse form.
| key | The lookup key; key[0] is the sparse input value, key[1] is unused |
Definition at line 26 of file aes128.hpp.