Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
generic_lookup_relation.test.cpp File Reference
#include "generic_lookup_relation.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/relations/relation_parameters.hpp"
#include <array>
#include <gtest/gtest.h>

Go to the source code of this file.

Classes

struct  SettingsBasicLookup
 
struct  SettingsCustomizedLookup
 
class  GenericLookupRelationTest< Settings >
 
class  BasicLookupTest
 
class  CustomizedLookupTest
 
struct  SettingsMixedLookup
 
class  MixedLookupTest
 

Typedefs

using FF = bb::fr
 

Functions

 TEST_F (BasicLookupTest, InactiveRow)
 An all-zero row must leave both subrelations at zero.
 
 TEST_F (BasicLookupTest, ValidLookupRow)
 A correctly-set-up lookup row satisfies subrelation 0.
 
 TEST_F (BasicLookupTest, ValidTableRow)
 A correctly-set-up table row satisfies subrelation 0.
 
 TEST_F (BasicLookupTest, ValidTrace)
 A two-row trace with matching lookup/table terms satisfies the log-derivative identity.
 
 TEST_F (BasicLookupTest, IncorrectInverse)
 An active lookup row with an incorrect inverse violates subrelation 0.
 
 TEST_F (BasicLookupTest, InvalidLookup)
 Table term mismatch: lookup_term0 = 1*beta+2+gamma, table_term1 = 2*beta+4+gamma → acc[1] ≠ 0.
 
 TEST_F (BasicLookupTest, InvalidReadCount)
 Read count mismatch: table_term1 = lookup_term0 but read_count=2 → acc[1] = -1/lookup_term0 ≠ 0.
 
 TEST_F (CustomizedLookupTest, InactiveRow)
 All-zero row → both subrelations are zero.
 
 TEST_F (CustomizedLookupTest, ValidLookupRow)
 Correctly-set-up lookup row satisfies subrelation 0.
 
 TEST_F (CustomizedLookupTest, ValidTableRow)
 Correctly-set-up table row satisfies subrelation 0.
 
 TEST_F (CustomizedLookupTest, ValidTrace)
 Two-row trace with matching lookup/table terms satisfies the log-derivative identity.
 
 TEST_F (CustomizedLookupTest, IncorrectInverse)
 Wrong inverse on a customized active row violates subrelation 0.
 
 TEST_F (CustomizedLookupTest, InvalidLookup)
 Table term mismatch: lookup_term0=9, table_t_value=8 → acc[1] = 1/9 - 1/8 ≠ 0.
 
 TEST_F (CustomizedLookupTest, InvalidReadCount)
 Read count mismatch: table_t_value=9 matches but read_count=2 → acc[1] = 1/9 - 2/9 ≠ 0.
 
 TEST_F (MixedLookupTest, InactiveRow)
 An all-zero row leaves both subrelations at zero.
 
 TEST_F (MixedLookupTest, ValidLookupRow)
 A correctly-set-up basic lookup row satisfies subrelation 0. in[3]=1 or in[4] = 1, all other predicates 0.
 
 TEST_F (MixedLookupTest, ValidTableRow)
 A correctly-set-up table-0 row satisfies subrelation 0. in[5]=1 or in[6] = 1, all other predicates 0.
 
 TEST_F (MixedLookupTest, ValidTrace)
 A two-row trace where the basic lookup matches table 0 satisfies the log-derivative identity.
 
 TEST_F (MixedLookupTest, IncorrectInverse)
 Wrong inverse on an active basic lookup row violates subrelation 0.
 
 TEST_F (MixedLookupTest, InvalidLookup)
 Table term mismatch.
 
 TEST_F (MixedLookupTest, InvalidReadCount)
 Read count mismatch.
 

Typedef Documentation

◆ FF

using FF = bb::fr

Definition at line 8 of file generic_lookup_relation.test.cpp.

Function Documentation

◆ TEST_F() [1/21]

TEST_F ( BasicLookupTest  ,
InactiveRow   
)

An all-zero row must leave both subrelations at zero.

When no predicate is active, inverse_exists = 0, lookup_inverse = 0: subrel_0 = (prod * 0 - 0) * sf = 0 subrel_1 += 0 * ... - 0 * ... = 0

Definition at line 294 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [2/21]

TEST_F ( BasicLookupTest  ,
IncorrectInverse   
)

An active lookup row with an incorrect inverse violates subrelation 0.

We set I to a wrong value (not the product-inverse) and confirm subrelation 0 ≠ 0.

Definition at line 388 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [3/21]

TEST_F ( BasicLookupTest  ,
InvalidLookup   
)

Table term mismatch: lookup_term0 = 1*beta+2+gamma, table_term1 = 2*beta+4+gamma → acc[1] ≠ 0.

