Skip to content

Commit ed81ff5

Browse files
Maddiaa0alejoamirasalexghrasteritecharlielye
committed
fix(sol-verifier): templating error
Optimized verifier has a templating error - denominator inverses should not have started at the scratch space pointer used in the other bary centric values loop before, rather continued on from pointer Co-authored-by: Alejo Amiras <alejo.amiras@gmail.com> Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com> Co-authored-by: Ary Borenszweig <asterite@gmail.com> Co-authored-by: Charlie <5764343+charlielye@users.noreply.github.com> Co-authored-by: Charlie Lye <5764343+charlielye@users.noreply.github.com> Co-authored-by: Ciara Nightingale <ciara.nightingale@sky.com> Co-authored-by: DanielKotov <159419107+DanielKotov@users.noreply.github.com> Co-authored-by: DanielKotov <katod.daniel@gmail.com> Co-authored-by: David Banks <47112877+dbanks12@users.noreply.github.com> Co-authored-by: Esau <esau@aztecprotocol.com> Co-authored-by: Facundo <fcarreiro@users.noreply.github.com> Co-authored-by: Ilyas Ridhuan <ilyas@aztecprotocol.com> Co-authored-by: IlyasRidhuan <ilyasridhuan@gmail.com> Co-authored-by: Innokentii Sennovskii <isennovskiy@gmail.com> Co-authored-by: Jan Beneš <janbenes1234@gmail.com> Co-authored-by: Jean M <132435771+jeanmon@users.noreply.github.com> Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com> Co-authored-by: Jonathan Hao <jonathanpohsianghao@gmail.com> Co-authored-by: Josh Crites <jc@joshcrites.com> Co-authored-by: José Pedro Sousa <jose@aztecprotocol.com> Co-authored-by: José Pedro Sousa <outgoing@zpedro.dev> Co-authored-by: Khashayar Barooti <khashayar@aztecprotocol.com> Co-authored-by: LHerskind <16536249+LHerskind@users.noreply.github.com> Co-authored-by: Lasse Herskind <16536249+LHerskind@users.noreply.github.com> Co-authored-by: Leila Wang <leizciw@gmail.com> Co-authored-by: Lucas Xia <lucasxia01@gmail.com> Co-authored-by: Miranda Wood <miranda@aztecprotocol.com> Co-authored-by: MirandaWood <58737490+MirandaWood@users.noreply.github.com> Co-authored-by: MirandaWood <miranda@aztecprotocol.com> Co-authored-by: Mitch <mitchell@aztecprotocol.com> Co-authored-by: Mitchell Tracy <mitchellftracy@gmail.com> Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com> Co-authored-by: Phil Windle <philip.windle@gmail.com> Co-authored-by: PhilWindle <60546371+PhilWindle@users.noreply.github.com> Co-authored-by: PhilWindle <philip.windle@gmail.com> Co-authored-by: Ragnar <rodiondenmark@gmail.com> Co-authored-by: Raju Krishnamoorthy <krishnamoorthy@gmail.com> Co-authored-by: Rumata888 <isennovskiy@gmail.com> Co-authored-by: Santiago Palladino <santiago@aztec-labs.com> Co-authored-by: Santiago Palladino <santiago@aztecprotocol.com> Co-authored-by: Santiago Palladino <spalladino@gmail.com> Co-authored-by: Sarkoxed <75146596+Sarkoxed@users.noreply.github.com> Co-authored-by: Sarkoxed <sarkoxed2013@yandex.ru> Co-authored-by: Savio <72797635+Savio-Sou@users.noreply.github.com> Co-authored-by: Savio-Sou <72797635+Savio-Sou@users.noreply.github.com> Co-authored-by: StoneMac65 <StoneMac65@gmail.com> Co-authored-by: Suyash Bagad <suyash@aztecprotocol.com> Co-authored-by: Thunkar <5404052+Thunkar@users.noreply.github.com> Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> Co-authored-by: TomAFrench <15848336+TomAFrench@users.noreply.github.com> Co-authored-by: alejoamiras <2982991+alejoamiras@users.noreply.github.com> Co-authored-by: alexghr <3816165+alexghr@users.noreply.github.com> Co-authored-by: benesjan <13470840+benesjan@users.noreply.github.com> Co-authored-by: benesjan <janbenes1234@gmail.com> Co-authored-by: charlielye <5764343+charlielye@users.noreply.github.com> Co-authored-by: ciaranightingale <52419674+ciaranightingale@users.noreply.github.com> Co-authored-by: critesjosh <18372439+critesjosh@users.noreply.github.com> Co-authored-by: danielntmd <danielntmd@nethermind.io> Co-authored-by: dbanks12 <david@aztec-labs.com> Co-authored-by: defkit <84741533+defkit@users.noreply.github.com> Co-authored-by: fcarreiro <facundo@aztecprotocol.com> Co-authored-by: federicobarbacovi <171914500+federicobarbacovi@users.noreply.github.com> Co-authored-by: feltroid Prime <96737978+feltroidprime@users.noreply.github.com> Co-authored-by: guipublic <47281315+guipublic@users.noreply.github.com> Co-authored-by: iAmMichaelConnor <42943676+iAmMichaelConnor@users.noreply.github.com> Co-authored-by: iAmMichaelConnor <mike@aztecprotocol.com> Co-authored-by: iakovenkos <sergey.s.yakovenko@gmail.com> Co-authored-by: jeanmon <132435771+jeanmon@users.noreply.github.com> Co-authored-by: jeanmon <jean@aztec-labs.com> Co-authored-by: jewelofchaos9 <jewelofchaos9@gmail.com> Co-authored-by: jorem321 <jorgearce321@gmail.com> Co-authored-by: josh crites <critesjosh@gmail.com> Co-authored-by: josh crites <jc@joshcrites.com> Co-authored-by: just-mitch <68168980+just-mitch@users.noreply.github.com> Co-authored-by: ledwards2225 <98505400+ledwards2225@users.noreply.github.com> Co-authored-by: ledwards2225 <l.edwards.d@gmail.com> Co-authored-by: lucasxia01 <lucasxia01@gmail.com> Co-authored-by: ludamad <163993+ludamad@users.noreply.github.com> Co-authored-by: ludamad <adam.domurad@gmail.com> Co-authored-by: ludamad <domuradical@gmail.com> Co-authored-by: maramihali <mara@aztec-labs.com> Co-authored-by: mralj <11197201+mralj@users.noreply.github.com> Co-authored-by: mralj <nikola.mratinic@gmail.com> Co-authored-by: mverzilli <651693+mverzilli@users.noreply.github.com> Co-authored-by: nishatkoti <nishatkoti@gmail.com> Co-authored-by: nventuro <2530770+nventuro@users.noreply.github.com> Co-authored-by: saleel <13466197+saleel@users.noreply.github.com> Co-authored-by: saleel <saleel@saleel.xyz> Co-authored-by: sarkoxed <sarkoxed2013@yandex.ru> Co-authored-by: sergei iakovenko <105737703+iakovenkos@users.noreply.github.com> Co-authored-by: signorecello <20129824+signorecello@users.noreply.github.com> Co-authored-by: signorecello <github@zpedro.dev> Co-authored-by: sirasistant <5372114+sirasistant@users.noreply.github.com> Co-authored-by: sirasistant <sirasistant@gmail.com> Co-authored-by: sklppy <152162806+sklppy88@users.noreply.github.com> Co-authored-by: sklppy88 <152162806+sklppy88@users.noreply.github.com> Co-authored-by: spalladino <429604+spalladino@users.noreply.github.com> Co-authored-by: spypsy <6403450+spypsy@users.noreply.github.com> Co-authored-by: spypsy <spypsy@outlook.com> Co-authored-by: suyash67 <suyashnbagad1997@gmail.com> Co-authored-by: thunkar <gregojquiros@gmail.com> Co-authored-by: wildjos <13541715+wildjos@users.noreply.github.com> Co-authored-by: Álvaro Rodríguez <sirasistant@gmail.com>
1 parent effc6d1 commit ed81ff5

