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

Tests SingleBusLookupRelation arithmetic against a simple reference implementation. More...

Go to the source code of this file.

Classes

class  DatabusLookupRelationConsistency
 

Typedefs

using FF = fr
 
using DatabusInputElements = MegaFlavor_Generated::AllEntities< FF >
 
using AllEntities = DatabusInputElements
 
using EntityId = DatabusInputElements::EntityId
 
using KernelCalldataRelation = SingleBusLookupRelationImpl< FF, EntityId::kernel_calldata, EntityId::kernel_calldata_read_counts, EntityId::kernel_calldata_inverses, EntityId::kernel_calldata_indicator, EntityId::q_l >
 

Functions

 TEST_F (DatabusLookupRelationConsistency, RandomInputs)
 
 TEST_F (DatabusLookupRelationConsistency, InactiveGates)
 
 TEST_F (DatabusLookupRelationConsistency, ValidInverseComputation)
 
 TEST_F (DatabusLookupRelationConsistency, MismatchedReadWriteTerms)
 
 TEST_F (DatabusLookupRelationConsistency, InverseUnconstrainedAtInactiveRows)
 
 TEST_F (DatabusLookupRelationConsistency, ReadCountLocalityFailsOutsideDataRows)
 
 TEST_F (DatabusLookupRelationConsistency, WrongInverseOnReadRowFails)
 
 TEST_F (DatabusLookupRelationConsistency, WrongInverseOnWriteRowFails)
 
 TEST_F (DatabusLookupRelationConsistency, CorrectInverseOnWriteRow)
 

Detailed Description

Tests SingleBusLookupRelation arithmetic against a simple reference implementation.

Each Mega bus column is its own SingleBusLookupRelation in the flavor's Relations_<FF> tuple, and every instantiation has identical shape (4 subrelations, same algebraic identity, only the EntityId template args differ). Testing one bus — kernel_calldata, with selector q_l — is sufficient to cover the relation's behavior. The four subrelations being validated are:

1a Inverse correctness on read rows: (I·L·T − 1) · is_read = 0 1b Inverse correctness on write rows: (I·L·T − 1) · count = 0 2 Log-derivative lookup identity: Σ_rows (is_read·T − count·L)·I = 0 3 Read-count locality: (1 − indicator) · count = 0

Definition in file databus_lookup_relation_consistency.test.cpp.

Typedef Documentation

◆ AllEntities

◆ DatabusInputElements

◆ EntityId

◆ FF

using FF = fr

Definition at line 23 of file databus_lookup_relation_consistency.test.cpp.

◆ KernelCalldataRelation

using KernelCalldataRelation = SingleBusLookupRelationImpl<FF, EntityId::kernel_calldata, EntityId::kernel_calldata_read_counts, EntityId::kernel_calldata_inverses, EntityId::kernel_calldata_indicator, EntityId::q_l>

Definition at line 31 of file databus_lookup_relation_consistency.test.cpp.

Function Documentation

◆ TEST_F() [1/9]

TEST_F ( DatabusLookupRelationConsistency  ,
CorrectInverseOnWriteRow   
)

Pure write row with correct inverse: (1a)/(1b) zero; (2) contributes nonzero per-row (the row sum cancels at the trace level).

Definition at line 319 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [2/9]

TEST_F ( DatabusLookupRelationConsistency  ,
InactiveGates   
)

Inactive gate (no read, no count) → all four subrelations vanish.

Definition at line 124 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [3/9]

TEST_F ( DatabusLookupRelationConsistency  ,
InverseUnconstrainedAtInactiveRows   
)

At inactive rows the inverse is unconstrained — set it to garbage and confirm no subrelation is affected.

Definition at line 216 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [4/9]

TEST_F ( DatabusLookupRelationConsistency  ,
MismatchedReadWriteTerms   
)

Mismatched read/write terms: the per-row component of (2) becomes nonzero.

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

◆ TEST_F() [5/9]

TEST_F ( DatabusLookupRelationConsistency  ,
RandomInputs   
)

◆ TEST_F() [6/9]

TEST_F ( DatabusLookupRelationConsistency  ,
ReadCountLocalityFailsOutsideDataRows   
)

Nonzero read-count outside the bus's data rows → (3) fires.

Definition at line 238 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [7/9]

TEST_F ( DatabusLookupRelationConsistency  ,
ValidInverseComputation   
)

Valid read with correct inverse: all per-row subrelations vanish; lookup identity is also zero here because L == T (the read's value/index match the table).

Definition at line 148 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [8/9]

TEST_F ( DatabusLookupRelationConsistency  ,
WrongInverseOnReadRowFails   
)

Wrong inverse on a read row → (1a) fires.

Definition at line 255 of file databus_lookup_relation_consistency.test.cpp.

◆ TEST_F() [9/9]

TEST_F ( DatabusLookupRelationConsistency  ,
WrongInverseOnWriteRowFails   
)

Wrong inverse on a write row (count != 0, no read gate) → (1b) fires.

Definition at line 286 of file databus_lookup_relation_consistency.test.cpp.