Definition at line 422 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [4/21]

TEST_F ( BasicLookupTest  ,
InvalidReadCount   
)

Read count mismatch: table_term1 = lookup_term0 but read_count=2 → acc[1] = -1/lookup_term0 ≠ 0.

Definition at line 432 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [5/21]

TEST_F ( BasicLookupTest  ,
ValidLookupRow   
)

A correctly-set-up lookup row satisfies subrelation 0.

With lookup_predicate=1, table_predicate=0: inverse_exists = 1 I = 1 / (lookup_term * table_term) subrel_0 = I * lookup_term * table_term - 1 = 0

Definition at line 311 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [6/21]

TEST_F ( BasicLookupTest  ,
ValidTableRow   
)

A correctly-set-up table row satisfies subrelation 0.

With lookup_predicate=0, table_predicate=1, read_count=1: inverse_exists = 1 I = 1 / (lookup_term * table_term) subrel_0 = I * lookup_term * table_term - 1 = 0

Definition at line 345 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [7/21]

TEST_F ( BasicLookupTest  ,
ValidTrace   
)

A two-row trace with matching lookup/table terms satisfies the log-derivative identity.

t1=1, t2=2 on row 1 → table_term1 = 1*beta + 2 + gamma = lookup_term0, so acc[1] = 0.

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

◆ TEST_F() [8/21]

TEST_F ( CustomizedLookupTest  ,
InactiveRow   
)

All-zero row → both subrelations are zero.

Definition at line 496 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [9/21]

TEST_F ( CustomizedLookupTest  ,
IncorrectInverse   
)

Wrong inverse on a customized active row violates subrelation 0.

Definition at line 570 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [10/21]

TEST_F ( CustomizedLookupTest  ,
InvalidLookup   
)

Table term mismatch: lookup_term0=9, table_t_value=8 → acc[1] = 1/9 - 1/8 ≠ 0.

Definition at line 595 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [11/21]

TEST_F ( CustomizedLookupTest  ,
InvalidReadCount   
)

Read count mismatch: table_t_value=9 matches but read_count=2 → acc[1] = 1/9 - 2/9 ≠ 0.

Definition at line 604 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [12/21]

TEST_F ( CustomizedLookupTest  ,
ValidLookupRow   
)

Correctly-set-up lookup row satisfies subrelation 0.

lookup_term = f^2, f = in[4] table_term = t , t = in[5] (arbitrary, since table_pred=0)

Definition at line 511 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [13/21]

TEST_F ( CustomizedLookupTest  ,
ValidTableRow   
)

Correctly-set-up table row satisfies subrelation 0.

lookup_term = f^2, f = in[4] (arbitrary) table_term = t , t = in[5]

Definition at line 536 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [14/21]

TEST_F ( CustomizedLookupTest  ,
ValidTrace   
)

Two-row trace with matching lookup/table terms satisfies the log-derivative identity.

table_t_value=9 (=v^2) matches lookup_term0=9, so acc[1] = 1/9 - 1/9 = 0.

Definition at line 561 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [15/21]

TEST_F ( MixedLookupTest  ,
InactiveRow   
)

An all-zero row leaves both subrelations at zero.

All predicates (in[3], in[4], in[5], in[6]) are 0, so inverse_exists = OR(OR(0,0), OR(0,0)) = 0 and no inverse is needed. subrel_0 = 0*prod - 0 = 0 subrel_1 = all predicate contributions = 0

Definition at line 878 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [16/21]

TEST_F ( MixedLookupTest  ,
IncorrectInverse   
)

Wrong inverse on an active basic lookup row violates subrelation 0.

Definition at line 995 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [17/21]

TEST_F ( MixedLookupTest  ,
InvalidLookup   
)

Table term mismatch.

Definition at line 1037 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [18/21]

TEST_F ( MixedLookupTest  ,
InvalidReadCount   
)

Read count mismatch.

Definition at line 1051 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [19/21]

TEST_F ( MixedLookupTest  ,
ValidLookupRow   
)

A correctly-set-up basic lookup row satisfies subrelation 0. in[3]=1 or in[4] = 1, all other predicates 0.

Definition at line 891 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [20/21]

TEST_F ( MixedLookupTest  ,
ValidTableRow   
)

A correctly-set-up table-0 row satisfies subrelation 0. in[5]=1 or in[6] = 1, all other predicates 0.

Definition at line 938 of file generic_lookup_relation.test.cpp.

◆ TEST_F() [21/21]

TEST_F ( MixedLookupTest  ,
ValidTrace   
)

A two-row trace where the basic lookup matches table 0 satisfies the log-derivative identity.

Definition at line 986 of file generic_lookup_relation.test.cpp.