|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include "aes128.hpp"#include "barretenberg/circuit_checker/circuit_checker.hpp"#include "barretenberg/crypto/aes128/aes128.hpp"#include "barretenberg/numeric/bitop/sparse_form.hpp"#include "barretenberg/stdlib/primitives/plookup/plookup.hpp"#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"#include <gtest/gtest.h>Go to the source code of this file.
Functions | |
| stdlib::field_t< UltraCircuitBuilder > | create_field_element (UltraCircuitBuilder &builder, const uint256_t &value, bool as_witness) |
| uint256_t | convert_bytes_to_uint256 (const uint8_t *data) |
| void | test_aes128_combination (bool key_as_witness, bool iv_as_witness, bool input_as_witness) |
| void | test_aes128_mixed_input (bool key_as_witness, bool iv_as_witness, const std::vector< bool > &input_block_config) |
| TEST (stdlib_aes128, encrypt_64_bytes_all_witness) | |
| TEST (stdlib_aes128, encrypt_64_bytes_all_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_witness_iv_constant_input_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_constant_iv_witness_input_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_constant_iv_constant_input_witness) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_witness_iv_witness_input_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_witness_iv_constant_input_witness) | |
| TEST (stdlib_aes128, encrypt_64_bytes_key_constant_iv_witness_input_witness) | |
| TEST (stdlib_aes128, encrypt_64_bytes_original) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_first_witness_rest_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_alternating_witness_constant) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_first_constant_rest_witness) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_key_witness_mixed_blocks) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_iv_witness_mixed_blocks) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_key_iv_witness_mixed_blocks) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_all_witness_blocks) | |
| TEST (stdlib_aes128, encrypt_64_bytes_mixed_input_all_constant_blocks) | |
| TEST (stdlib_aes128_sparse, sparse_form_roundtrip) | |
| Test that sparse form correctly represents bytes. | |
| TEST (stdlib_aes128_sparse, sparse_addition_equals_xor_native) | |
| Test that addition of sparse forms equals XOR after normalization (native) | |
| TEST (stdlib_aes128_sparse, sparse_form_lookup_table) | |
| Test that when using AES input table, sparse form is correctly applied to the input bytes. | |
| TEST (stdlib_aes128_sparse, sparse_xor_circuit) | |
| Test sparse XOR in circuit using plookup normalization. | |
| TEST (stdlib_aes128_sparse, sparse_multi_xor_circuit) | |
| Test multi-way XOR via sparse form (a XOR b XOR c) | |
| TEST (stdlib_aes128_sparse, sparse_addition_limit) | |
| Test the maximum number of additions before overflow. | |
| TEST (stdlib_aes128_sparse, sparse_addition_overflow) | |
| Test the minimum number of additions with overflow. | |
Variables | |
| constexpr uint64_t | AES_SPARSE_BASE = 9 |
| uint256_t convert_bytes_to_uint256 | ( | const uint8_t * | data | ) |
Definition at line 25 of file aes128.test.cpp.
| stdlib::field_t< UltraCircuitBuilder > create_field_element | ( | UltraCircuitBuilder & | builder, |
| const uint256_t & | value, | ||
| bool | as_witness | ||
| ) |
Definition at line 13 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_all_constant | |||
| ) |
Definition at line 152 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_all_witness | |||
| ) |
Definition at line 147 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_constant_iv_constant_input_witness | |||
| ) |
Definition at line 167 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_constant_iv_witness_input_constant | |||
| ) |
Definition at line 162 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_constant_iv_witness_input_witness | |||
| ) |
Definition at line 182 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_witness_iv_constant_input_constant | |||
| ) |
Definition at line 157 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_witness_iv_constant_input_witness | |||
| ) |
Definition at line 177 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_key_witness_iv_witness_input_constant | |||
| ) |
Definition at line 172 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_all_constant_blocks | |||
| ) |
Definition at line 277 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_all_witness_blocks | |||
| ) |
Definition at line 272 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_alternating_witness_constant | |||
| ) |
Definition at line 247 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_first_constant_rest_witness | |||
| ) |
Definition at line 252 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_first_witness_rest_constant | |||
| ) |
Definition at line 242 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_iv_witness_mixed_blocks | |||
| ) |
Definition at line 262 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_key_iv_witness_mixed_blocks | |||
| ) |
Definition at line 267 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_mixed_input_key_witness_mixed_blocks | |||
| ) |
Definition at line 257 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128 | , |
| encrypt_64_bytes_original | |||
| ) |
Definition at line 188 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_addition_equals_xor_native | |||
| ) |
Test that addition of sparse forms equals XOR after normalization (native)
This tests the mathematical property without circuit constraints.
Definition at line 315 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_addition_limit | |||
| ) |
Test the maximum number of additions before overflow.
With base-9, each digit can hold values 0-8 before overflowing. This means we can safely add up to 8 sparse bytes (each with digits 0 or 1) before normalization is required.
Definition at line 510 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_addition_overflow | |||
| ) |
Test the minimum number of additions with overflow.
With base-9, each digit can hold values 0-8 before overflowing. This means we need to add 9 sparse bytes (each with digits 0 or 1) to overflow.
Definition at line 558 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_form_lookup_table | |||
| ) |
Test that when using AES input table, sparse form is correctly applied to the input bytes.
| builder | The circuit builder to use |
| input | The input bytes to test |
| expected | The expected sparse form of the input bytes |
Definition at line 368 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_form_roundtrip | |||
| ) |
Test that sparse form correctly represents bytes.
Verifies map_into_sparse_form and map_from_sparse_form are inverses.
Definition at line 300 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_multi_xor_circuit | |||
| ) |
Test multi-way XOR via sparse form (a XOR b XOR c)
In AES, we often XOR multiple values together (e.g., in AddRoundKey, MixColumns). Sparse form allows accumulating multiple additions before normalizing.
Definition at line 463 of file aes128.test.cpp.
| TEST | ( | stdlib_aes128_sparse | , |
| sparse_xor_circuit | |||
| ) |
Test sparse XOR in circuit using plookup normalization.
This tests the actual circuit operation used in AES.
Definition at line 418 of file aes128.test.cpp.
| void test_aes128_combination | ( | bool | key_as_witness, |
| bool | iv_as_witness, | ||
| bool | input_as_witness | ||
| ) |
Definition at line 36 of file aes128.test.cpp.
| void test_aes128_mixed_input | ( | bool | key_as_witness, |
| bool | iv_as_witness, | ||
| const std::vector< bool > & | input_block_config | ||
| ) |
Definition at line 91 of file aes128.test.cpp.
|
constexpr |
Definition at line 293 of file aes128.test.cpp.