Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant > Class Template Reference

Testing functions to generate the AES128Test test suite. More...

Classes

class  InvalidWitness
 

Public Types

using Builder = Builder_
 
using AcirConstraint = AES128Constraint
 
using FF = typename Builder::FF
 

Static Public Member Functions

static ProgramMetadata generate_metadata ()
 
static void generate_constraints (AcirConstraint &constraint, WitnessVector &witness_values)
 Generate valid AES128 encryption constraints with random inputs.
 
static std::pair< AcirConstraint, WitnessVectorinvalidate_witness (AcirConstraint constraint, WitnessVector witness_values, const typename InvalidWitness::Target &target)
 Invalidate witness values to test circuit failure detection.
 

Static Private Member Functions

static std::vector< uint8_t > native_aes128_cbc_encrypt (const std::vector< uint8_t > &plaintext, const std::array< uint8_t, 16 > &key, const std::array< uint8_t, 16 > &iv)
 Native AES-128-CBC encryption for generating expected outputs.
 

Detailed Description

template<typename Builder_, bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
class AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >

Testing functions to generate the AES128Test test suite.

Tests that:

  1. Verification key generation is deterministic and independent of witness values
  2. Invalid witnesses (wrong key, IV, or output) cause circuit failure
Template Parameters
Builder_The circuit builder type
IsKeyConstantIf true, the encryption key is a constant (not a witness)
IsIVConstantIf true, the initialization vector is a constant (not a witness)

Definition at line 37 of file aes128_constraint.test.cpp.

Member Typedef Documentation

◆ AcirConstraint

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
using AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::AcirConstraint = AES128Constraint

Definition at line 40 of file aes128_constraint.test.cpp.

◆ Builder

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
using AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::Builder = Builder_

Definition at line 39 of file aes128_constraint.test.cpp.

◆ FF

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
using AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::FF = typename Builder::FF

Definition at line 41 of file aes128_constraint.test.cpp.

Member Function Documentation

◆ generate_constraints()

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
static void AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::generate_constraints ( AcirConstraint constraint,
WitnessVector witness_values 
)
inlinestatic

Generate valid AES128 encryption constraints with random inputs.

Creates a constraint with:

  • Random plaintext (1-3 full blocks, i.e. 16, 32, or 48 bytes)
  • Random 16-byte key (constant or witness based on template param)
  • Random 16-byte IV (constant or witness based on template param)
  • Output witnesses computed via native AES-128-CBC

Definition at line 97 of file aes128_constraint.test.cpp.

◆ generate_metadata()

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
static ProgramMetadata AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::generate_metadata ( )
inlinestatic

Definition at line 86 of file aes128_constraint.test.cpp.

◆ invalidate_witness()

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
static std::pair< AcirConstraint, WitnessVector > AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::invalidate_witness ( AcirConstraint  constraint,
WitnessVector  witness_values,
const typename InvalidWitness::Target target 
)
inlinestatic

Invalidate witness values to test circuit failure detection.

Definition at line 169 of file aes128_constraint.test.cpp.

◆ native_aes128_cbc_encrypt()

template<typename Builder_ , bool IsPlaintextConstant, bool IsKeyConstant, bool IsIVConstant>
static std::vector< uint8_t > AES128TestingFunctions< Builder_, IsPlaintextConstant, IsKeyConstant, IsIVConstant >::native_aes128_cbc_encrypt ( const std::vector< uint8_t > &  plaintext,
const std::array< uint8_t, 16 > &  key,
const std::array< uint8_t, 16 > &  iv 
)
inlinestaticprivate

Native AES-128-CBC encryption for generating expected outputs.

Uses the native crypto implementation to compute expected ciphertext. For full blocks (plaintext.size() % 16 == 0), no padding is added to match circuit behavior.

Definition at line 227 of file aes128_constraint.test.cpp.


The documentation for this class was generated from the following file: