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

Tests that validate correctness at the ZK masking boundaries. More...

Go to the source code of this file.

Classes

class  ZKBoundaryTests
 

Functions

 TEST_F (ZKBoundaryTests, EccOpWireAlignmentAtDisabledBoundary)
 Verify ECC op wire alignment: ecc_op_wire[r] == w_shift[r] = w[r+1] at the boundary.
 
 TEST_F (ZKBoundaryTests, WitnessMaskingStructure)
 Verify that the disabled head rows (0-3) contain masking values in witness wires.
 
 TEST_F (ZKBoundaryTests, DisabledRegionIsolation)
 Corrupt a masking value in the disabled region and verify proof still passes.
 
 TEST_F (ZKBoundaryTests, LagrangeFirstPosition)
 Verify that lagrange_first is positioned correctly after the disabled region.
 
 TEST_F (ZKBoundaryTests, EccOpWiresZeroInDisabledRegion)
 Verify ECC op wires are zero in the disabled region (not masked).
 
 TEST_F (ZKBoundaryTests, ProveAndVerifyMegaZK)
 End-to-end: prove and verify a MegaZK circuit, confirming the full pipeline works with ECC ops.
 
 TEST_F (ZKBoundaryTests, CorruptionInActiveRegionFailsProof)
 Corrupt a witness in the active region (first gate after disabled rows) and verify that proof fails.
 

Detailed Description

Tests that validate correctness at the ZK masking boundaries.

These tests verify that the disabled head region (rows 0-3) interacts correctly with the active trace, specifically around:

  • ECC op wire / main wire alignment across the shift boundary
  • Grand product initialization at the disabled/active edge
  • Masking values not leaking into active relation checks
  • Row-disabling polynomial correctly killing the disabled region

Tests are MegaZK-only since the disabled head region only exists for ZK flavors.

Definition in file zk_boundary.test.cpp.

Function Documentation

◆ TEST_F() [1/7]

TEST_F ( ZKBoundaryTests  ,
CorruptionInActiveRegionFailsProof   
)

Corrupt a witness in the active region (first gate after disabled rows) and verify that proof fails.

Definition at line 208 of file zk_boundary.test.cpp.

◆ TEST_F() [2/7]

TEST_F ( ZKBoundaryTests  ,
DisabledRegionIsolation   
)

Corrupt a masking value in the disabled region and verify proof still passes.

The row-disabling polynomial kills rows 0-3, so any values there (including masking) should not affect relation correctness. Changing a masking value should still produce a valid proof (the change affects commitment/ZK but not soundness within the disabled region). This test verifies that the row-disabling polynomial properly isolates the disabled region.

Definition at line 136 of file zk_boundary.test.cpp.

◆ TEST_F() [3/7]

TEST_F ( ZKBoundaryTests  ,
EccOpWireAlignmentAtDisabledBoundary   
)

Verify ECC op wire alignment: ecc_op_wire[r] == w_shift[r] = w[r+1] at the boundary.

ecc_op_wire data starts at row TRACE_OFFSET (4 for MegaZK), while the block's data in w starts at row TRACE_OFFSET + NUM_ZERO_ROWS (5). The shift convention (w_shift[r] = w[r+1]) bridges the gap, so ecc_op_wire[TRACE_OFFSET + i] == w[TRACE_OFFSET + NUM_ZERO_ROWS + i]. This test checks the alignment holds and that corrupting it causes relation failure.

Definition at line 71 of file zk_boundary.test.cpp.

◆ TEST_F() [4/7]

TEST_F ( ZKBoundaryTests  ,
EccOpWiresZeroInDisabledRegion   
)

Verify ECC op wires are zero in the disabled region (not masked).

Unlike witness wires, ecc_op_wires are not masked (ZK for ops comes from random ops in the merge protocol). They should be zero at rows 0 through ecc_op_start-1.

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

◆ TEST_F() [5/7]

TEST_F ( ZKBoundaryTests  ,
LagrangeFirstPosition   
)

Verify that lagrange_first is positioned correctly after the disabled region.

Definition at line 163 of file zk_boundary.test.cpp.

◆ TEST_F() [6/7]

TEST_F ( ZKBoundaryTests  ,
ProveAndVerifyMegaZK   
)

End-to-end: prove and verify a MegaZK circuit, confirming the full pipeline works with ECC ops.

Definition at line 198 of file zk_boundary.test.cpp.

◆ TEST_F() [7/7]

TEST_F ( ZKBoundaryTests  ,
WitnessMaskingStructure   
)

Verify that the disabled head rows (0-3) contain masking values in witness wires.

Witness wires (w_l, w_r, w_o, w_4) should have random masking at rows {1,2,3} and zero at row 0 (shiftable constraint). This test asserts the structural invariant.

Definition at line 109 of file zk_boundary.test.cpp.