Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: barretenberg/stdlib/logic bugs #11651

Merged
merged 43 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a837887
IT FINALLY WORKS :D
jewelofchaos9 Nov 18, 2024
5750f4c
i forgot cmakelists
jewelofchaos9 Nov 18, 2024
cc71c30
save artifacts
jewelofchaos9 Nov 18, 2024
a791e76
stable version for verifying
jewelofchaos9 Nov 21, 2024
56559cf
dummy
jewelofchaos9 Nov 22, 2024
c364e63
IT FINALLY WORKS :D
jewelofchaos9 Nov 18, 2024
579c5ff
i forgot cmakelists
jewelofchaos9 Nov 18, 2024
be6ef36
save artifacts
jewelofchaos9 Nov 18, 2024
6b27d0e
stable version for verifying
jewelofchaos9 Nov 21, 2024
84319b2
dummy
jewelofchaos9 Nov 22, 2024
28cd1f9
smol refactor
jewelofchaos9 Nov 25, 2024
8ea00fc
smol refactor
jewelofchaos9 Nov 25, 2024
2ff5084
smol refactor
jewelofchaos9 Nov 25, 2024
58c1268
forgot to resolve merge conflicts
jewelofchaos9 Nov 25, 2024
e1a6541
i forgor to resolve conflicts in cargolock...
Nov 26, 2024
7dd7e98
hmm
jewelofchaos9 Nov 27, 2024
d58a19a
smol refactor
jewelofchaos9 Nov 29, 2024
4f07105
ples have a patient i have problems
jewelofchaos9 Dec 2, 2024
e33a29f
verif changes
jewelofchaos9 Dec 3, 2024
802b0cd
smol shifts
jewelofchaos9 Dec 9, 2024
d7dd95d
deleted codegen + shl + shr
jewelofchaos9 Dec 12, 2024
2cf19f0
bug in acir builder
jewelofchaos9 Dec 12, 2024
10b361f
recaftor
jewelofchaos9 Dec 16, 2024
3cc7f44
docs + small refactor
jewelofchaos9 Dec 27, 2024
884b2aa
readme mistake, artifacts dirs
jewelofchaos9 Dec 27, 2024
ef9c730
restore cmake list
jewelofchaos9 Dec 27, 2024
208f9ce
bug in verify_mod
jewelofchaos9 Dec 27, 2024
97bfad1
still bug in verify_mod
jewelofchaos9 Dec 27, 2024
1c90845
deleted gitignores + table + shl64 bug + directory flag for binary
jewelofchaos9 Jan 6, 2025
442e387
readme mistake, deleted all noir stuff
jewelofchaos9 Jan 6, 2025
29ed080
broken table
jewelofchaos9 Jan 6, 2025
f32a27e
last readme fix
jewelofchaos9 Jan 6, 2025
711e138
fix_negative
jewelofchaos9 Jan 31, 2025
f03033f
fix unconstrained chunks in logic AND and XOR
jewelofchaos9 Jan 31, 2025
13b589b
remove fix from other PR
jewelofchaos9 Jan 31, 2025
78226a9
remove fix from other PR
jewelofchaos9 Jan 31, 2025
c447323
moved from range constraints to tables
jewelofchaos9 Jan 31, 2025
7282a1e
from range constraints to tables fix
jewelofchaos9 Jan 31, 2025
2c45aa6
Please be patient.
jewelofchaos9 Jan 31, 2025
560676f
CHANGE TEST plonk_honk_shared LookupReadCounts
jewelofchaos9 Feb 1, 2025
29e1a8a
name mismatch
jewelofchaos9 Feb 1, 2025
ea6a397
blank
jewelofchaos9 Feb 3, 2025
dcb36bd
Merge remote-tracking branch 'origin/master' into sn/fix_logic_bugs
jewelofchaos9 Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ TEST_F(ComposerLibTests, LookupReadCounts)
auto accumulators = plookup::get_lookup_accumulators(UINT32_XOR, left, right, /*is_2_to_1_lookup*/ true);
builder.create_gates_from_plookup_accumulators(UINT32_XOR, accumulators, left_idx, right_idx);

EXPECT_EQ(builder.lookup_tables.size(), 1); // we only used a single table
EXPECT_EQ(builder.lookup_tables[0].size(), 4096); // table has size 64*64 (6 bit operands)
EXPECT_EQ(builder.lookup_tables.size(), 2); // we only used two tables, first for 6 bits, second for 2 bits
EXPECT_EQ(builder.lookup_tables[0].size(), 4096); // first table has size 64*64 (6 bit operands)
EXPECT_EQ(builder.lookup_tables[1].size(), 16); // first table has size 4*4 (2 bit operands)

size_t circuit_size = 8192;

Expand All @@ -59,15 +60,19 @@ TEST_F(ComposerLibTests, LookupReadCounts)

