Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
aes128.test.cpp File Reference

Go to the source code of this file.

Functions

stdlib::field_t< UltraCircuitBuildercreate_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
 

Function Documentation

◆ convert_bytes_to_uint256()

uint256_t convert_bytes_to_uint256 ( const uint8_t *  data)

Definition at line 25 of file aes128.test.cpp.

◆ create_field_element()

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() [1/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_all_constant   
)

Definition at line 152 of file aes128.test.cpp.

◆ TEST() [2/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_all_witness   
)

Definition at line 147 of file aes128.test.cpp.

◆ TEST() [3/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_constant_iv_constant_input_witness   
)

Definition at line 167 of file aes128.test.cpp.

◆ TEST() [4/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_constant_iv_witness_input_constant   
)

Definition at line 162 of file aes128.test.cpp.

◆ TEST() [5/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_constant_iv_witness_input_witness   
)

Definition at line 182 of file aes128.test.cpp.

◆ TEST() [6/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_witness_iv_constant_input_constant   
)

Definition at line 157 of file aes128.test.cpp.

◆ TEST() [7/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_witness_iv_constant_input_witness   
)

Definition at line 177 of file aes128.test.cpp.

◆ TEST() [8/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_key_witness_iv_witness_input_constant   
)

Definition at line 172 of file aes128.test.cpp.

◆ TEST() [9/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_all_constant_blocks   
)

Definition at line 277 of file aes128.test.cpp.

◆ TEST() [10/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_all_witness_blocks   
)

Definition at line 272 of file aes128.test.cpp.

◆ TEST() [11/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_alternating_witness_constant   
)

Definition at line 247 of file aes128.test.cpp.

◆ TEST() [12/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_first_constant_rest_witness   
)

Definition at line 252 of file aes128.test.cpp.

◆ TEST() [13/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_first_witness_rest_constant   
)

Definition at line 242 of file aes128.test.cpp.

◆ TEST() [14/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_iv_witness_mixed_blocks   
)

Definition at line 262 of file aes128.test.cpp.

◆ TEST() [15/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_key_iv_witness_mixed_blocks   
)

Definition at line 267 of file aes128.test.cpp.

◆ TEST() [16/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_mixed_input_key_witness_mixed_blocks   
)

Definition at line 257 of file aes128.test.cpp.

◆ TEST() [17/24]

TEST ( stdlib_aes128  ,
encrypt_64_bytes_original   
)

Definition at line 188 of file aes128.test.cpp.

◆ TEST() [18/24]

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() [19/24]

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() [20/24]

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() [21/24]

TEST ( stdlib_aes128_sparse  ,
sparse_form_lookup_table   
)

Test that when using AES input table, sparse form is correctly applied to the input bytes.

Parameters
builderThe circuit builder to use
inputThe input bytes to test
expectedThe expected sparse form of the input bytes
Returns
True if the test passes, false otherwise

Definition at line 368 of file aes128.test.cpp.

◆ TEST() [22/24]

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() [23/24]

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() [24/24]

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.

◆ test_aes128_combination()

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.

◆ test_aes128_mixed_input()

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.

Variable Documentation

◆ AES_SPARSE_BASE

constexpr uint64_t AES_SPARSE_BASE = 9
constexpr

Definition at line 293 of file aes128.test.cpp.