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

Go to the source code of this file.

Classes

class  Sha256Test< Builder >
 

Macros

#define STDLIB_TYPE_ALIASES
 

Typedefs

using BuilderTypes = ::testing::Types< bb::UltraCircuitBuilder, bb::MegaCircuitBuilder >
 

Functions

 TYPED_TEST_SUITE (Sha256Test, BuilderTypes)
 
 TYPED_TEST (Sha256Test, BlockNistVectorOne)
 Test sha256_block against NIST vector one ("abc")
 
 TYPED_TEST (Sha256Test, BlockNistVectorTwo)
 Test sha256_block against NIST vector two (56-byte message)
 
 TYPED_TEST (Sha256Test, ExtendWitnessTamperingFailure)
 Test extend_witness constraints (boomerang attack regression)
 

Macro Definition Documentation

◆ STDLIB_TYPE_ALIASES

#define STDLIB_TYPE_ALIASES

Typedef Documentation

◆ BuilderTypes

Definition at line 24 of file sha256.test.cpp.

Function Documentation

◆ TYPED_TEST() [1/3]

TYPED_TEST ( Sha256Test  ,
BlockNistVectorOne   
)

Test sha256_block against NIST vector one ("abc")

This tests the compression function directly by manually padding the message and comparing against the known NIST hash output.

For "abc" (3 bytes):

  • Padded block: "abc" + 0x80 + zeros + 64-bit length (24 bits)
  • Single block since message fits in 55 bytes

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

◆ TYPED_TEST() [2/3]

TYPED_TEST ( Sha256Test  ,
BlockNistVectorTwo   
)

Test sha256_block against NIST vector two (56-byte message)

This tests chained compression by manually padding a two-block message and comparing against the known NIST hash output.

For "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" (56 bytes):

  • Block 1: message bytes + padding bit (0x80)
  • Block 2: zeros + 64-bit length (448 bits = 0x1c0)

Definition at line 104 of file sha256.test.cpp.

◆ TYPED_TEST() [3/3]

TYPED_TEST ( Sha256Test  ,
ExtendWitnessTamperingFailure   
)

Test extend_witness constraints (boomerang attack regression)

This security test verifies that SHA256::extend_witness() properly constrains all 64 extended message schedule words. Modifying any word should cause circuit failure.

Definition at line 180 of file sha256.test.cpp.

◆ TYPED_TEST_SUITE()

TYPED_TEST_SUITE ( Sha256Test  ,
BuilderTypes   
)