Skip to content

Commit aeab64c

Browse files
committed
fix tests
1 parent 59f601f commit aeab64c

File tree

10 files changed

+159
-196
lines changed

10 files changed

+159
-196
lines changed

barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ template <typename Builder> inline constexpr size_t ASSERT_EQUALITY = ZERO_GATE
5555
// Honk Recursion Constants
5656
// ========================================
5757

58-
inline constexpr size_t ROOT_ROLLUP_GATE_COUNT = 12986977;
58+
inline constexpr size_t ROOT_ROLLUP_GATE_COUNT = 12995065;
5959

6060
template <typename RecursiveFlavor>
6161
constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
@@ -67,26 +67,26 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
6767
if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraRecursiveFlavor_<UltraCircuitBuilder>>) {
6868
switch (mode) {
6969
case PredicateTestCase::ConstantTrue:
70-
return std::make_tuple(722844, 0);
70+
return std::make_tuple(726842, 0);
7171
case PredicateTestCase::WitnessTrue:
7272
case PredicateTestCase::WitnessFalse:
73-
return std::make_tuple(723995, 0);
73+
return std::make_tuple(727993, 0);
7474
}
7575
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraZKRecursiveFlavor_<UltraCircuitBuilder>>) {
7676
switch (mode) {
7777
case PredicateTestCase::ConstantTrue:
78-
return std::make_tuple(766262, 0);
78+
return std::make_tuple(770506, 0);
7979
case PredicateTestCase::WitnessTrue:
8080
case PredicateTestCase::WitnessFalse:
81-
return std::make_tuple(767515, 0);
81+
return std::make_tuple(771759, 0);
8282
}
8383
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraRollupRecursiveFlavor_<UltraCircuitBuilder>>) {
8484
switch (mode) {
8585
case PredicateTestCase::ConstantTrue:
86-
return std::make_tuple(723163, 0);
86+
return std::make_tuple(727160, 0);
8787
case PredicateTestCase::WitnessTrue:
8888
case PredicateTestCase::WitnessFalse:
89-
return std::make_tuple(724462, 0);
89+
return std::make_tuple(728459, 0);
9090
}
9191
} else if constexpr (std::is_same_v<RecursiveFlavor, bb::UltraRecursiveFlavor_<MegaCircuitBuilder>>) {
9292
switch (mode) {
@@ -108,7 +108,7 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
108108
if (mode != PredicateTestCase::ConstantTrue) {
109109
bb::assert_failure("Unhandled mode in MegaZKRecursiveFlavor.");
110110
}
111-
return std::make_tuple(814519, 0);
111+
return std::make_tuple(817287, 0);
112112
} else {
113113
bb::assert_failure("Unhandled recursive flavor.");
114114
}
@@ -119,7 +119,7 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
119119
// ========================================
120120

121121
// Gate count for Chonk recursive verification (UltraRollup builder)
122-
inline constexpr size_t CHONK_RECURSION_GATES = 2368439;
122+
inline constexpr size_t CHONK_RECURSION_GATES = 2385506;
123123

124124
// ========================================
125125
// Hypernova Recursion Constants
@@ -153,7 +153,7 @@ inline constexpr size_t HIDING_KERNEL_ULTRA_OPS = 124;
153153
// ========================================
154154

155155
// Gate count for ECCVM recursive verifier (Ultra-arithmetized)
156-
inline constexpr size_t ECCVM_RECURSIVE_VERIFIER_GATE_COUNT = 214950;
156+
inline constexpr size_t ECCVM_RECURSIVE_VERIFIER_GATE_COUNT = 220455;
157157

158158
// ========================================
159159
// Goblin AVM Recursive Verifier Constants

barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ class ECCVMTranscriptTests : public ::testing::Test {
135135
manifest_expected.add_entry(round, "LOOKUP_INVERSES", frs_per_G);
136136
manifest_expected.add_entry(round, "Z_PERM", frs_per_G);
137137
manifest_expected.add_challenge(round, "Sumcheck:alpha");
138-
139138
for (size_t i = 0; i < CONST_ECCVM_LOG_N; i++) {
140-
round++;
141139
std::string label = "Sumcheck:gate_challenge_" + std::to_string(i);
142140
manifest_expected.add_challenge(round, label);
143141
}

barretenberg/cpp/src/barretenberg/goblin/merge.test.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -542,29 +542,25 @@ class MergeTranscriptTests : public ::testing::Test {
542542

543543
size_t round = 0;
544544

545-
// Round 0: Prover sends shift_size and merged table commitments
545+
// Round 0: Prover sends shift_size and merged table commitments, gets degree check challenges
546546
manifest_expected.add_entry(round, "shift_size", frs_per_uint32);
547547
for (size_t idx = 0; idx < NUM_WIRES; ++idx) {
548548
manifest_expected.add_entry(round, "MERGED_TABLE_" + std::to_string(idx), frs_per_G);
549549
}
550-
// Verifier generates degree check challenges
551550
manifest_expected.add_challenge(round, "LEFT_TABLE_DEGREE_CHECK_0");
552551
manifest_expected.add_challenge(round, "LEFT_TABLE_DEGREE_CHECK_1");
553552
manifest_expected.add_challenge(round, "LEFT_TABLE_DEGREE_CHECK_2");
554553
manifest_expected.add_challenge(round, "LEFT_TABLE_DEGREE_CHECK_3");
555554

556-
// Round 1: Verifier generates Shplonk batching challenges, Prover sends degree check polynomial commitment
555+
// Round 1: Batching challenges + kappa, then send batched polynomial commitment
557556
round++;
558557
for (size_t idx = 0; idx < 13; ++idx) {
559558
manifest_expected.add_challenge(round, "SHPLONK_MERGE_BATCHING_CHALLENGE_" + std::to_string(idx));
560559
}
561-
manifest_expected.add_entry(round, "REVERSED_BATCHED_LEFT_TABLES", frs_per_G);
562-
563-
// Round 2: Verifier generates evaluation challenge kappa
564-
round++;
565560
manifest_expected.add_challenge(round, "kappa");
561+
manifest_expected.add_entry(round, "REVERSED_BATCHED_LEFT_TABLES", frs_per_G);
566562

567-
// Round 3: Verifier generates Shplonk opening challenge, Prover sends all evaluations and quotient
563+
// Round 2: Shplonk opening challenge, then send all evaluations and quotient
568564
round++;
569565
manifest_expected.add_challenge(round, "shplonk_opening_challenge");
570566
for (size_t idx = 0; idx < NUM_WIRES; ++idx) {
@@ -579,7 +575,7 @@ class MergeTranscriptTests : public ::testing::Test {
579575
manifest_expected.add_entry(round, "REVERSED_BATCHED_LEFT_TABLES_EVAL", frs_per_Fr);
580576
manifest_expected.add_entry(round, "SHPLONK_BATCHED_QUOTIENT", frs_per_G);
581577

582-
// Round 4: KZG opening proof with masking challenge
578+
// Round 3: KZG masking challenge, then send W commitment
583579
round++;
584580
manifest_expected.add_challenge(round, "KZG:masking_challenge");
585581
manifest_expected.add_entry(round, "KZG:W", frs_per_G);

barretenberg/cpp/src/barretenberg/hypernova/hypernova_decider_verifier.test.cpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,44 +50,47 @@ class HypernovaDeciderVerifierTests : public ::testing::Test {
5050

5151
/**
5252
* @brief Build the expected transcript manifest for HyperNova decider
53-
* @details Manifest tracking is enabled after folding (which uses 50 rounds), so only
54-
* decider rounds are tracked. Round numbers continue from folding:
55-
* - Round 50: rho challenge (batching for Gemini)
56-
* - Round 51: Gemini FOLD commitments -> Gemini:r challenge
57-
* - Round 52: Gemini evaluations -> Shplonk:nu challenge
58-
* - Round 53: Shplonk:Q commitment -> Shplonk:z challenge
59-
* - Round 54: KZG:W commitment -> KZG:masking_challenge
53+
* @details Manifest tracking is enabled after folding (which uses 48 rounds, 0-47), so only
54+
* decider rounds are tracked. Since folding ends with a challenge (claim_batching_challenge)
55+
* at round 47, and the decider starts with a challenge (rho), they are in the same round:
56+
* - Round 47: rho challenge (same round as folding's claim_batching_challenge)
57+
* - Round 48: Gemini FOLD commitments -> Gemini:r challenge
58+
* - Round 49: Gemini evaluations -> Shplonk:nu challenge
59+
* - Round 50: Shplonk:Q commitment -> Shplonk:z challenge
60+
* - Round 51: KZG:W commitment -> KZG:masking_challenge
6061
*/
6162
static TranscriptManifest build_expected_decider_manifest()
6263
{
6364
TranscriptManifest manifest;
6465
constexpr size_t frs_per_G = FrCodec::calc_num_fields<curve::BN254::AffineElement>();
6566
constexpr size_t NUM_GEMINI_FOLDS = NativeFlavor::VIRTUAL_LOG_N - 1; // 20
6667
constexpr size_t NUM_GEMINI_EVALS = NativeFlavor::VIRTUAL_LOG_N; // 21
67-
constexpr size_t FOLDING_ROUNDS = 50; // Rounds used by folding verifier
68+
// Folding uses 48 rounds (0-47). The last round (47) ends with claim_batching_challenge.
69+
// Since rho is also a challenge with no data between, it stays in round 47.
70+
constexpr size_t LAST_FOLDING_ROUND = 47;
6871

69-
// Round 50: rho challenge
70-
manifest.add_challenge(FOLDING_ROUNDS, "rho");
72+
// Round 47: rho challenge (same round as folding's claim_batching_challenge)
73+
manifest.add_challenge(LAST_FOLDING_ROUND, "rho");
7174

72-
// Round 51: Gemini FOLD commitments -> Gemini:r
75+
// Round 48: Gemini FOLD commitments -> Gemini:r
7376
for (size_t i = 1; i <= NUM_GEMINI_FOLDS; ++i) {
74-
manifest.add_entry(FOLDING_ROUNDS + 1, "Gemini:FOLD_" + std::to_string(i), frs_per_G);
77+
manifest.add_entry(LAST_FOLDING_ROUND + 1, "Gemini:FOLD_" + std::to_string(i), frs_per_G);
7578
}
76-
manifest.add_challenge(FOLDING_ROUNDS + 1, "Gemini:r");
79+
manifest.add_challenge(LAST_FOLDING_ROUND + 1, "Gemini:r");
7780

78-
// Round 52: Gemini evaluations -> Shplonk:nu
81+
// Round 49: Gemini evaluations -> Shplonk:nu
7982
for (size_t i = 1; i <= NUM_GEMINI_EVALS; ++i) {
80-
manifest.add_entry(FOLDING_ROUNDS + 2, "Gemini:a_" + std::to_string(i), 1);
83+
manifest.add_entry(LAST_FOLDING_ROUND + 2, "Gemini:a_" + std::to_string(i), 1);
8184
}
82-
manifest.add_challenge(FOLDING_ROUNDS + 2, "Shplonk:nu");
85+
manifest.add_challenge(LAST_FOLDING_ROUND + 2, "Shplonk:nu");
8386

84-
// Round 53: Shplonk:Q -> Shplonk:z
85-
manifest.add_entry(FOLDING_ROUNDS + 3, "Shplonk:Q", frs_per_G);
86-
manifest.add_challenge(FOLDING_ROUNDS + 3, "Shplonk:z");
87+
// Round 50: Shplonk:Q -> Shplonk:z
88+
manifest.add_entry(LAST_FOLDING_ROUND + 3, "Shplonk:Q", frs_per_G);
89+
manifest.add_challenge(LAST_FOLDING_ROUND + 3, "Shplonk:z");
8790

88-
// Round 54: KZG:W -> KZG:masking_challenge
89-
manifest.add_entry(FOLDING_ROUNDS + 4, "KZG:W", frs_per_G);
90-
manifest.add_challenge(FOLDING_ROUNDS + 4, "KZG:masking_challenge");
91+
// Round 51: KZG:W -> KZG:masking_challenge
92+
manifest.add_entry(LAST_FOLDING_ROUND + 4, "KZG:W", frs_per_G);
93+
manifest.add_challenge(LAST_FOLDING_ROUND + 4, "KZG:masking_challenge");
9194

9295
return manifest;
9396
}

barretenberg/cpp/src/barretenberg/hypernova/hypernova_verifier.test.cpp

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -168,77 +168,82 @@ class HypernovaFoldingVerifierTests : public ::testing::Test {
168168
constexpr size_t frs_per_G = FrCodec::calc_num_fields<curve::BN254::AffineElement>();
169169
constexpr size_t NUM_SUMCHECK_UNIVARIATES = NativeFlavor::VIRTUAL_LOG_N; // 21
170170

171-
// Round 0: Oink preamble + wires + ECC ops + databus
172-
manifest.add_entry(0, "vk_hash", 1);
171+
size_t round = 0;
172+
173+
// Round 0: Oink preamble + wires + ECC ops + databus -> eta challenges
174+
manifest.add_challenge(round, std::array{ "eta", "eta_two", "eta_three" });
175+
manifest.add_entry(round, "vk_hash", 1);
173176
for (size_t i = 0; i < 4; ++i) {
174-
manifest.add_entry(0, "public_input_" + std::to_string(i), 1);
177+
manifest.add_entry(round, "public_input_" + std::to_string(i), 1);
175178
}
176179
for (const auto& wire : { "W_L", "W_R", "W_O" }) {
177-
manifest.add_entry(0, wire, frs_per_G);
180+
manifest.add_entry(round, wire, frs_per_G);
178181
}
179182
for (const auto& wire : { "ECC_OP_WIRE_1", "ECC_OP_WIRE_2", "ECC_OP_WIRE_3", "ECC_OP_WIRE_4" }) {
180-
manifest.add_entry(0, wire, frs_per_G);
183+
manifest.add_entry(round, wire, frs_per_G);
181184
}
182185
for (const auto& bus : { "CALLDATA", "SECONDARY_CALLDATA", "RETURN_DATA" }) {
183-
manifest.add_entry(0, bus, frs_per_G);
184-
manifest.add_entry(0, std::string(bus) + "_READ_COUNTS", frs_per_G);
185-
manifest.add_entry(0, std::string(bus) + "_READ_TAGS", frs_per_G);
186+
manifest.add_entry(round, bus, frs_per_G);
187+
manifest.add_entry(round, std::string(bus) + "_READ_COUNTS", frs_per_G);
188+
manifest.add_entry(round, std::string(bus) + "_READ_TAGS", frs_per_G);
186189
}
187-
manifest.add_challenge(0, std::array{ "eta", "eta_two", "eta_three" });
188-
189-
// Round 1: lookup + w_4
190-
manifest.add_entry(1, "LOOKUP_READ_COUNTS", frs_per_G);
191-
manifest.add_entry(1, "LOOKUP_READ_TAGS", frs_per_G);
192-
manifest.add_entry(1, "W_4", frs_per_G);
193-
manifest.add_challenge(1, std::array{ "beta", "gamma" });
194-
195-
// Round 2: inverses + z_perm
196-
manifest.add_entry(2, "LOOKUP_INVERSES", frs_per_G);
197-
manifest.add_entry(2, "CALLDATA_INVERSES", frs_per_G);
198-
manifest.add_entry(2, "SECONDARY_CALLDATA_INVERSES", frs_per_G);
199-
manifest.add_entry(2, "RETURN_DATA_INVERSES", frs_per_G);
200-
manifest.add_entry(2, "Z_PERM", frs_per_G);
201-
manifest.add_challenge(2, "alpha");
202-
203-
// Round 3: gate challenge
204-
manifest.add_challenge(3, "HypernovaFoldingProver:gate_challenge");
205-
206-
// Rounds 4-24: main sumcheck univariates
190+
round++;
191+
192+
// Round 1: lookup + w_4 -> beta, gamma challenges
193+
manifest.add_challenge(round, std::array{ "beta", "gamma" });
194+
manifest.add_entry(round, "LOOKUP_READ_COUNTS", frs_per_G);
195+
manifest.add_entry(round, "LOOKUP_READ_TAGS", frs_per_G);
196+
manifest.add_entry(round, "W_4", frs_per_G);
197+
round++;
198+
199+
// Round 2: inverses + z_perm -> alpha + gate_challenge (consecutive challenges in same round)
200+
manifest.add_challenge(round, "alpha");
201+
manifest.add_challenge(round, "HypernovaFoldingProver:gate_challenge");
202+
manifest.add_entry(round, "LOOKUP_INVERSES", frs_per_G);
203+
manifest.add_entry(round, "CALLDATA_INVERSES", frs_per_G);
204+
manifest.add_entry(round, "SECONDARY_CALLDATA_INVERSES", frs_per_G);
205+
manifest.add_entry(round, "RETURN_DATA_INVERSES", frs_per_G);
206+
manifest.add_entry(round, "Z_PERM", frs_per_G);
207+
round++;
208+
209+
// Rounds 3-23: main sumcheck univariates (21 rounds)
207210
for (size_t i = 0; i < NUM_SUMCHECK_UNIVARIATES; ++i) {
208-
manifest.add_entry(4 + i, "Sumcheck:univariate_" + std::to_string(i), 8);
209-
manifest.add_challenge(4 + i, "Sumcheck:u_" + std::to_string(i));
211+
manifest.add_challenge(round, "Sumcheck:u_" + std::to_string(i));
212+
manifest.add_entry(round, "Sumcheck:univariate_" + std::to_string(i), 8);
213+
round++;
210214
}
211215

212-
// Round 25: evaluations + unshifted batching challenges
213-
manifest.add_entry(25, "Sumcheck:evaluations", 60);
216+
// Round 24: evaluations + all batching challenges (unshifted + shifted in same round)
214217
for (size_t i = 0; i < 55; ++i) {
215-
manifest.add_challenge(25, "unshifted_challenge_" + std::to_string(i));
218+
manifest.add_challenge(round, "unshifted_challenge_" + std::to_string(i));
216219
}
217-
218-
// Round 26: shifted batching challenges
219220
for (size_t i = 0; i < 5; ++i) {
220-
manifest.add_challenge(26, "shifted_challenge_" + std::to_string(i));
221+
manifest.add_challenge(round, "shifted_challenge_" + std::to_string(i));
221222
}
223+
manifest.add_entry(round, "Sumcheck:evaluations", 60);
224+
round++;
222225

223-
// Round 27: MLB accumulator data
224-
manifest.add_entry(27, "non_shifted_accumulator_commitment", frs_per_G);
225-
manifest.add_entry(27, "shifted_accumulator_commitment", frs_per_G);
226+
// Round 25: Sumcheck:alpha + MLB accumulator data (Sumcheck:alpha is consecutive challenge)
227+
manifest.add_challenge(round, "Sumcheck:alpha");
228+
manifest.add_entry(round, "non_shifted_accumulator_commitment", frs_per_G);
229+
manifest.add_entry(round, "shifted_accumulator_commitment", frs_per_G);
226230
for (size_t i = 0; i < NUM_SUMCHECK_UNIVARIATES; ++i) {
227-
manifest.add_entry(27, "accumulator_challenge_" + std::to_string(i), 1);
231+
manifest.add_entry(round, "accumulator_challenge_" + std::to_string(i), 1);
228232
}
229-
manifest.add_entry(27, "accumulator_evaluation_0", 1);
230-
manifest.add_entry(27, "accumulator_evaluation_1", 1);
231-
manifest.add_challenge(27, "Sumcheck:alpha");
233+
manifest.add_entry(round, "accumulator_evaluation_0", 1);
234+
manifest.add_entry(round, "accumulator_evaluation_1", 1);
235+
round++;
232236

233-
// Rounds 28-48: MLB sumcheck univariates
237+
// Rounds 26-46: MLB sumcheck univariates (21 rounds)
234238
for (size_t i = 0; i < NUM_SUMCHECK_UNIVARIATES; ++i) {
235-
manifest.add_entry(28 + i, "Sumcheck:univariate_" + std::to_string(i), 4);
236-
manifest.add_challenge(28 + i, "Sumcheck:u_" + std::to_string(i));
239+
manifest.add_challenge(round, "Sumcheck:u_" + std::to_string(i));
240+
manifest.add_entry(round, "Sumcheck:univariate_" + std::to_string(i), 4);
241+
round++;
237242
}
238243

239-
// Round 49: final evaluations + claim_batching_challenge
240-
manifest.add_entry(49, "Sumcheck:evaluations", 6);
241-
manifest.add_challenge(49, "claim_batching_challenge");
244+
// Round 47: final evaluations + claim_batching_challenge
245+
manifest.add_challenge(round, "claim_batching_challenge");
246+
manifest.add_entry(round, "Sumcheck:evaluations", 6);
242247

243248
return manifest;
244249
}

barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.circuit.failure.test.cpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ class Poseidon2FailureTests : public ::testing::Test {
1919
using SubrelationSeparator = Flavor::SubrelationSeparator;
2020
using RelationParameters = RelationParameters<FF>;
2121

22-
void modify_selector(auto& selector)
23-
{
24-
size_t start_idx = selector.start_index();
25-
size_t end_idx = selector.end_index();
26-
27-
// Flip the first non-zero selector value.
28-
for (size_t idx = start_idx; idx < end_idx; idx++) {
29-
if (selector.at(idx) == 1) {
30-
selector.at(idx) = 0;
31-
break;
32-
}
33-
}
34-
}
35-
3622
void modify_witness(const auto& selector, auto& witness)
3723
{
3824
size_t start_idx = selector.start_index();
@@ -108,7 +94,7 @@ class Poseidon2FailureTests : public ::testing::Test {
10894
virtual_log_n);
10995
auto proof = sumcheck_prover.prove();
11096

111-
auto verifier_transcript = std::make_shared<Transcript>(prover_transcript->export_proof());
97+
auto verifier_transcript = Transcript::verifier_init_empty(prover_transcript);
11298

11399
SubrelationSeparator verifier_subrelation_separator =
114100
verifier_transcript->template get_challenge<FF>("Sumcheck:alpha");
@@ -140,34 +126,6 @@ TEST_F(Poseidon2FailureTests, ValidCircuitVerifies)
140126
prove_and_verify(prover_instance, true);
141127
}
142128

143-
TEST_F(Poseidon2FailureTests, WrongSelectorValues)
144-
{
145-
Builder builder;
146-
147-
// Construct a circuit that hashes a single witness field element.
148-
hash_single_input(builder);
149-
150-
// Convert circuit to polynomials.
151-
auto prover_instance = std::make_shared<ProverInstance_<Flavor>>(builder);
152-
{
153-
// Disable Poseidon2 External selector in the first active row.
154-
// This UNDERCONSTRAINS the circuit, so verification still passes because all remaining constraints are
155-
// satisfied on the valid witness data.
156-
modify_selector(prover_instance->polynomials.q_poseidon2_external);
157-
158-
// Run sumcheck - it should PASS because we only removed a constraint
159-
prove_and_verify(prover_instance, true);
160-
}
161-
{
162-
// Disable Poseidon2 Internal selector in the first active row.
163-
// Again, this underconstrains the circuit, so verification passes.
164-
modify_selector(prover_instance->polynomials.q_poseidon2_internal);
165-
166-
// Run sumcheck - it should PASS because we only removed a constraint
167-
prove_and_verify(prover_instance, true);
168-
}
169-
}
170-
171129
TEST_F(Poseidon2FailureTests, WrongWitnessValues)
172130
{
173131
Builder builder;

0 commit comments

Comments
 (0)