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

Corruption/negative tests for ECCVM relation constraints. More...

Go to the source code of this file.

Classes

class  ECCVMRelationCorruptionTests
 

Functions

 TEST_F (ECCVMRelationCorruptionTests, MSMAccumulatorCorruptionAtTransitionRowIsHarmless)
 Show that corrupting the accumulator at row 1 (msm_transition=1) does NOT break the MSM relation.
 
 TEST_F (ECCVMRelationCorruptionTests, MSMAccumulatorCorruptionAtInteriorAndNoOpRows)
 Corrupt the MSM accumulator at an interior active row and at a trailing no-op row.
 
 TEST_F (ECCVMRelationCorruptionTests, MSMRelationFailsOnShiftedMSMTable)
 Shift every MSM column down by one row, inserting a zero row at row 1.
 
 TEST_F (ECCVMRelationCorruptionTests, TranscriptNoOpRowRejectsAccumulatorNotEmpty)
 On a transcript no-op row, setting accumulator_not_empty=1 must be caught by subrelation 22.
 
 TEST_F (ECCVMRelationCorruptionTests, SetRelationFailsOnZPermNonZeroAtFirstRow)
 Test that z_perm must be zero at the lagrange_first row.
 

Detailed Description

Corruption/negative tests for ECCVM relation constraints.

Each test builds valid ProverPolynomials from a real ECCVMCircuitBuilder, asserts that relations pass on clean data, then corrupts specific witness values and verifies detection.

Definition in file eccvm_relation_corruption.test.cpp.

Function Documentation

◆ TEST_F() [1/5]

TEST_F ( ECCVMRelationCorruptionTests  ,
MSMAccumulatorCorruptionAtInteriorAndNoOpRows   
)

Corrupt the MSM accumulator at an interior active row and at a trailing no-op row.

Part 1 targets an interior addition row (q_add=1, msm_transition=0). Unlike the transition row, the interior addition directly uses acc as input to the point-addition chain, so corrupting it breaks the addition subrelations.

Part 2 targets a trailing no-op row where all MSM selectors are zero. Here the no-op preservation constraints (subrelations 45-46) enforce acc_shift == acc.

Definition at line 195 of file eccvm_relation_corruption.test.cpp.

◆ TEST_F() [2/5]

TEST_F ( ECCVMRelationCorruptionTests  ,
MSMAccumulatorCorruptionAtTransitionRowIsHarmless   
)

Show that corrupting the accumulator at row 1 (msm_transition=1) does NOT break the MSM relation.

Row 1 is the first active MSM row with msm_transition=1. The first_add lambda in the MSM relation replaces the accumulator with the offset generator when msm_transition=1: x = xo * msm_transition + acc_x * (-msm_transition + 1) So when msm_transition=1, acc_x and acc_y are completely unused — corrupting them is harmless. This test documents that behavior explicitly.

Definition at line 161 of file eccvm_relation_corruption.test.cpp.

◆ TEST_F() [3/5]

TEST_F ( ECCVMRelationCorruptionTests  ,
MSMRelationFailsOnShiftedMSMTable   
)

Shift every MSM column down by one row, inserting a zero row at row 1.

For every MSM polynomial p, we set: p_new[0] = p[0] (row 0 is reserved for shifts, always zero) p_new[1] = 0 (injected blank row) p_new[k] = p[k-1] for k >= 2

This shifts all real MSM data one row later. Row 1, which was the first active MSM row (msm_transition = 1, q_add = 1, nonzero accumulator), becomes a no-op with zero accumulator. But the non-MSM columns (e.g. lagrange polynomials, precompute columns) are NOT shifted, so there's a mismatch. The no-op constraint (subrelations 45-46) forces acc_shift == acc at the now-empty row 1, but the shifted row 2 carries a nonzero accumulator from what was originally the row-1 computation, causing a detected violation.

Definition at line 274 of file eccvm_relation_corruption.test.cpp.

◆ TEST_F() [4/5]

TEST_F ( ECCVMRelationCorruptionTests  ,
SetRelationFailsOnZPermNonZeroAtFirstRow   
)

Test that z_perm must be zero at the lagrange_first row.

The set relation grand product relies on z_perm[0] = 0 so that (z_perm + lagrange_first) evaluates to 1 at the first row. Sub-relation Z_PERM_INIT (lagrange_first * z_perm = 0) enforces this.

We cross-check the lagrange_first position two ways:

  1. Structurally: z_perm.start_index() - 1 (the zero row before the shiftable region)
  2. By scanning the lagrange_first polynomial for its non-zero entry

Definition at line 394 of file eccvm_relation_corruption.test.cpp.

◆ TEST_F() [5/5]

TEST_F ( ECCVMRelationCorruptionTests  ,
TranscriptNoOpRowRejectsAccumulatorNotEmpty   
)

On a transcript no-op row, setting accumulator_not_empty=1 must be caught by subrelation 22.

The accumulator_infinity_from_noop term in subrelation 22 forces is_accumulator_empty_shift = 1 whenever all selectors are zero. This test corrupts the shifted value (i.e. accumulator_not_empty at row+1) to 1 and verifies detection.

Definition at line 360 of file eccvm_relation_corruption.test.cpp.