Skip to content

Commit a3aa0f1

Browse files
ledwards2225aztec-bot
authored andcommitted
test(bb): generalize lookup table-index invariant across all tables
Replace the secp256r1-specific unique/positive table_index test with one that sweeps every basic table reachable through any MultiTable. The LogDeriv relation identifies a table solely by table_index, so this guards against any generator (not just secp256r1 fixed-base) storing a window or bit-slice position in place of the builder-assigned index. (cherry picked from commit 3a53c97)
1 parent acaff27 commit a3aa0f1

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

barretenberg/cpp/src/barretenberg/circuit_checker/ultra_circuit_builder_lookup.test.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,27 @@ TEST_F(UltraCircuitBuilderLookup, DifferentTablesGetUniqueIndices)
122122
EXPECT_EQ(builder.get_num_lookup_tables(), 3UL);
123123
}
124124

125-
TEST_F(UltraCircuitBuilderLookup, Secp256r1FixedBaseTablesGetUniquePositiveIndices)
125+
// Every basic table reachable through any MultiTable must receive a unique, positive circuit-local
126+
// table_index. The LogDeriv lookup relation identifies a table solely by table_index (not BasicTableId),
127+
// so a generator that stores anything other than the builder-assigned index — e.g. a window or bit-slice
128+
// position — silently collapses distinct tables to one identity. This sweeps the whole table space so
129+
// any such generator (not just secp256r1 fixed-base) is caught.
130+
TEST_F(UltraCircuitBuilderLookup, AllMultiTableBasicTablesGetUniquePositiveIndices)
126131
{
127132
Builder builder;
128-
std::unordered_set<size_t> table_indices;
129-
130-
const auto first_id = static_cast<size_t>(plookup::BasicTableId::SECP256R1_FIXED_BASE_XLO_0);
131-
const auto end_id = static_cast<size_t>(plookup::BasicTableId::SECP256R1_FIXED_BASE_END);
132-
for (size_t id = first_id; id < end_id; ++id) {
133-
const auto& table = builder.get_table(static_cast<plookup::BasicTableId>(id));
134-
EXPECT_GT(table.table_index, 0UL);
135-
EXPECT_TRUE(table_indices.insert(table.table_index).second);
133+
for (size_t mt = 0; mt < static_cast<size_t>(plookup::MultiTableId::NUM_MULTI_TABLES); ++mt) {
134+
const auto& multitable = plookup::get_multitable(static_cast<plookup::MultiTableId>(mt));
135+
for (const auto id : multitable.basic_table_ids) {
136+
builder.get_table(id);
137+
}
136138
}
137139

140+
std::unordered_set<size_t> seen;
141+
for (const auto& table : builder.get_lookup_tables()) {
142+
EXPECT_GT(table.table_index, 0UL) << "non-positive index for basic table id " << static_cast<size_t>(table.id);
143+
EXPECT_TRUE(seen.insert(table.table_index).second)
144+
<< "duplicate table_index " << table.table_index << " for basic table id " << static_cast<size_t>(table.id);
145+
}
138146
EXPECT_NO_THROW(builder.finalize_circuit());
139147
}
140148

0 commit comments

Comments
 (0)