|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
Failure/negative tests for Translator scattered masking layout. More...
#include "barretenberg/honk/library/grand_product_library.hpp"#include "barretenberg/honk/relation_checker.hpp"#include "barretenberg/translator_vm/translator_circuit_builder.hpp"#include "barretenberg/translator_vm/translator_flavor.hpp"#include "barretenberg/translator_vm/translator_proving_key.hpp"#include <gtest/gtest.h>Go to the source code of this file.
Classes | |
| class | TranslatorRelationFailureTests |
Functions | |
| TEST_F (TranslatorRelationFailureTests, PermutationFailsOnConcatenatedCorruption) | |
| Corrupt a non-masking value in concatenated_range_constraints_0, creating a multiset mismatch (numerator changes but ordered/denominator is not updated). | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnMaxValueCorruption) | |
| Corrupt the value at lagrange_real_last position (circuit_size - MAX_RANDOM - 1) in an ordered poly. Subrelations 5-9 check that ordered[real_last] == 2^14 - 1; this is the only position they are active. | |
| TEST_F (TranslatorRelationFailureTests, PermutationFailsOnZPermCorruption) | |
| Corrupt z_perm at a mid position, breaking the running product consistency. | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnOrderedMaskingBoundary) | |
| Corrupt ordered poly at position circuit_size - MAX_RANDOM - 2, the last row where the delta constraint is enforced. This is right before lagrange_real_last + lagrange_ordered_masking kicks in. | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnNegativeDelta) | |
| Swap two adjacent sorted values to create a negative delta (descending pair). In the field, ordered[i+1] - ordered[i] becomes a huge element, not in {0,1,2,3}. | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnDeltaFour) | |
| Set delta = 4 (smallest forbidden step) between adjacent ordered values. D ∈ {0,1,2,3} passes; D = 4 is the exact boundary that must fail. | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnFirstSortedValueTooLarge) | |
| Corrupt position 1 in an ordered poly (the first real sorted value after virtual zero at pos 0). If ordered[1] > 3, the delta from 0 to ordered[1] violates the step constraint. | |
| TEST_F (TranslatorRelationFailureTests, DeltaRangeFailsOnFifthOrderedPolyCorruption) | |
| Corrupt ordered_range_constraints_4 (the 5th ordered poly, built from the extra denominator). This poly is constructed from a different code path than the first 4. Verify subrelation 4 catches it. | |
| TEST_F (TranslatorRelationFailureTests, PermutationFailsOnOrderedCorruption) | |
| Corrupt a value in ordered_range_constraints_0 (denominator side of the permutation), creating a multiset mismatch without updating z_perm. | |
| TEST_F (TranslatorRelationFailureTests, InRangeValueInMaskingFlowsToOrderedTail) | |
| Place a small in-range value (42) at a wire masking position and verify it flows correctly through concatenation into the ordered polynomial's contiguous masking tail. | |
| TEST_F (TranslatorRelationFailureTests, PermutationFailsOnExtraNumeratorCorruption) | |
| Corrupt ordered_extra_range_constraints_numerator (the 5th factor in the permutation numerator), creating a multiset mismatch without updating z_perm. | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferFailsOnOddRowCorruption) | |
| Corrupt an accumulator limb at an interior odd row to break the transfer chain. Subrelations 0-3 enforce acc[odd] == acc[odd+1] at odd minicircuit rows (except the last). | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferFailsOnZeroInitCorruption) | |
| Set a non-zero accumulator at the last minicircuit row where zero-init is enforced. Subrelations 4-7 check acc * lagrange_last_in_minicircuit == 0 at position MINI - NUM_MASKED - 1 (= 8187). | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferFailsOnResultMismatch) | |
| Mismatch accumulated_result[0] with the actual accumulator value at RESULT_ROW (= 8). Subrelations 8-11 check (acc - expected) * lagrange_result_row == 0. | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferPassesWithMaskingRegionValues) | |
| Place arbitrary non-zero values in accumulator limbs at masking positions ([2,7] and [8188,8191]). Verify the relation still passes — masking regions must not leak into the accumulator transfer relation. | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferFailsAtFirstTransferRow) | |
| Corrupt the accumulator at row 9 (first odd row in minicircuit, left boundary of transfer chain). lagrange_odd_in_minicircuit is first active at RESULT_ROW + 1 = 9. | |
| TEST_F (TranslatorRelationFailureTests, AccumulatorTransferFailsAtLastTransferRow) | |
| Corrupt the accumulator at the penultimate odd row (right boundary of the transfer chain, just before the zero-init row 8187). Row 8185 is the last odd row where the transfer subrelation is active (lagrange_odd = 1, lagrange_last = 0). | |
| TEST_F (TranslatorRelationFailureTests, PermutationFailsOnConcatenatedBlockBoundaryCorruption) | |
| Place a non-zero value at position j*MINI (block boundary, below start_index) in a concatenated poly. This position is normally zero because wire data starts at start_index=1 within each block. Changing it alters the permutation numerator without updating ordered polys. | |
Failure/negative tests for Translator scattered masking layout.
Each test builds a fully valid TranslatorProvingKey (via build_valid_translator_state()), asserts that the target relation passes on clean data, then corrupts a specific witness value and verifies detection. All corruptions are witness-level only.
Permutation relation (TranslatorPermutationRelation) — 5 tests: PermutationFailsOnConcatenatedCorruption — numerator (concatenated poly, block interior) PermutationFailsOnZPermCorruption — running product (z_perm mid-circuit) PermutationFailsOnOrderedCorruption — denominator (ordered poly, interior) PermutationFailsOnExtraNumeratorCorruption — 5th numerator factor (extra range numerator) PermutationFailsOnConcatenatedBlockBoundaryCorruption — block boundary (position j*MINI, zero gap)
Delta range relation (TranslatorDeltaRangeConstraintRelation) — 6 tests: DeltaRangeFailsOnMaxValueCorruption — real_last position != 2^14-1 (subrelations 5-9) DeltaRangeFailsOnOrderedMaskingBoundary — last enforced row before masking region DeltaRangeFailsOnNegativeDelta — descending pair (D < 0 in field) DeltaRangeFailsOnDeltaFour — smallest forbidden step (D = 4) DeltaRangeFailsOnFirstSortedValueTooLarge — position 0->1 transition (virtual zero start) DeltaRangeFailsOnFifthOrderedPolyCorruption — 5th ordered poly (different build path)
Accumulator transfer relation (TranslatorAccumulatorTransferRelation) — 6 tests: AccumulatorTransferFailsOnOddRowCorruption — interior odd row (transfer chain) AccumulatorTransferFailsOnZeroInitCorruption — last minicircuit row (zero-init) AccumulatorTransferFailsOnResultMismatch — result row vs expected (subrelations 8-11) AccumulatorTransferPassesWithMaskingRegionValues — masking regions excluded by selectors AccumulatorTransferFailsAtFirstTransferRow — row 9 (left boundary of transfer chain) AccumulatorTransferFailsAtLastTransferRow — row 8185 (right boundary before zero-init)
Pipeline correctness — 1 test: InRangeValueInMaskingFlowsToOrderedTail — trace FF(42) from wire masking through concatenation into ordered poly tail
Definition in file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferFailsAtFirstTransferRow | |||
| ) |
Corrupt the accumulator at row 9 (first odd row in minicircuit, left boundary of transfer chain). lagrange_odd_in_minicircuit is first active at RESULT_ROW + 1 = 9.
Definition at line 620 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferFailsAtLastTransferRow | |||
| ) |
Corrupt the accumulator at the penultimate odd row (right boundary of the transfer chain, just before the zero-init row 8187). Row 8185 is the last odd row where the transfer subrelation is active (lagrange_odd = 1, lagrange_last = 0).
Definition at line 644 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferFailsOnOddRowCorruption | |||
| ) |
Corrupt an accumulator limb at an interior odd row to break the transfer chain. Subrelations 0-3 enforce acc[odd] == acc[odd+1] at odd minicircuit rows (except the last).
Definition at line 516 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferFailsOnResultMismatch | |||
| ) |
Mismatch accumulated_result[0] with the actual accumulator value at RESULT_ROW (= 8). Subrelations 8-11 check (acc - expected) * lagrange_result_row == 0.
Definition at line 561 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferFailsOnZeroInitCorruption | |||
| ) |
Set a non-zero accumulator at the last minicircuit row where zero-init is enforced. Subrelations 4-7 check acc * lagrange_last_in_minicircuit == 0 at position MINI - NUM_MASKED - 1 (= 8187).
Definition at line 539 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| AccumulatorTransferPassesWithMaskingRegionValues | |||
| ) |
Place arbitrary non-zero values in accumulator limbs at masking positions ([2,7] and [8188,8191]). Verify the relation still passes — masking regions must not leak into the accumulator transfer relation.
This is the key test for the new concatenated layout: lagrange_odd_in_minicircuit is only active at odd positions in [RESULT_ROW, MINI - NUM_MASKED), lagrange_last_in_minicircuit at 8187, and lagrange_result_row at 8. None of these cover masking positions [2,7] or [8188,8191]. If any selector were accidentally set at a masking position, non-zero accumulator values there would cause a failure.
Definition at line 588 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnDeltaFour | |||
| ) |
Set delta = 4 (smallest forbidden step) between adjacent ordered values. D ∈ {0,1,2,3} passes; D = 4 is the exact boundary that must fail.
Definition at line 305 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnFifthOrderedPolyCorruption | |||
| ) |
Corrupt ordered_range_constraints_4 (the 5th ordered poly, built from the extra denominator). This poly is constructed from a different code path than the first 4. Verify subrelation 4 catches it.
Definition at line 352 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnFirstSortedValueTooLarge | |||
| ) |
Corrupt position 1 in an ordered poly (the first real sorted value after virtual zero at pos 0). If ordered[1] > 3, the delta from 0 to ordered[1] violates the step constraint.
Definition at line 329 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnMaxValueCorruption | |||
| ) |
Corrupt the value at lagrange_real_last position (circuit_size - MAX_RANDOM - 1) in an ordered poly. Subrelations 5-9 check that ordered[real_last] == 2^14 - 1; this is the only position they are active.
Definition at line 201 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnNegativeDelta | |||
| ) |
Swap two adjacent sorted values to create a negative delta (descending pair). In the field, ordered[i+1] - ordered[i] becomes a huge element, not in {0,1,2,3}.
Definition at line 280 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| DeltaRangeFailsOnOrderedMaskingBoundary | |||
| ) |
Corrupt ordered poly at position circuit_size - MAX_RANDOM - 2, the last row where the delta constraint is enforced. This is right before lagrange_real_last + lagrange_ordered_masking kicks in.
At this position: lagrange_real_last = 0, lagrange_ordered_masking = 0. The delta to the next row (real_last, which holds 2^14-1) must be in {0,1,2,3}. Setting a value of 0 here creates a gap of 2^14 - 1 to the next row.
Definition at line 254 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| InRangeValueInMaskingFlowsToOrderedTail | |||
| ) |
Place a small in-range value (42) at a wire masking position and verify it flows correctly through concatenation into the ordered polynomial's contiguous masking tail.
The value 42 is unique among random FF masking values. We trace it: wire masking pos → concatenated poly (scattered) → ordered poly tail (contiguous). After the full pipeline, all relations should still pass.
Definition at line 402 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| PermutationFailsOnConcatenatedBlockBoundaryCorruption | |||
| ) |
Place a non-zero value at position j*MINI (block boundary, below start_index) in a concatenated poly. This position is normally zero because wire data starts at start_index=1 within each block. Changing it alters the permutation numerator without updating ordered polys.
Definition at line 667 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| PermutationFailsOnConcatenatedCorruption | |||
| ) |
Corrupt a non-masking value in concatenated_range_constraints_0, creating a multiset mismatch (numerator changes but ordered/denominator is not updated).
Definition at line 174 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| PermutationFailsOnExtraNumeratorCorruption | |||
| ) |
Corrupt ordered_extra_range_constraints_numerator (the 5th factor in the permutation numerator), creating a multiset mismatch without updating z_perm.
Definition at line 491 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| PermutationFailsOnOrderedCorruption | |||
| ) |
Corrupt a value in ordered_range_constraints_0 (denominator side of the permutation), creating a multiset mismatch without updating z_perm.
Definition at line 375 of file relation_failure.test.cpp.
| TEST_F | ( | TranslatorRelationFailureTests | , |
| PermutationFailsOnZPermCorruption | |||
| ) |
Corrupt z_perm at a mid position, breaking the running product consistency.
Definition at line 225 of file relation_failure.test.cpp.