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.

Typedefs

using Builder = UltraCircuitBuilder
 
using field_ct = field_t< Builder >
 
using witness_ct = witness_t< Builder >
 

Functions

 TEST (stdlib_sha256, test_sha256_block_NIST_vector_one)
 Test sha256_block against NIST vector one ("abc")
 
 TEST (stdlib_sha256, test_sha256_block_NIST_vector_two)
 Test sha256_block against NIST vector two (56-byte message)
 
 TEST (stdlib_sha256, test_extend_witness_constraints)
 Test extend_witness constraints (boomerang attack regression)
 

Typedef Documentation

◆ Builder

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

◆ field_ct

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

◆ witness_ct

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

Function Documentation

◆ TEST() [1/3]

TEST ( stdlib_sha256  ,
test_extend_witness_constraints   
)

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 170 of file sha256.test.cpp.

◆ TEST() [2/3]

TEST ( stdlib_sha256  ,
test_sha256_block_NIST_vector_one   
)

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 29 of file sha256.test.cpp.

◆ TEST() [3/3]

TEST ( stdlib_sha256  ,
test_sha256_block_NIST_vector_two   
)

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 94 of file sha256.test.cpp.