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

Tests LogDerivLookupRelation arithmetic against a direct reference implementation. More...

Go to the source code of this file.

Classes

class  LogDerivLookupRelationConsistency
 

Typedefs

using FF = fr
 
using Inputs = UltraFlavor_Generated::AllEntities< FF >
 
using EntityId = Inputs::EntityId
 
using LookupRelation = LogDerivLookupRelationImpl< FF >
 
using SubrelationAccumulator = std::array< FF, NUM_SUBRELATIONS >
 

Functions

 TEST_F (LogDerivLookupRelationConsistency, RandomInputsMatchReference)
 
 TEST_F (LogDerivLookupRelationConsistency, InactiveRow)
 
 TEST_F (LogDerivLookupRelationConsistency, ValidLookupRow)
 
 TEST_F (LogDerivLookupRelationConsistency, ValidWriteRow)
 
 TEST_F (LogDerivLookupRelationConsistency, ValidTraceSumsToZero)
 
 TEST_F (LogDerivLookupRelationConsistency, WrongInverseFires)
 
 TEST_F (LogDerivLookupRelationConsistency, InverseMustBeZeroOnInactiveRows)
 
 TEST_F (LogDerivLookupRelationConsistency, WrongReadCount)
 
 TEST_F (LogDerivLookupRelationConsistency, NonBooleanReadTagFiresBooleanCheck)
 
 TEST_F (LogDerivLookupRelationConsistency, SkipBehavior)
 
 TEST_F (LogDerivLookupRelationConsistency, ZeroTableIndex)
 

Detailed Description

Tests LogDerivLookupRelation arithmetic against a direct reference implementation.

The relation has three subrelations:

1 Inverse correctness: (I·L·T − inverse_exists) · sf = 0 per-row, deg 4 2 Lookup identity: Σ_rows (q_lookup·T − read_count·L) · I per-row deg 4, summed (no scaling) 3 read_tag boolean check: (read_tag² − read_tag) · sf = 0 per-row, deg 2

Where

L = (w_l + γ + q_r·w_l_shift) + β·(w_r + q_m·w_r_shift) + β²·(w_o + q_c·w_o_shift) + β³·q_o T = table_1 + γ + β·table_2 + β²·table_3 + β³·table_4 inverse_exists = q_lookup + read_tag − q_lookup·read_tag (i.e. OR when both are boolean)

Definition in file logderiv_lookup_relation.test.cpp.

Typedef Documentation

◆ EntityId

Definition at line 28 of file logderiv_lookup_relation.test.cpp.

◆ FF

using FF = fr

Definition at line 26 of file logderiv_lookup_relation.test.cpp.

◆ Inputs

◆ LookupRelation

◆ SubrelationAccumulator

using SubrelationAccumulator = std::array<FF, NUM_SUBRELATIONS>

Definition at line 32 of file logderiv_lookup_relation.test.cpp.

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
InactiveRow   
)

All-zero row: every subrelation vanishes (inverse_exists = 0, I = 0, read_tag = 0).

Definition at line 172 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [2/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
InverseMustBeZeroOnInactiveRows   
)

On inactive rows (q_lookup = read_tag = 0) the inverse subrelation reduces to L·T·I (since inverse_exists = 0). This forces the prover to set I = 0 on those rows — otherwise the inverse subrelation fires.

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

◆ TEST_F() [3/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
NonBooleanReadTagFiresBooleanCheck   
)

Non-boolean read_tag fires subrelation (3).

Definition at line 348 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [4/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
RandomInputsMatchReference   
)

Reference matches accumulate on both random and structured inputs, with two scaling factors.

Definition at line 159 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [5/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
SkipBehavior   
)

skip() returns true iff the row is neither a read gate nor has a non-zero read count.

Definition at line 359 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [6/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
ValidLookupRow   
)

Valid lookup-gate row (q_lookup=1, read_tag=1, correct I). All three subrelations vanish.

Definition at line 183 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [7/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
ValidTraceSumsToZero   
)

Two-row trace: read row + matching write row with read_count=1 → lookup identity sum vanishes.

Definition at line 217 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [8/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
ValidWriteRow   
)

Pure write row (q_lookup=0, read_tag=1, read_count != 0, correct I). Inverse correctness still fires via read_tag → inverse_exists = 1; lookup identity is non-zero per-row (cancels at the trace level against a matching read).

Definition at line 196 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [9/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
WrongInverseFires   
)

A wrong inverse on an active row fires subrelation (1).

Definition at line 256 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [10/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
WrongReadCount   
)

Read-count mismatch (extra read claimed on a table row) leaves per-row inverse correctness satisfied but breaks the trace-level lookup identity.

Definition at line 309 of file logderiv_lookup_relation.test.cpp.

◆ TEST_F() [11/11]

TEST_F ( LogDerivLookupRelationConsistency  ,
ZeroTableIndex   
)

Regression test for exploit that used a lookup term with no dependence on beta. If such a term existed, then a malicious prover could plant a forged row balancing the lookup with table entries not in the table. Check that lookup row with table index != 0 picks up a beta^3 term. This makes it impossible to exploit a lookup term that has no dependence on beta because table_index > 0 in the codebase.

Definition at line 376 of file logderiv_lookup_relation.test.cpp.