File tree

3 files changed

+313
-313
lines changed

3 files changed

+313
-313
lines changed

barretenberg/cpp/src/barretenberg/dsl/acir_proofs/honk_optimized_contract.hpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ inline std::string generate_memory_offsets(int log_n)
248248
}
249249
for (int i = 0; i < log_n; ++i) {
250250
for (int j = 0; j < BARYCENTRIC_DOMAIN_SIZE; ++j) {
251-
print_fr(bary_pointer,
251+
print_fr(pointer,
252252
"BARYCENTRIC_DENOMINATOR_INVERSES_" + std::to_string(i) + "_" + std::to_string(j) + "_LOC");
253-
bary_pointer += 32;
253+
pointer += 32;
254254
}
255255
}
256256
print_header_centered("SUMCHECK - RUNTIME MEMORY - BARYCENTRIC COMPLETE");
@@ -299,55 +299,54 @@ inline std::string generate_memory_offsets(int log_n)
299299
print_header_centered("SHPLEMINI - RUNTIME MEMORY - INVERSIONS");
300300

301301
// Inverted gemini denominators
302-
int inv_pointer = SCRATCH_SPACE_POINTER;
303302
for (int i = 0; i < log_n + 1; ++i) {
304-
print_fr(inv_pointer, "INVERTED_GEMINI_DENOMINATOR_" + std::to_string(i) + "_LOC");
305-
inv_pointer += 32;
303+
print_fr(pointer, "INVERTED_GEMINI_DENOMINATOR_" + std::to_string(i) + "_LOC");
304+
pointer += 32;
306305
}
307306

308307
// Batched evaluation accumulator inversions
309308
for (int i = 0; i < log_n; ++i) {
310-
print_fr(inv_pointer, "BATCH_EVALUATION_ACCUMULATOR_INVERSION_" + std::to_string(i) + "_LOC");
311-
inv_pointer += 32;
309+
print_fr(pointer, "BATCH_EVALUATION_ACCUMULATOR_INVERSION_" + std::to_string(i) + "_LOC");
310+
pointer += 32;
312311
}
313312

314313
out << "\n";
315-
print_fr(inv_pointer, "BATCHED_EVALUATION_LOC");
316-
inv_pointer += 32;
317-
print_fr(inv_pointer, "CONSTANT_TERM_ACCUMULATOR_LOC");
318-
inv_pointer += 32;
314+
print_fr(pointer, "BATCHED_EVALUATION_LOC");
315+
pointer += 32;
316+
print_fr(pointer, "CONSTANT_TERM_ACCUMULATOR_LOC");
317+
pointer += 32;
319318

320319
out << "\n";
321-
print_fr(inv_pointer, "POS_INVERTED_DENOMINATOR");
322-
inv_pointer += 32;
323-
print_fr(inv_pointer, "NEG_INVERTED_DENOMINATOR");
324-
inv_pointer += 32;
320+
print_fr(pointer, "POS_INVERTED_DENOMINATOR");
321+
pointer += 32;
322+
print_fr(pointer, "NEG_INVERTED_DENOMINATOR");
323+
pointer += 32;
325324

326325
out << "\n";
327326
out << "// LOG_N challenge pow minus u\n";
328327
for (int i = 0; i < log_n; ++i) {
329-
print_fr(inv_pointer, "INVERTED_CHALLENEGE_POW_MINUS_U_" + std::to_string(i) + "_LOC");
330-
inv_pointer += 32;
328+
print_fr(pointer, "INVERTED_CHALLENEGE_POW_MINUS_U_" + std::to_string(i) + "_LOC");
329+
pointer += 32;
331330
}
332331

333332
out << "\n";
334333
out << "// LOG_N pos_inverted_off\n";
335334
for (int i = 0; i < log_n; ++i) {
336-
print_fr(inv_pointer, "POS_INVERTED_DENOM_" + std::to_string(i) + "_LOC");
337-
inv_pointer += 32;
335+
print_fr(pointer, "POS_INVERTED_DENOM_" + std::to_string(i) + "_LOC");
336+
pointer += 32;
338337
}
339338

340339
out << "\n";
341340
out << "// LOG_N neg_inverted_off\n";
342341
for (int i = 0; i < log_n; ++i) {
343-
print_fr(inv_pointer, "NEG_INVERTED_DENOM_" + std::to_string(i) + "_LOC");
344-
inv_pointer += 32;
342+
print_fr(pointer, "NEG_INVERTED_DENOM_" + std::to_string(i) + "_LOC");
343+
pointer += 32;
345344
}
346345

347346
out << "\n";
348347
for (int i = 0; i < log_n; ++i) {
349-
print_fr(inv_pointer, "FOLD_POS_EVALUATIONS_" + std::to_string(i) + "_LOC");
350-
inv_pointer += 32;
348+
print_fr(pointer, "FOLD_POS_EVALUATIONS_" + std::to_string(i) + "_LOC");
349+
pointer += 32;
351350
}
352351

353352
print_header_centered("SHPLEMINI RUNTIME MEMORY - INVERSIONS - COMPLETE");
@@ -368,7 +367,6 @@ inline std::string generate_memory_offsets(int log_n)
368367
// Scratch space aliases
369368
out << "\n";
370369
out << "// Aliases for scratch space\n";
371-
out << "// TODO: work out the stack scheduling for these\n";
372370
print_fr(0x00, "CHALL_POW_LOC");
373371
print_fr(0x20, "SUMCHECK_U_LOC");
374372
print_fr(0x40, "GEMINI_A_LOC");
@@ -840,7 +838,6 @@ contract HonkVerifier is IVerifier {
840838
841839
mcopy(0x20, LOOKUP_INVERSES_X_LOC, 0x80)
842840
843-
// Generate single alpha challenge and compute its powers
844841
prev_challenge := mod(keccak256(0x00, 0xa0), p)
845842
mstore(0x00, prev_challenge)
846843
let alpha := and(prev_challenge, LOWER_127_MASK)
@@ -1315,7 +1312,7 @@ contract HonkVerifier is IVerifier {
13151312
13161313
// Normalise as last loop will have incremented the offset
13171314
bary_centric_inverses_off := sub(bary_centric_inverses_off, 0x20)
1318-
for {} gt(bary_centric_inverses_off, BARYCENTRIC_LAGRANGE_DENOMINATOR_7_LOC) {
1315+
for {} gt(bary_centric_inverses_off, SUM_U_CHALLENGE_{{ LOG_N_MINUS_ONE }}) {
13191316
bary_centric_inverses_off := sub(bary_centric_inverses_off, 0x20)
13201317
} {
13211318
let tmp := mulmod(accumulator, mload(temp), p)

barretenberg/sol/scripts/copy_optimized_to_cpp.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ sed -i -E 's/(uint256 constant NUMBER_PUBLIC_INPUTS = )[0-9]+;/\1{{ NUM_PUBLIC_I
6868
sed -i -E 's/(uint256 constant REAL_NUMBER_PUBLIC_INPUTS = )[0-9]+ - [0-9]+;/\1{{ REAL_NUM_PUBLIC_INPUTS }};/' "$TEMP_SOL"
6969
sed -i -E 's/(uint256 constant NUMBER_OF_BARYCENTRIC_INVERSES = )[0-9]+;/\1{{ NUMBER_OF_BARYCENTRIC_INVERSES }};/' "$TEMP_SOL"
7070

71+
# Replace the for-loop comparison to use a template placeholder for CIRCUIT_SIZE
72+
sed -i -E 's/for \{\} gt\(bary_centric_inverses_off, SUM_U_CHALLENGE_14\) \{/for {} gt(bary_centric_inverses_off, SUM_U_CHALLENGE_{{ LOG_N_MINUS_ONE }}) \{/' "$TEMP_SOL"
73+
7174
# Replace the contract name
7275
sed -i 's/contract BlakeOptHonkVerifier/contract HonkVerifier/' "$TEMP_SOL"
7376

0 commit comments

Comments
 (0)