|
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/mega_circuit_builder.hpp"#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp"#include <gtest/gtest.h>Go to the source code of this file.
Classes | |
| class | StdlibAes128< Builder > |
Typedefs | |
| using | BuilderTypes = ::testing::Types< bb::UltraCircuitBuilder, bb::MegaCircuitBuilder > |
Functions | |
| TYPED_TEST_SUITE (StdlibAes128, BuilderTypes) | |
| template<class Builder > | |
| stdlib::field_t< Builder > | create_field_element (Builder &builder, const uint256_t &value, bool as_witness) |
| template<class Builder > | |
| void | test_aes128_combination (bool key_as_witness, bool iv_as_witness, bool input_as_witness) |
| template<class Builder > | |
| void | test_aes128_mixed_input (bool key_as_witness, bool iv_as_witness, const std::vector< bool > &input_block_config) |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_all_witness) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_all_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_witness_iv_constant_input_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_constant_iv_witness_input_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_constant_iv_constant_input_witness) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_witness_iv_witness_input_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_witness_iv_constant_input_witness) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_key_constant_iv_witness_input_witness) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_original) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_first_witness_rest_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_alternating_witness_constant) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_first_constant_rest_witness) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_key_witness_mixed_blocks) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_iv_witness_mixed_blocks) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_key_iv_witness_mixed_blocks) | |
| TYPED_TEST (StdlibAes128, encrypt_64_bytes_mixed_input_all_witness_blocks) | |
| TYPED_TEST (StdlibAes128, 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 |
| using BuilderTypes = ::testing::Types<bb::UltraCircuitBuilder, bb::MegaCircuitBuilder> |
Definition at line 19 of file aes128.test.cpp.
| stdlib::field_t< Builder > create_field_element | ( | Builder & | builder, |
| const uint256_t & | value, | ||
| bool | as_witness | ||
| ) |
Definition at line 24 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 328 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 523 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 571 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 381 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 313 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 476 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 431 of file aes128.test.cpp.
| void test_aes128_combination | ( | bool | key_as_witness, |
| bool | iv_as_witness, | ||
| bool | input_as_witness | ||
| ) |
Definition at line 44 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 100 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_all_constant | |||
| ) |
Definition at line 161 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_all_witness | |||
| ) |
Definition at line 156 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_constant_iv_constant_input_witness | |||
| ) |
Definition at line 176 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_constant_iv_witness_input_constant | |||
| ) |
Definition at line 171 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_constant_iv_witness_input_witness | |||
| ) |
Definition at line 191 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_witness_iv_constant_input_constant | |||
| ) |
Definition at line 166 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_witness_iv_constant_input_witness | |||
| ) |
Definition at line 186 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_key_witness_iv_witness_input_constant | |||
| ) |
Definition at line 181 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_all_constant_blocks | |||
| ) |
Definition at line 287 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_all_witness_blocks | |||
| ) |
Definition at line 282 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_alternating_witness_constant | |||
| ) |
Definition at line 257 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_first_constant_rest_witness | |||
| ) |
Definition at line 262 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_first_witness_rest_constant | |||
| ) |
Definition at line 252 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_iv_witness_mixed_blocks | |||
| ) |
Definition at line 272 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_key_iv_witness_mixed_blocks | |||
| ) |
Definition at line 277 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_mixed_input_key_witness_mixed_blocks | |||
| ) |
Definition at line 267 of file aes128.test.cpp.
| TYPED_TEST | ( | StdlibAes128 | , |
| encrypt_64_bytes_original | |||
| ) |
Definition at line 197 of file aes128.test.cpp.
| TYPED_TEST_SUITE | ( | StdlibAes128 | , |
| BuilderTypes | |||
| ) |
|
constexpr |
Definition at line 306 of file aes128.test.cpp.