Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
batch_merge.test.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
19
20namespace bb {
21
24
25static constexpr size_t NUM_FRS_COMM = NativeTranscript::Codec::template calc_num_fields<NativeG1>();
26
27template <typename Curve, typename = void> struct BuilderTypeHelper {
28 struct DummyBuilder {};
30};
31
32template <typename Curve> struct BuilderTypeHelper<Curve, std::enable_if_t<Curve::is_stdlib_type>> {
33 using type = typename Curve::Builder;
34};
35
36enum class FaultMode : uint8_t {
37 NONE,
38 WRONG_MERGED_TABLE, // merged table commitment/evals/opening are self-consistent but table is wrong
39 BAD_DEGREE_CHECK_POLY, // degree-check commitment/eval/opening are self-consistent but polynomial is wrong
40 PADDING_NOT_INFINITY, // padded slot sends non-zero shift size and non-zero commitment/eval
41 SHIFT_SIZE_MINUS_ONE, // send k-1 as shift size for a subtable polynomial of size k
42 ZK_TABLE_DEGREE_TOO_HIGH, // zk table has degree above verifier hard-coded ZK shift
43 ZERO_SUBTABLES_CLAIM, // send 0 as number of subtables,
44 TOO_MANY_SUBTABLES, // send a number of subtables above the max that the verifier is configured for
45};
46
47void populate_subtable(const std::shared_ptr<ECCOpQueue>& op_queue, size_t num_ops)
48{
49 for (size_t i = 0; i < num_ops; ++i) {
50 op_queue->add_accumulate(NativeG1::random_element());
51 op_queue->mul_accumulate(NativeG1::random_element(), bb::fr::random_element());
52 op_queue->eq_and_reset();
53 }
54}
55
57{
58 const size_t max_op_queue_ops = 10;
59 auto op_queue = std::make_shared<ECCOpQueue>();
60 for (size_t i = 0; i < n; ++i) {
61 if (i > 0) {
62 op_queue->initialize_new_subtable();
63 }
64 populate_subtable(op_queue, ((1 + i) % max_op_queue_ops) + 1); // +1 to avoid empty subtables
65 op_queue->merge();
66 }
67 return op_queue;
68}
69
75bb::fr compute_running_hash(const std::vector<bb::fr>& proof, size_t N)
76{
77 std::vector<bb::fr> round_inputs;
78 bb::fr previous_challenge(0);
79 bool is_first_challenge = true;
80
81 for (size_t subtable_idx = 0; subtable_idx < N; ++subtable_idx) {
82 round_inputs.clear();
83 if (!is_first_challenge) {
84 round_inputs.push_back(previous_challenge);
85 }
86 for (size_t col = 0; col < NUM_WIRES; ++col) {
87 const size_t global_col_idx = (subtable_idx * NUM_WIRES) + col;
88 const size_t base = (global_col_idx * NUM_FRS_COMM);
89 for (size_t j = 0; j < NUM_FRS_COMM; ++j) {
90 round_inputs.push_back(proof[base + j]);
91 }
92 }
93
94 // Transcript logic: hash full round buffer, then split into two challenge parts; get_challenge uses part[0].
96 previous_challenge = full_hash;
97 is_first_challenge = false;
98 }
99
100 return previous_challenge;
101}
102
114
115 public:
122
124 {
125 const size_t M = max_subtables;
126
127 // Step 1
128 std::vector<std::array<Polynomial, NUM_WIRES>> subtable_cols = op_queue->construct_subtable_columns();
129
130 size_t N = subtable_cols.size();
131
132 std::vector<size_t> shift_sizes(N);
133 size_t max_shift_size = 0;
134 for (size_t i = 0; i < N; ++i) {
135 shift_sizes[i] = subtable_cols[i][0].size();
136 max_shift_size = std::max(max_shift_size, shift_sizes[i]);
137 }
138
139 // Step 2: commit subtable columns
140 Polynomial zero_poly(0);
141 for (size_t idx = 0; idx < N; ++idx) {
142 for (size_t col = 0; col < NUM_WIRES; ++col) {
143 const Polynomial& col_to_commit =
144 (fault_mode == FaultMode::ZERO_SUBTABLES_CLAIM) ? zero_poly : subtable_cols[idx][col];
145 transcript->send_to_verifier("COLUMN_" + std::to_string(col) + "_" + std::to_string(idx),
146 pcs_commitment_key.commit(col_to_commit));
147 }
148 [[maybe_unused]] FF _ = transcript->template get_challenge<FF>("HASH_" + std::to_string(idx));
149 }
150
151 Polynomial one_poly(1);
152 one_poly.at(0) = 1;
153 for (size_t idx = N; idx < M; ++idx) {
154 for (size_t col = 0; col < NUM_WIRES; ++col) {
155 const bool non_infinity_padding =
156 (fault_mode == FaultMode::PADDING_NOT_INFINITY && idx == N && col == 0);
157 transcript->send_to_verifier("COLUMN_" + std::to_string(col) + "_" + std::to_string(idx),
158 pcs_commitment_key.commit(non_infinity_padding ? one_poly : zero_poly));
159 }
160 [[maybe_unused]] FF _ = transcript->template get_challenge<FF>("HASH_" + std::to_string(idx));
161 }
162
163 // Step 2.b: Send the masking table
164 std::array<Polynomial, NUM_WIRES> zk_columns = op_queue->construct_zk_columns();
165
167 for (size_t col = 0; col < NUM_WIRES; ++col) {
168 // Make zk column degree exceed verifier's hard-coded ZK shift (= ZK_ULTRA_OPS).
169 Polynomial larger_zk_col(zk_columns[col], zk_columns[col].size() + 1);
170 larger_zk_col.at(larger_zk_col.size() - 1) = FF(1);
171 zk_columns[col] = std::move(larger_zk_col);
172 }
173 }
174
175 for (size_t col = 0; col < NUM_WIRES; ++col) {
176 transcript->send_to_verifier("ZK_COLUMN_" + std::to_string(col),
177 pcs_commitment_key.commit(zk_columns[col]));
178 }
179 max_shift_size = std::max(max_shift_size, zk_columns[0].size());
180
181 // Step 2.c: Flatten the columns for easier utilisation
182 std::vector<Polynomial> flattened_cols;
183 flattened_cols.reserve((subtable_cols.size() * NUM_WIRES) + NUM_WIRES);
184 for (size_t col = 0; col < NUM_WIRES; ++col) {
185 flattened_cols.push_back(std::move(zk_columns[col]));
186 }
187 for (auto& subtable_col : subtable_cols) {
188 for (size_t col = 0; col < NUM_WIRES; ++col) {
190 flattened_cols.push_back(Polynomial(1));
191 } else {
192 flattened_cols.push_back(std::move(subtable_col[col]));
193 }
194 }
195 }
196
197 // Step 3
198 uint32_t sent_num_subtables = static_cast<uint32_t>(N);
200 sent_num_subtables = 0;
201 }
202 transcript->send_to_verifier("NUM_SUBTABLES", sent_num_subtables);
203 for (size_t i = 0; i < M; ++i) {
204 uint32_t sent_shift_size = static_cast<uint32_t>(i < N ? shift_sizes[i] : 0);
205 if (fault_mode == FaultMode::PADDING_NOT_INFINITY && i == N && N < M) {
206 sent_shift_size = 1;
207 }
208 if (fault_mode == FaultMode::SHIFT_SIZE_MINUS_ONE && i == 0 && N > 0) {
209 BB_ASSERT_GT(shift_sizes[0], 0U);
210 sent_shift_size = static_cast<uint32_t>(shift_sizes[0] - 1);
211 }
212 if (fault_mode == FaultMode::ZERO_SUBTABLES_CLAIM && i == N && N < M) {
213 sent_shift_size = 0;
214 }
215 transcript->send_to_verifier("SHIFT_SIZE_" + std::to_string(i), sent_shift_size);
216 }
217
218 // Step 4: merged table
219 std::array<Polynomial, NUM_WIRES> merged_table(op_queue->construct_ultra_ops_table_columns());
220 if (fault_mode == FaultMode::WRONG_MERGED_TABLE && !merged_table[0].is_empty()) {
221 merged_table[0].at(0) += FF(1);
223 for (size_t col = 0; col < NUM_WIRES; ++col) {
224 merged_table[col] = Polynomial(1);
225 }
226 }
227 for (size_t col = 0; col < NUM_WIRES; ++col) {
228 transcript->send_to_verifier("MERGED_COLUMN_" + std::to_string(col),
229 pcs_commitment_key.commit(merged_table[col]));
230 }
231
232 // Step 5
233 const FF degree_check_challenge = transcript->template get_challenge<FF>("DEGREE_CHECK_CHALLENGE");
234 const size_t num_degree_check_challenges = (M * NUM_WIRES) + NUM_WIRES;
235 std::vector<FF> degree_check_challenges = { FF(1), degree_check_challenge };
236 for (size_t idx = 2; idx < num_degree_check_challenges; ++idx) {
237 degree_check_challenges.push_back(degree_check_challenges.back() * degree_check_challenge);
238 }
239
240 // Step 6: degree-check poly
242 // This is the case in which we test that if the prover sends more columns than the max number of tables
243 // then the verifier rejects
244 size_t diff = flattened_cols.size() - num_degree_check_challenges;
245 for (size_t idx = 0; idx < diff * NUM_WIRES; ++idx) {
246 // Add challenges for the extra columns sent by the prover
247 degree_check_challenges.push_back(degree_check_challenges.back() * degree_check_challenge);
248 }
249 }
250
251 Polynomial degree_check_poly =
252 compute_degree_check_polynomial(flattened_cols, degree_check_challenges, max_shift_size);
253
255 // Remove the extra challenge added above to keep the degree check poly consistent with the rest of the
256 // proof
257 degree_check_challenges.pop_back();
258 }
259
260 if (fault_mode == FaultMode::BAD_DEGREE_CHECK_POLY && !degree_check_poly.is_empty()) {
261 degree_check_poly.at(0) += FF(1);
262 }
263
264 transcript->send_to_verifier("DEGREE_CHECK_POLY", pcs_commitment_key.commit(degree_check_poly));
265
266 // Step 7
267 const FF kappa = transcript->template get_challenge<FF>("KAPPA");
268 const FF kappa_inv = kappa.invert();
269
270 // Step 8: evals
271 std::vector<FF> evals;
272 const size_t num_actual_flattened_cols = (N * NUM_WIRES) + NUM_WIRES;
273 const size_t num_flattened_col_evals = (M * NUM_WIRES) + NUM_WIRES;
274 for (size_t flat_idx = 0; flat_idx < num_flattened_col_evals; ++flat_idx) {
275 FF eval = FF(0);
276 if (flat_idx < num_actual_flattened_cols) {
277 eval = flattened_cols[flat_idx].evaluate(kappa);
278 } else if (fault_mode == FaultMode::PADDING_NOT_INFINITY && flat_idx == num_actual_flattened_cols) {
279 eval = FF(1); // matches one_poly commitment at the first padded slot
280 }
281 evals.push_back(eval);
282 transcript->send_to_verifier("C_EVAL_" + std::to_string(flat_idx), eval);
283 }
284
285 for (size_t col = 0; col < NUM_WIRES; ++col) {
286 evals.push_back(merged_table[col].evaluate(kappa));
287 transcript->send_to_verifier("MERGED_EVAL_" + std::to_string(col), evals.back());
288 }
289
290 evals.push_back(degree_check_poly.evaluate(kappa_inv));
291 transcript->send_to_verifier("DEGREE_CHECK_EVAL", evals.back());
292
293 // Step 9
294 const size_t num_opening_claims = ((M + 1) * NUM_WIRES) + 1 + NUM_WIRES;
295 std::vector<OpeningClaim> opening_claims;
296 opening_claims.reserve(num_opening_claims);
297
298 for (size_t idx = 0; idx < num_flattened_col_evals; ++idx) {
299 if (idx < num_actual_flattened_cols) {
300 opening_claims.push_back({ std::move(flattened_cols[idx]), { kappa, evals[idx] } });
301 } else {
302 opening_claims.push_back({ Polynomial(1), { kappa, FF(0) } });
303 }
304 }
305
306 for (size_t idx = 0; idx < NUM_WIRES; ++idx) {
307 opening_claims.push_back(
308 { std::move(merged_table[idx]), { kappa, evals[(M * NUM_WIRES) + NUM_WIRES + idx] } });
309 }
310
311 opening_claims.push_back({ std::move(degree_check_poly), { kappa_inv, evals.back() } });
312
313 auto shplonk_opening_claim = ShplonkProver::prove(pcs_commitment_key, opening_claims, transcript);
314
316 return transcript->export_proof();
317 }
318
319 private:
321};
322
323// Custom parameter struct to hold both Curve type and NumSubtables value
324template <typename Curve, size_t N> struct TestParam {
326 static constexpr size_t NumSubtables = N;
327};
328
329// Specialize the fixture to extract both template parameters from TypeParam
330template <typename Param> class BatchMergeTests : public testing::Test {
331 public:
332 using Curve = typename Param::CurveType;
333 static constexpr size_t NumSubtables = Param::NumSubtables;
334 using FF = typename Curve::ScalarField;
336 using Proof = typename Verifier::Proof;
338 static constexpr bool IsRecursive = Curve::is_stdlib_type;
340
341 static constexpr size_t VERIFIER_NUM_GATES = NumSubtables == 9 ? 3035 : 19085;
342 static constexpr size_t ZK_OFFSET = NumSubtables == 9 ? 666 : 520;
343
349
351
352 static Proof create_proof(BuilderType& builder, const std::vector<bb::fr>& native_proof)
353 {
354 if constexpr (IsRecursive) {
355 stdlib::Proof<BuilderType> stdlib_proof(builder, native_proof);
356 return stdlib_proof;
357 } else {
358 (void)builder;
359 return native_proof;
360 }
361 }
362
363 static FF create_hash(BuilderType& builder, const bb::fr& native_hash)
364 {
365 if constexpr (IsRecursive) {
366 auto hash = FF::from_witness(&builder, native_hash);
367 hash.unset_free_witness_tag();
368 return hash;
369 } else {
370 (void)builder;
371 return native_hash;
372 }
373 }
374
376 {
377 if constexpr (IsRecursive) {
379 } else {
380 (void)builder;
381 return true;
382 }
383 }
384
386 FaultMode fault_mode = FaultMode::NONE,
387 bool wrong_hash = false,
388 bool check_manifest = false)
389 {
390 TranscriptManifest prover_manifest;
391 std::vector<bb::fr> native_proof;
392 if (fault_mode == FaultMode::NONE) {
393 BatchMergeProver prover{ op_queue, NumSubtables };
394 if (check_manifest) {
395 prover.transcript->enable_manifest();
396 }
397
398 native_proof = prover.construct_proof();
399 if (check_manifest) {
400 prover_manifest = prover.transcript->get_manifest();
401 }
402 } else {
403 TweakableBatchMergeProver prover{ op_queue, NumSubtables, fault_mode };
404 if (check_manifest) {
405 prover.transcript->enable_manifest();
406 }
407
408 native_proof = prover.construct_proof();
409 if (check_manifest) {
410 prover_manifest = prover.transcript->get_manifest();
411 }
412 }
413
414 bb::fr native_hash = compute_running_hash(native_proof, op_queue->num_subtables());
415 if (wrong_hash) {
416 native_hash += bb::fr(1);
417 }
418
420 Proof proof = create_proof(builder, native_proof);
421 FF hash = create_hash(builder, native_hash);
422
423 Verifier verifier;
424 if (check_manifest) {
425 verifier.transcript->enable_manifest();
426 }
427 auto result = verifier.reduce_to_pairing_check(proof, hash);
428
429 if (check_manifest) {
430 // Check consistency of manifests
431 auto verifier_manifest = verifier.transcript->get_manifest();
432 EXPECT_EQ(prover_manifest.size(), verifier_manifest.size());
433 for (size_t i = 0; i < prover_manifest.size(); ++i) {
434 EXPECT_EQ(prover_manifest[i], verifier_manifest[i]);
435 }
436 }
437
438 if constexpr (Curve::is_stdlib_type) {
439 EXPECT_EQ(builder.get_num_finalized_gates_inefficient(), VERIFIER_NUM_GATES + ZK_OFFSET);
440 }
441
442 return { result.reduction_succeeded, result.pairing_points.check(), check_circuit(builder) };
443 }
444};
445
446using TestParams = ::testing::Types<TestParam<curve::BN254, 9>,
449 TestParam<stdlib::bn254<MegaCircuitBuilder>, CHONK_MAX_NUM_CIRCUITS>>;
451
452// Completeness
453
454TYPED_TEST(BatchMergeTests, ValidProofPassesWithPadding)
455{
456 auto op_queue = make_op_queue_with_n_subtables(3);
457 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::NONE, false, /*check_manifest*/ true);
458 EXPECT_TRUE(res.reduction_ok);
459 EXPECT_TRUE(res.pairing_ok);
460 EXPECT_TRUE(res.circuit_ok);
461}
462
463TYPED_TEST(BatchMergeTests, ValidProofMaxSizePasses)
464{
465 auto op_queue = make_op_queue_with_n_subtables(TestFixture::NumSubtables);
466 auto res = TestFixture::prove_and_verify(op_queue);
467 EXPECT_TRUE(res.reduction_ok);
468 EXPECT_TRUE(res.pairing_ok);
469 EXPECT_TRUE(res.circuit_ok);
470}
471
472// Soundness
473
474TYPED_TEST(BatchMergeTests, ZeroSubtablesFails)
475{
477 auto op_queue = make_op_queue_with_n_subtables(3);
478 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::ZERO_SUBTABLES_CLAIM);
479 EXPECT_FALSE(res.reduction_ok); // Caught by product check
480 EXPECT_TRUE(res.pairing_ok);
481 if constexpr (TestFixture::IsRecursive) {
482 EXPECT_FALSE(res.circuit_ok);
483 }
484}
485
486TYPED_TEST(BatchMergeTests, TooManySubtablesFails)
487{
488 if constexpr (!TestFixture::Curve::is_stdlib_type) {
489 GTEST_SKIP() << "This test in native setting fails due to a deserialization failure. The verifier path in the "
490 "same for native and recursive code, so it's enough to test the recursive code.";
491 } else {
493 auto op_queue = make_op_queue_with_n_subtables(TestFixture::NumSubtables + 1);
494 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::TOO_MANY_SUBTABLES);
495 EXPECT_FALSE(res.reduction_ok); // Caught by product check
496 EXPECT_FALSE(res.pairing_ok); // Verifier uses fewer commitments than the one sent
497 if constexpr (TestFixture::IsRecursive) {
498 EXPECT_FALSE(res.circuit_ok); // Assertions fail
499 }
500 }
501}
502
503TYPED_TEST(BatchMergeTests, WrongMergedTableFails)
504{
505 auto op_queue = make_op_queue_with_n_subtables(2);
506 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::WRONG_MERGED_TABLE);
507 EXPECT_FALSE(res.reduction_ok); // Caught by the concatenation check
508 EXPECT_TRUE(res.pairing_ok);
509 if constexpr (TestFixture::IsRecursive) {
510 EXPECT_FALSE(res.circuit_ok);
511 }
512}
513
515{
516 auto op_queue = make_op_queue_with_n_subtables(4);
517 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::NONE, true);
518 EXPECT_FALSE(res.reduction_ok); // Caught by the hash check
519 EXPECT_TRUE(res.pairing_ok);
520 if constexpr (TestFixture::IsRecursive) {
521 EXPECT_FALSE(res.circuit_ok);
522 }
523}
524
525TYPED_TEST(BatchMergeTests, BadSubtableDegreeCheckFails)
526{
527 auto op_queue = make_op_queue_with_n_subtables(6);
528 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::BAD_DEGREE_CHECK_POLY);
529 EXPECT_FALSE(res.reduction_ok); // Caught by the degree check
530 EXPECT_TRUE(res.pairing_ok);
531 if constexpr (TestFixture::IsRecursive) {
532 EXPECT_FALSE(res.circuit_ok);
533 }
534}
535
536TYPED_TEST(BatchMergeTests, PaddingTableNotInfinityFails)
537{
538 auto op_queue = make_op_queue_with_n_subtables(3);
539 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::PADDING_NOT_INFINITY);
540 EXPECT_FALSE(res.reduction_ok); // Caught by the degree check: shift sizes are zeroed out >= N
541 EXPECT_TRUE(res.pairing_ok); // PCS is consistent
542 if constexpr (TestFixture::IsRecursive) {
543 EXPECT_FALSE(res.circuit_ok); // Caught by the degree check: shift sizes are zeroed out >= N
544 }
545}
546
547TYPED_TEST(BatchMergeTests, ShiftSizeMinusOneFailsReductionOnly)
548{
549 auto op_queue = make_op_queue_with_n_subtables(7);
550 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::SHIFT_SIZE_MINUS_ONE);
551 EXPECT_FALSE(res.reduction_ok); // Caught by the degree check
552 EXPECT_TRUE(res.pairing_ok);
553 if constexpr (TestFixture::IsRecursive) {
554 EXPECT_FALSE(res.circuit_ok);
555 }
556}
557
558TYPED_TEST(BatchMergeTests, ZKTableDegreeTooHighFailsReductionOnly)
559{
560 auto op_queue = make_op_queue_with_n_subtables(5);
561 auto res = TestFixture::prove_and_verify(op_queue, FaultMode::ZK_TABLE_DEGREE_TOO_HIGH);
562 EXPECT_FALSE(res.reduction_ok); // Caught by degree/concatenation reductions via hard-coded ZK shift.
563 EXPECT_TRUE(res.pairing_ok); // PCS opening remains self-consistent with sent commitments/evals.
564 if constexpr (TestFixture::IsRecursive) {
565 EXPECT_FALSE(res.circuit_ok);
566 }
567}
568
569// Static analysis of the recursive verifier circuit: every variable must belong to a single connected
570// component (no disjoint subgraphs) and there must be no variables that participate in only one gate
571// (i.e. no unconstrained witnesses).
572TYPED_TEST(BatchMergeTests, GraphDescription)
573{
574 if constexpr (!TestFixture::IsRecursive) {
575 GTEST_SKIP() << "Graph description analysis only applies to stdlib (recursive) verifier circuits.";
576 } else {
577 using BuilderType = typename TestFixture::BuilderType;
578 using FF = typename TestFixture::FF;
579 using Proof = typename TestFixture::Proof;
580 using Verifier = typename TestFixture::Verifier;
581
582 auto op_queue = make_op_queue_with_n_subtables(5);
583 BatchMergeProver prover{ op_queue, TestFixture::NumSubtables };
584 auto native_proof = prover.construct_proof();
585 const bb::fr native_hash = compute_running_hash(native_proof, op_queue->num_subtables());
586
587 BuilderType builder;
588 Proof proof = TestFixture::create_proof(builder, native_proof);
589 FF hash = TestFixture::create_hash(builder, native_hash);
590 // The hash is a public input to the recursive batch-merge verifier. Pin it so the StaticAnalyzer doesn't flag
591 // it as unconstrained when graph-description tests analyze the verifier circuit in isolation.
592 hash.fix_witness();
593
594 Verifier verifier;
595 auto result = verifier.reduce_to_pairing_check(proof, hash);
596
597 // The pairing points are public outputs from the recursive verifier that will be verified externally via a
598 // pairing check. Their output coordinates may not appear in multiple constraint gates; fix_witness() pins
599 // them so the StaticAnalyzer doesn't flag the coordinate limbs as unconstrained.
600 result.pairing_points.fix_witness();
601
602 builder.finalize_circuit();
603
604 using Analyzer =
606 auto graph = Analyzer(builder);
607 auto [cc, variables_in_one_gate] = graph.analyze_circuit(/*filter_cc=*/true);
608
609 EXPECT_EQ(cc.size(), 1);
610 EXPECT_EQ(variables_in_one_gate.size(), 0);
611 }
612}
613
614} // namespace bb
constexpr size_t N
#define BB_ASSERT_GT(left, right,...)
Definition assert.hpp:113
#define BB_DISABLE_ASSERTS()
Definition assert.hpp:33
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
Batch merge prover.
static constexpr size_t NUM_WIRES
std::shared_ptr< Transcript > transcript
std::shared_ptr< ECCOpQueue > op_queue
std::vector< FF > MergeProof
MergeProof construct_proof()
Construct the batch merge proof.
static Polynomial compute_degree_check_polynomial(const std::vector< Polynomial > &flattened_columns, const std::vector< FF > &degree_check_challenges, const size_t max_size)
static constexpr size_t ZK_OFFSET
typename Verifier::Transcript Transcript
typename Param::CurveType Curve
static Proof create_proof(BuilderType &builder, const std::vector< bb::fr > &native_proof)
static constexpr bool IsRecursive
static constexpr size_t NumSubtables
typename Verifier::Proof Proof
static bool check_circuit(BuilderType &builder)
static FF create_hash(BuilderType &builder, const bb::fr &native_hash)
typename BuilderTypeHelper< Curve >::type BuilderType
static constexpr size_t VERIFIER_NUM_GATES
static VerifyResult prove_and_verify(const std::shared_ptr< ECCOpQueue > &op_queue, FaultMode fault_mode=FaultMode::NONE, bool wrong_hash=false, bool check_manifest=false)
typename Curve::ScalarField FF
Unified batch verifier for the batch Goblin ECC op queue merge protocol.
std::shared_ptr< Transcript > transcript
ReductionResult reduce_to_pairing_check(const Proof &proof, const FF hash)
Reduce the batch merge proof to a pairing check.
TranscriptFor_t< Curve > Transcript
Commitment commit(PolynomialSpan< const Fr > polynomial, bool has_duplicates_hint=false) const
Uses the ProverSRS to create a commitment to p(X)
static void compute_opening_proof(const CK &ck, const ProverOpeningClaim< Curve > &opening_claim, const std::shared_ptr< Transcript > &prover_trancript)
Computes the KZG commitment to an opening proof polynomial at a single evaluation point.
Definition kzg.hpp:44
bool is_empty() const
Fr evaluate(const Fr &z) const
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
std::size_t size() const
Polynomial p and an opening pair (r,v) such that p(r) = v.
Definition claim.hpp:36
static ProverOpeningClaim< Curve > prove(const CommitmentKey< Curve > &commitment_key, std::span< ProverOpeningClaim< Curve > > opening_claims, const std::shared_ptr< Transcript > &transcript, std::span< ProverOpeningClaim< Curve > > libra_opening_claims={}, std::span< ProverOpeningClaim< Curve > > sumcheck_round_claims={}, const size_t virtual_log_n=0)
Definition shplonk.hpp:307
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
TweakableBatchMergeProver(const std::shared_ptr< ECCOpQueue > &op_queue, size_t max_subtables, FaultMode mode=FaultMode::NONE)
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
typename Group::affine_element AffineElement
Definition bn254.hpp:22
bb::fr ScalarField
Definition bn254.hpp:18
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:67
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:20
AluTraceBuilder builder
Definition alu.test.cpp:124
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
@ ZK_TABLE_DEGREE_TOO_HIGH
TYPED_TEST_SUITE(CommitmentKeyTest, Curves)
field< Bn254FrParams > fr
Definition fr.hpp:155
bb::fr compute_running_hash(const std::vector< bb::fr > &proof, size_t N)
void populate_subtable(const std::shared_ptr< ECCOpQueue > &op_queue, size_t num_ops)
TYPED_TEST(CommitmentKeyTest, CommitToZeroPoly)
curve::Grumpkin Curve
NativeCurve::AffineElement NativeG1
std::shared_ptr< ECCOpQueue > make_op_queue_with_n_subtables(size_t n)
::testing::Types< TestParam< curve::BN254, 9 >, TestParam< curve::BN254, CHONK_MAX_NUM_CIRCUITS >, TestParam< stdlib::bn254< MegaCircuitBuilder >, 9 >, TestParam< stdlib::bn254< MegaCircuitBuilder >, CHONK_MAX_NUM_CIRCUITS > > TestParams
BaseTranscript< FrCodec, bb::crypto::Poseidon2< bb::crypto::Poseidon2Bn254ScalarFieldParams > > NativeTranscript
StaticAnalyzer_< bb::fr, bb::MegaCircuitBuilder > MegaStaticAnalyzer
Definition graph.hpp:189
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
static constexpr size_t NumSubtables
constexpr field invert() const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
VectorField result