// The uint32 XOR lookup table is constructed for 6 bit operands via double for loop that iterates through the left
// operand externally (0 to 63) then the right operand internally (0 to 63). Computing (1 XOR 5) will thus result in
// 1 lookup from the (1*64 + 5)th index in the table and 5 lookups from the (0*64 + 0)th index (for the remaining 5
// limbs that are all 0). The counts and tags at all other indices should be zero.
// 1 lookup from the (1*64 + 5)th index in the table and 4 lookups from the (0*64 + 0)th index (for the remaining 4
// 6-bits limbs that are all 0) and one lookup from second table from the (64 * 64 + 0) index (for last 2 bits).
// The counts and tags at all other indices should be zero.
for (auto [idx, count, tag] : zip_polys(read_counts, read_tags)) {
if (idx == (0 + offset)) {
EXPECT_EQ(count, 5);
EXPECT_EQ(count, 4);
EXPECT_EQ(tag, 1);
} else if (idx == (69 + offset)) {
EXPECT_EQ(count, 1);
EXPECT_EQ(tag, 1);
} else if (idx == (64 * 64 + offset)) {
EXPECT_EQ(count, 1);
EXPECT_EQ(tag, 1);
} else {
EXPECT_EQ(count, 0);
EXPECT_EQ(tag, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,17 @@ BasicTable create_basic_table(const BasicTableId id, const size_t index)
case SHA256_BASE16_ROTATE2: {
return sparse_tables::generate_sparse_table_with_rotation<16, 11, 2>(SHA256_BASE16_ROTATE2, index);
}
case UINT_XOR_ROTATE0: {
return uint_tables::generate_xor_rotate_table<6, 0>(UINT_XOR_ROTATE0, index);
case UINT_XOR_SLICE_6_ROTATE_0: {
return uint_tables::generate_xor_rotate_table<6, 0>(UINT_XOR_SLICE_6_ROTATE_0, index);
}
case UINT_AND_ROTATE0: {
return uint_tables::generate_and_rotate_table<6, 0>(UINT_AND_ROTATE0, index);
case UINT_AND_SLICE_6_ROTATE_0: {
return uint_tables::generate_and_rotate_table<6, 0>(UINT_AND_SLICE_6_ROTATE_0, index);
}
case UINT_XOR_SLICE_2_ROTATE_0: {
return uint_tables::generate_xor_rotate_table<2, 0>(UINT_XOR_SLICE_2_ROTATE_0, index);
}
case UINT_AND_SLICE_2_ROTATE_0: {
return uint_tables::generate_and_rotate_table<2, 0>(UINT_AND_SLICE_2_ROTATE_0, index);
}
case BN254_XLO_BASIC: {
return ecc_generator_tables::ecc_generator_table<bb::g1>::generate_xlo_table(BN254_XLO_BASIC, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ enum BasicTableId {
SHA256_BASE16_ROTATE6,
SHA256_BASE16_ROTATE7,
SHA256_BASE16_ROTATE8,
UINT_XOR_ROTATE0,
UINT_AND_ROTATE0,
UINT_XOR_SLICE_6_ROTATE_0,
UINT_XOR_SLICE_2_ROTATE_0,
UINT_AND_SLICE_6_ROTATE_0,
UINT_AND_SLICE_2_ROTATE_0,
BN254_XLO_BASIC,
BN254_XHI_BASIC,
BN254_YLO_BASIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,49 @@ inline BasicTable generate_and_rotate_table(BasicTableId id, const size_t table_

inline MultiTable get_uint32_xor_table(const MultiTableId id = UINT32_XOR)
{
const size_t num_entries = (32 + 5) / 6;
const uint64_t base = 1 << 6;
const size_t TABLE_BIT_SIZE = 6;
const size_t num_entries = 32 / TABLE_BIT_SIZE;
const uint64_t base = 1 << TABLE_BIT_SIZE;
MultiTable table(base, base, base, num_entries);

table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(base);
table.basic_table_ids.emplace_back(UINT_XOR_ROTATE0);
table.basic_table_ids.emplace_back(UINT_XOR_SLICE_6_ROTATE_0);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<6, 0>);
}

// 32 = 5 * 6 + 2
// all remaining bits
const size_t LAST_BIT_SIZE = 32 - TABLE_BIT_SIZE * num_entries;
const size_t LAST_SLICE_SIZE = 1 << LAST_BIT_SIZE;
table.slice_sizes.emplace_back(base);
table.basic_table_ids.emplace_back(UINT_XOR_SLICE_2_ROTATE_0);
table.get_table_values.emplace_back(&get_xor_rotate_values_from_key<LAST_SLICE_SIZE, 0>);
return table;
}

inline MultiTable get_uint32_and_table(const MultiTableId id = UINT32_AND)
{
const size_t num_entries = (32 + 5) / 6;
const uint64_t base = 1 << 6;
const size_t TABLE_BIT_SIZE = 6;
const size_t num_entries = 32 / TABLE_BIT_SIZE;
const uint64_t base = 1 << TABLE_BIT_SIZE;
MultiTable table(base, base, base, num_entries);

table.id = id;
for (size_t i = 0; i < num_entries; ++i) {
table.slice_sizes.emplace_back(base);
table.basic_table_ids.emplace_back(UINT_AND_ROTATE0);
table.get_table_values.emplace_back(&get_and_rotate_values_from_key<6, 0>);
table.basic_table_ids.emplace_back(UINT_AND_SLICE_6_ROTATE_0);
table.get_table_values.emplace_back(&get_and_rotate_values_from_key<TABLE_BIT_SIZE, 0>);
}
// 32 = 5 * 6 + 2
// all remaining bits
const size_t LAST_TABLE_BIT_SIZE = 32 - TABLE_BIT_SIZE * num_entries;
const size_t LAST_SLICE_SIZE = 1 << LAST_TABLE_BIT_SIZE;
table.slice_sizes.emplace_back(LAST_SLICE_SIZE);
table.basic_table_ids.emplace_back(UINT_AND_SLICE_2_ROTATE_0);
table.get_table_values.emplace_back(&get_and_rotate_values_from_key<LAST_TABLE_BIT_SIZE, 0>);

return table;
}

Expand Down