Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
chonk.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Sergei], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
22
23namespace bb {
24
25// Constructor
26Chonk::Chonk(size_t num_circuits)
27 : num_circuits(num_circuits)
28{
29 BB_ASSERT_GTE(num_circuits, 4UL, "Number of circuits must be at least 4 (get_queue_type uses num_circuits - 3).");
30}
31
43 const std::vector<std::shared_ptr<RecursiveVKAndHash>>& input_keys)
44{
45 bool vkeys_provided = !input_keys.empty();
46 if (vkeys_provided) {
48 input_keys.size(),
49 "Incorrect number of verification keys provided in "
50 "stdlib verification queue instantiation.");
51 }
52
53 size_t key_idx = 0;
54 while (!verification_queue.empty()) {
55 const VerifierInputs& entry = verification_queue.front();
56
57 // Construct stdlib proof directly from the internal native queue data
58 StdlibProof stdlib_proof(circuit, entry.proof);
59
60 // Use the provided stdlib vkey if present, otherwise construct one from the internal native queue
61 std::shared_ptr<RecursiveVKAndHash> stdlib_vk_and_hash;
62 if (vkeys_provided) {
63 stdlib_vk_and_hash = input_keys[key_idx++];
64 } else {
65 stdlib_vk_and_hash = std::make_shared<RecursiveVKAndHash>(circuit, entry.honk_vk);
66 }
67
68 stdlib_verification_queue.emplace_back(stdlib_proof, stdlib_vk_and_hash, entry.type, entry.is_kernel);
69
70 verification_queue.pop_front(); // the native data is not needed beyond this point
71 }
72}
73
87 ClientCircuit& circuit,
88 const StdlibVerifierInputs& verifier_inputs,
89 const std::shared_ptr<RecursiveVerifierInstance>& verifier_instance,
90 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript) const
91{
92 std::vector<PairingPoints> pairing_points;
94
95 RecursiveFoldingVerifier folding_verifier(accumulation_recursive_transcript);
96 switch (verifier_inputs.type) {
97 case QUEUE_TYPE::OINK: {
98 vinfo("Recursively verifying accumulation of the first app circuit.");
99 auto [_, new_verifier_accumulator] =
100 folding_verifier.instance_to_accumulator(verifier_instance, verifier_inputs.proof);
101 output_accumulator = std::move(new_verifier_accumulator);
102 break;
103 }
104 case QUEUE_TYPE::HN:
105 case QUEUE_TYPE::HN_TAIL: {
106 vinfo("Recursively verifying inner accumulation.");
107 auto [_first_verified, _second_verified, new_verifier_accumulator] =
108 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
109 output_accumulator = std::move(new_verifier_accumulator);
110 break;
111 }
113 vinfo("Recursively verifying accumulation of the tail kernel.");
114 BB_ASSERT_EQ(stdlib_verification_queue.size(), size_t(1));
115
116 auto [_first_verified, _second_verified, final_verifier_accumulator] =
117 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
118
119 RecursiveDeciderVerifier decider_verifier(accumulation_recursive_transcript);
120 StdlibProof stdlib_decider_proof(circuit, decider_proof);
121 pairing_points.emplace_back(decider_verifier.verify_proof(final_verifier_accumulator, stdlib_decider_proof));
122 break;
123 }
124 default: {
125 throw_or_abort("Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
126 }
127 }
128
129 return { std::move(output_accumulator), std::move(pairing_points) };
130}
131
147 const StdlibVerifierInputs& verifier_inputs,
148 std::vector<StdlibFF>& public_inputs,
149 WitnessCommitments& witness_commitments,
150 const std::optional<StdlibFF>& prev_accum_hash)
151{
152 if (verifier_inputs.is_kernel) {
153 BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::HN || verifier_inputs.type == QUEUE_TYPE::HN_TAIL ||
154 verifier_inputs.type == QUEUE_TYPE::HN_FINAL,
155 true,
156 "Kernel circuits should be folded.");
157
158 // ============= Reconstruct the public inputs of the previous kernel =============
159
160 KernelIO kernel_input; // pairing points, ecc op tables, databus commitments
161 kernel_input.reconstruct_from_public(public_inputs);
162
163 // ============= Perform databus consistency checks ===============================
164
165 // Kernel return data
166 bool kernel_return_data_match =
167 kernel_input.kernel_return_data.get_value() == witness_commitments.calldata.get_value();
168 BB_ASSERT_DEBUG(kernel_return_data_match,
169 "kernel_return_data mismatch: proof contains " << kernel_input.kernel_return_data.get_value()
170 << " but calldata commitment is "
171 << witness_commitments.calldata.get_value());
172 kernel_input.kernel_return_data.incomplete_assert_equal(witness_commitments.calldata);
173
174 // App return data
175 bool app_return_data_match =
176 kernel_input.app_return_data.get_value() == witness_commitments.secondary_calldata.get_value();
177 BB_ASSERT_DEBUG(app_return_data_match,
178 "app_return_data mismatch: proof contains "
179 << kernel_input.app_return_data.get_value() << " but secondary_calldata commitment is "
180 << witness_commitments.secondary_calldata.get_value());
181 kernel_input.app_return_data.incomplete_assert_equal(witness_commitments.secondary_calldata);
182
183 // ============= Perform accumulator hash consistency check =========================
184
185 info("Accumulator hash from IO: ", kernel_input.output_hn_accum_hash);
186 BB_ASSERT(prev_accum_hash.has_value());
187 bool accum_hash_match = kernel_input.output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
188 BB_ASSERT_DEBUG(accum_hash_match,
189 "output_hn_accum_hash mismatch: proof contains "
190 << kernel_input.output_hn_accum_hash.get_value() << " but expected "
191 << prev_accum_hash->get_value());
192 kernel_input.output_hn_accum_hash.assert_equal(*prev_accum_hash);
193
194 // ============= Set the kernel return data commitment ==============================
195
196 bus_depot.set_kernel_return_data_commitment(witness_commitments.return_data);
197
198 return { std::move(kernel_input.pairing_inputs), std::move(kernel_input.ecc_op_hash) };
199 }
200
201 // App circuit path
202 AppIO app_input; // pairing points
203 app_input.reconstruct_from_public(public_inputs);
204
205 // Set the app return data commitment to be propagated via the public inputs
206 bus_depot.set_app_return_data_commitment(witness_commitments.return_data);
207
208 return { std::move(app_input.pairing_inputs), std::nullopt };
209}
210
226 ClientCircuit& circuit,
227 const StdlibVerifierInputs& verifier_inputs,
228 const std::optional<RecursiveVerifierAccumulator>& input_verifier_accumulator,
229 const std::optional<StdlibFF>& running_hash,
230 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript)
231{
232 BB_BENCH_NAME("Chonk::recursive_verification_and_consistency_checks");
233
234 auto verifier_instance = std::make_shared<RecursiveVerifierInstance>(verifier_inputs.honk_vk_and_hash);
235
236 // Compute prev_accum_hash before folding (transcript state changes during verification)
237 std::optional<StdlibFF> prev_accum_hash;
238 if (verifier_inputs.is_kernel) {
239 BB_ASSERT(input_verifier_accumulator.has_value(), "Previous accumulator expected for kernel circuit folding");
240 prev_accum_hash = input_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
241 }
242
243 // Step 1: Recursive folding verification
244 if (verifier_inputs.type == QUEUE_TYPE::OINK) {
245 BB_ASSERT_EQ(input_verifier_accumulator.has_value(), false);
246 }
247 auto [output_accumulator, folding_points] =
248 verify_folding(circuit, verifier_inputs, verifier_instance, accumulation_recursive_transcript);
249
250 // Extract the witness commitments and public inputs from the verified instance
251 WitnessCommitments witness_commitments = std::move(verifier_instance->witness_commitments);
252 std::vector<StdlibFF> public_inputs = std::move(verifier_instance->public_inputs);
253
254 // Step 2: Process public inputs and perform databus consistency checks
255 auto [io_pairing_points, previous_ecc_op_hash] = process_public_inputs_and_consistency_checks(
256 verifier_inputs, public_inputs, witness_commitments, prev_accum_hash);
257
258 std::optional<StdlibFF> updated_hash = running_hash;
259 if (previous_ecc_op_hash.has_value()) {
260 BB_ASSERT_EQ(verifier_inputs.is_kernel, true, "previous_ecc_op_hash should only be set for kernels");
261 BB_ASSERT(!running_hash.has_value(), "Running hash should not be set when recursively verifying a kernel");
262 updated_hash = previous_ecc_op_hash.value();
263 }
264
265 // Step 3: Update the running ECC op hash with this circuit's ECC op column commitments.
266 auto ecc_op_col_commitments = witness_commitments.get_ecc_op_wires().get_copy();
267 const std::vector<RecursiveCommitment> ecc_op_col_commitments_vec(ecc_op_col_commitments.begin(),
268 ecc_op_col_commitments.end());
269 updated_hash = Goblin::BatchMergeRecursiveVerifier::ecc_op_hash_step(ecc_op_col_commitments_vec, updated_hash);
270
271 // Combine all pairing points
273 all_points.insert(all_points.end(), folding_points.begin(), folding_points.end());
274 all_points.emplace_back(std::move(io_pairing_points));
275
276 return { std::move(output_accumulator), std::move(all_points), updated_hash.value() };
277}
278
293{
294 BB_BENCH_NAME("Chonk::complete_kernel_circuit_logic");
295 // Step 1: SETUP - Initialize state and determine kernel type
296
297 // Transcript is shared across recursive verification of the folding of K_{i-1} (kernel) and A_{i} (app)
298 auto accumulation_recursive_transcript = std::make_shared<RecursiveTranscript>();
299
300 // Running Poseidon2 hash over ECC op column commitments, propagated through kernel public inputs.
302
303 // Convert native verification queue to circuit witnesses
304 if (stdlib_verification_queue.empty()) {
306 }
307
308 // Determine kernel type from queue contents
309 bool is_init_kernel =
311
312 bool is_hiding_kernel =
314
315 // The ECC-op subtable for a kernel begins with an eq-and-reset to ensure that the preceding circuit's subtable
316 // cannot affect the ECC-op accumulator for the kernel.
317 circuit.queue_ecc_eq();
318
319 // Step 2: VERIFICATION LOOP - Recursively verify each proof in the queue
320
321 std::vector<PairingPoints> points_accumulator;
322 std::optional<RecursiveVerifierAccumulator> current_stdlib_verifier_accumulator;
323 if (!is_init_kernel) {
324 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
326 }
327 while (!stdlib_verification_queue.empty()) {
328 const StdlibVerifierInputs& verifier_input = stdlib_verification_queue.front();
329
330 auto [output_stdlib_verifier_accumulator, pairing_points, updated_hash] =
332 verifier_input,
333 current_stdlib_verifier_accumulator,
334 running_hash,
335 accumulation_recursive_transcript);
336 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
337 running_hash = updated_hash;
338
339 // Update the output verifier accumulator
340 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
341
342 stdlib_verification_queue.pop_front();
343 }
344
345 // Step 3: OUTPUT - Set public inputs for propagation to next kernel
346 BB_ASSERT_EQ(running_hash.has_value(), true, "Running hash should be set for public input propagation");
347
348 // Output differs based on kernel type: HidingKernelIO (no accum hash) vs KernelIO (with accum hash)
349 if (is_hiding_kernel) {
350 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(), false);
351
352 // Perform batch merge verification
353 auto [batch_pairing_points, batch_merged_table_commitments] =
354 goblin.recursively_verify_batch_merge(circuit, running_hash.value());
355
356 // Append batch merge pairing points to the list of pairing points
357 points_accumulator.emplace_back(batch_pairing_points);
358
359 // Compute aggregated pairing points for output
360 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
361
362 // Add randomness at the end of the hiding kernel (whose ecc ops fall right at the end of the op queue table) to
363 // ensure the Chonk proof doesn't leak information about the actual content of the op queue
365
366 HidingKernelIO hiding_output{ pairing_points_aggregator,
368 std::move(batch_merged_table_commitments) };
369 hiding_output.set_public();
370 } else {
371 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(), false);
372
373 // Compute aggregated pairing points for output
374 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
375
376 // Extract native verifier accumulator from the stdlib accum to use it in the next round
377 recursive_verifier_native_accum = current_stdlib_verifier_accumulator->get_value<VerifierAccumulator>();
378
379 // Get databus commitments
380 auto kernel_return_data_commitment = bus_depot.get_kernel_return_data_commitment(circuit);
381 auto app_return_data_commitment = bus_depot.get_app_return_data_commitment(circuit);
382
383 // Compute hash of output accumulator
384 RecursiveTranscript hash_transcript;
385 StdlibFF current_verifier_accum_hash =
386 current_stdlib_verifier_accumulator->hash_with_origin_tagging(hash_transcript);
387 info("Kernel output accumulator hash: ", current_verifier_accum_hash);
388#ifndef NDEBUG
389 info("Chonk recursive verification: accumulator hash set in the public inputs matches the one "
390 "computed natively: ",
391 current_verifier_accum_hash.get_value() == native_verifier_accum_hash ? "true" : "false");
392#endif
393
394 // Propagate public inputs
395 KernelIO kernel_output{ pairing_points_aggregator,
396 kernel_return_data_commitment,
397 app_return_data_commitment,
398 running_hash.value(),
399 current_verifier_accum_hash };
400 kernel_output.set_public();
401 }
402}
403
408{
409 // first app
410 if (num_circuits_accumulated == 0) {
411 return QUEUE_TYPE::OINK;
412 }
413 // app (excluding first) or kernel (inner or reset)
415 return QUEUE_TYPE::HN;
416 }
417 // last kernel prior to tail kernel
419 return QUEUE_TYPE::HN_TAIL;
420 }
421 // tail kernel
424 }
425 // hiding kernel
427 return QUEUE_TYPE::MEGA;
428 }
429 throw_or_abort("Chonk::get_queue_type: num_circuits_accumulated out of range");
430}
431
436{
437 BB_BENCH_NAME("Chonk::accumulate_hiding_kernel");
438 vinfo("Constructing hiding kernel instance (proving deferred to prove())");
440 // Free circuit block memory now that trace data has been copied to prover polynomials
441 for (auto& block : circuit.blocks.get()) {
442 block.free_data();
443 }
444 // MegaZKFlavor inherits VerificationKey from MegaFlavor unchanged, so MegaZKVerificationKey
445 // and MegaVerificationKey are the same type. Reuse the caller-supplied precomputed VK when
446 // present to skip the 31 sequential commitments in the NativeVerificationKey_ ctor.
447 static_assert(
449 "hiding-kernel precomputed VK reuse relies on MegaZKFlavor inheriting VerificationKey from MegaFlavor");
450 if (precomputed_vk) {
451 hiding_vk = precomputed_vk;
452 } else {
454 }
455
456 // Push VK to queue so get_hiding_kernel_vk_and_hash() can find it.
457 VerifierInputs queue_entry{ {}, hiding_vk, QUEUE_TYPE::MEGA, /*is_kernel=*/true };
458 verification_queue.push_back(queue_entry);
460}
461
473 const std::shared_ptr<MegaVerificationKey>& precomputed_vk,
474 QUEUE_TYPE queue_type,
475 std::shared_ptr<ProverInstance> prover_instance)
476{
477 BB_BENCH_NAME("Chonk::accumulate_and_fold");
478 // Construct the prover instance for circuit (may already exist from debug path)
479 if (!prover_instance) {
480 prover_instance = std::make_shared<ProverInstance>(circuit);
481 }
482
483 // Free circuit block memory (wires and selectors) now that they've been copied to prover polynomials
484 for (auto& block : circuit.blocks.get()) {
485 block.free_data();
486 }
487
488 // We're accumulating a kernel if the verification queue is empty (because the kernel circuit contains recursive
489 // verifiers for all the entries previously present in the verification queue) and if it's not the first accumulate
490 // call (which will always be for an app circuit).
491 bool is_kernel = verification_queue.empty() && num_circuits_accumulated > 0;
492
493 // Transcript to be shared across folding of K_{i} (kernel) (the current kernel), A_{i+1,1} (app), .., A_{i+1,
494 // n} (app)
495 if (is_kernel) {
497 }
498
499#ifndef NDEBUG
500 // Make a copy of the prover_accumulation_transcript for the native verifier to use, only happens in debugging
501 // builds
502 auto verifier_transcript =
504#endif
505
507 HonkProof proof;
508 switch (queue_type) {
509 case QUEUE_TYPE::OINK:
510 vinfo("Accumulating first app circuit");
511 BB_ASSERT_EQ(is_kernel, false, "First circuit accumulated must always be an app");
512
513 prover_accumulator = prover.instance_to_accumulator(prover_instance, precomputed_vk);
514 proof = prover.export_proof();
515 break;
516 case QUEUE_TYPE::HN:
518 vinfo("Accumulating circuit number ", num_circuits_accumulated + 1);
519 // Move old accumulator into fold, receive new accumulator back
520 std::tie(proof, prover_accumulator) =
521 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
522 break;
524 vinfo("Accumulating tail kernel");
525 // Move old accumulator into fold, receive new accumulator back
526 std::tie(proof, prover_accumulator) =
527 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
528 // Decider uses the NEW prover_accumulator (result of fold)
531 break;
532 }
533 default:
534 BB_ASSERT(false, "Unexpected queue type");
535 break;
536 }
537
541 }
542
543 VerifierInputs queue_entry{ std::move(proof), precomputed_vk, queue_type, is_kernel };
544 verification_queue.push_back(queue_entry);
545
546#ifndef NDEBUG
547 update_native_verifier_accumulator(queue_entry, verifier_transcript);
548#endif
549 // Keep one subtable per folded circuit and prove the batched merge after the tail kernel.
550 goblin.op_queue->merge();
551
553}
554
565{
566 BB_BENCH_NAME("Chonk::accumulate");
568 num_circuits_accumulated, num_circuits, "Chonk: Attempting to accumulate more circuits than expected.");
569 BB_ASSERT(precomputed_vk != nullptr, "Chonk::accumulate - VK expected for the provided circuit");
570
571 QUEUE_TYPE queue_type = get_queue_type();
572
573 std::shared_ptr<ProverInstance> prover_instance;
574#ifndef NDEBUG
575 prover_instance = std::make_shared<ProverInstance>(circuit);
576 debug_incoming_circuit(circuit, prover_instance, precomputed_vk);
577#endif
578
579 if (queue_type == QUEUE_TYPE::MEGA) {
580 accumulate_hiding_kernel(circuit, precomputed_vk);
581 } else {
582 accumulate_and_fold(circuit, precomputed_vk, queue_type, std::move(prover_instance));
583 }
584
585 prover_instance.reset();
586 if (queue_type == QUEUE_TYPE::HN_FINAL) {
587 prover_accumulator = ProverAccumulator(); // Free the prover accumulator now that it's no longer needed in the
588 // remaining fold of the hiding kernel
590 }
591}
592
603
618{
619 BB_BENCH_NAME("Chonk::prove");
620
621 // Share transcript between all provers.
623
624 // Phase 1: MegaZK Oink on the shared transcript.
626 auto hiding_oink_proof = batched_prover.prove_mega_zk_oink();
627
628 // Phase 2: Merge proof on the shared transcript (fixed append — hiding kernel's subtable).
629 auto merge_proof = goblin.prove_merge(transcript);
630 info("Goblin: num ultra ops = ", goblin.op_queue->get_ultra_ops_count());
631
632 // Phase 3: ECCVM proof on the shared transcript.
633 vinfo("prove eccvm...");
635 vinfo("finished eccvm proving.");
636
637 // Phase 4: Build translator proving key from ECCVM-derived challenges.
638 TranslatorCircuitBuilder translator_builder(
640 auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder);
641
642 // Phase 5: Translator Oink + Joint Sumcheck + Joint PCS on the shared transcript.
643 vinfo("prove translator and joint...");
644 auto joint_proof = batched_prover.prove(translator_key);
645 vinfo("finished translator and joint proving.");
646
647 // Release the hiding kernel instance now that proving is complete.
648 hiding_prover_inst.reset();
649
650 return ChonkProof{ std::move(hiding_oink_proof),
651 std::move(merge_proof),
654 std::move(joint_proof) };
655}
656
658{
659 BB_ASSERT_EQ(verification_queue.size(), 1UL, "Expected single hiding kernel VK in queue");
660 BB_ASSERT(verification_queue.front().type == QUEUE_TYPE::MEGA, "Expected MEGA proof type");
662}
663
664#ifndef NDEBUG
666 const std::shared_ptr<Transcript>& verifier_transcript)
667{
668 info("======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
669
670 auto verifier_inst =
672
673 FoldingVerifier native_verifier(verifier_transcript);
674 if (queue_entry.type == QUEUE_TYPE::OINK) {
675 auto [_first_verified, new_accumulator] =
676 native_verifier.instance_to_accumulator(verifier_inst, queue_entry.proof);
677 native_verifier_accum = std::move(new_accumulator);
678
679 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
680 } else {
681 auto [_first_verified, _second_verified, new_accumulator] =
682 native_verifier.verify_folding_proof(verifier_inst, queue_entry.proof);
683 native_verifier_accum = std::move(new_accumulator);
684
685 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
686 info("Sumcheck: batch two accumulators verified: ", _second_verified ? "true" : "false");
687
688 if (queue_entry.type == QUEUE_TYPE::HN_FINAL) {
689 HypernovaDeciderVerifier<MegaFlavor> decider_verifier(verifier_transcript);
690 bb::PairingPoints<curve::BN254> pairing_points =
692
693 info("Decider: pairing points verified? ", pairing_points.check() ? "true" : "false");
694 }
695 }
696
697 info("Chonk accumulate: prover and verifier accumulators match: ",
699
700 // Update the native verifier accumulator hash if we are accumulating an app (i.e. the previous circuit was a
701 // kernel) or if the last app has been accumulated (i.e. the current circuit is the tail kernel)
702 bool update_verifier_accum_hash = is_previous_circuit_a_kernel || has_last_app_been_accumulated;
703 if (update_verifier_accum_hash) {
704 native_verifier_accum_hash = native_verifier_accum.hash_with_origin_tagging(*verifier_transcript);
705 info("Chonk accumulate: hash of verifier accumulator computed natively set in previous kernel IO: ",
707 }
710
711 info("======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
712}
713
715 const std::shared_ptr<ProverInstance>& prover_instance,
716 const std::shared_ptr<MegaVerificationKey>& precomputed_vk)
717{
718 info("======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
719
720 info("Accumulating circuit ", num_circuits_accumulated + 1, " of ", num_circuits);
721 info("Is the circuit valid? ", CircuitChecker::check(circuit) ? "true" : "false");
722 info("Did we find a failure? ", circuit.failed() ? "true" : "false");
723 if (circuit.failed()) {
724 info("\t\t\tError message? ", circuit.err());
725 }
726
727 // Compare precomputed VK with the one generated during accumulation
728 auto vk = std::make_shared<MegaVerificationKey>(prover_instance->get_precomputed());
729 info("Does the precomputed vk match with the one generated during accumulation? ",
730 vk->compare(*precomputed_vk, MegaFlavor::CommitmentLabels().get_precomputed()) ? "true" : "false");
731
732 info("======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
733}
734#endif
735
736} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:70
#define BB_ASSERT_GTE(left, right,...)
Definition assert.hpp:128
#define BB_ASSERT_DEBUG(expression,...)
Definition assert.hpp:55
#define BB_ASSERT_NEQ(actual, expected,...)
Definition assert.hpp:98
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:83
#define BB_ASSERT_LT(left, right,...)
Definition assert.hpp:143
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:264
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
static std::shared_ptr< BaseTranscript > convert_prover_transcript_to_verifier_transcript(const std::shared_ptr< BaseTranscript > &prover_transcript)
Convert a prover transcript to a verifier transcript.
static FF ecc_op_hash_step(const std::vector< Commitment > &col_commitments, const std::optional< FF > &prev_hash=std::nullopt)
Compute one step of the ECC op running hash.
Prover for the batched MegaZK circuit + translator sumcheck and PCS.
HonkProof prove(std::shared_ptr< TranslatorProvingKey > translator_proving_key)
ProverAccumulator prover_accumulator
Definition chonk.hpp:159
void instantiate_stdlib_verification_queue(ClientCircuit &circuit, const std::vector< std::shared_ptr< RecursiveVKAndHash > > &input_keys={})
Instantiate a stdlib verification queue for use in the kernel completion logic.
Definition chonk.cpp:42
std::shared_ptr< MegaZKFlavor::VKAndHash > get_hiding_kernel_vk_and_hash() const
Get the hiding kernel verification key and hash for Chonk verification.
Definition chonk.cpp:657
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
Definition chonk.cpp:292
VerifierAccumulator native_verifier_accum
Definition chonk.hpp:165
void accumulate_and_fold(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk, QUEUE_TYPE queue_type, std::shared_ptr< ProverInstance > prover_instance)
Perform HyperNova folding for a circuit and produce the corresponding merge proof.
Definition chonk.cpp:472
void accumulate_hiding_kernel(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
Build the hiding kernel's ZK proving key and verification key (proving is deferred to prove()).
Definition chonk.cpp:435
Chonk(size_t num_circuits)
Definition chonk.cpp:26
void update_native_verifier_accumulator(const VerifierInputs &queue_entry, const std::shared_ptr< Transcript > &verifier_transcript)
Update native verifier accumulator. Useful for debugging.
Definition chonk.cpp:665
static void hide_op_queue_content_in_hiding(ClientCircuit &circuit)
Adds two random non-ops to the hiding kernel for zero-knowledge.
Definition chonk.cpp:598
DataBusDepot bus_depot
Definition chonk.hpp:179
std::shared_ptr< Transcript > transcript
Definition chonk.hpp:150
size_t num_circuits_accumulated
Definition chonk.hpp:157
void debug_incoming_circuit(ClientCircuit &circuit, const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
Definition chonk.cpp:714
HonkProof decider_proof
Definition chonk.hpp:161
FF native_verifier_accum_hash
Definition chonk.hpp:166
QUEUE_TYPE
Proof type determining recursive verification logic in kernel circuits.
Definition chonk.hpp:117
bool has_last_app_been_accumulated
Definition chonk.hpp:168
QUEUE_TYPE get_queue_type() const
Get queue type for the proof of a circuit about to be accumulated based on num circuits accumulated s...
Definition chonk.cpp:407
ChonkProof prove()
Construct Chonk proof using the batched MegaZK + Translator protocol.
Definition chonk.cpp:617
RecursiveFlavor::FF StdlibFF
Definition chonk.hpp:60
FoldingProver::Accumulator ProverAccumulator
Definition chonk.hpp:80
PublicInputsResult process_public_inputs_and_consistency_checks(const StdlibVerifierInputs &verifier_inputs, std::vector< StdlibFF > &public_inputs, WitnessCommitments &witness_commitments, const std::optional< StdlibFF > &prev_accum_hash)
Process public inputs from a verified circuit and perform databus consistency checks.
Definition chonk.cpp:146
VerifierAccumulator recursive_verifier_native_accum
Definition chonk.hpp:163
bool is_previous_circuit_a_kernel
Definition chonk.hpp:167
std::tuple< std::optional< RecursiveVerifierAccumulator >, std::vector< PairingPoints >, StdlibFF > recursive_verification_and_consistency_checks(ClientCircuit &circuit, const StdlibVerifierInputs &verifier_inputs, const std::optional< RecursiveVerifierAccumulator > &input_verifier_accumulator, const std::optional< StdlibFF > &running_hash, const std::shared_ptr< RecursiveTranscript > &accumulation_recursive_transcript)
Orchestrate recursive verification, databus consistency checks, and merge verification for a single c...
Definition chonk.cpp:225
std::shared_ptr< HidingKernelProverInstance > hiding_prover_inst
Definition chonk.hpp:184
void accumulate(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
Perform prover work for accumulation (e.g. HN folding, merge proving)
Definition chonk.cpp:564
FoldingResult verify_folding(ClientCircuit &circuit, const StdlibVerifierInputs &verifier_inputs, const std::shared_ptr< RecursiveVerifierInstance > &verifier_instance, const std::shared_ptr< RecursiveTranscript > &accumulation_recursive_transcript) const
Perform recursive folding verification for a single circuit in the IVC.
Definition chonk.cpp:86
size_t num_circuits
Definition chonk.hpp:155
VerificationQueue verification_queue
Definition chonk.hpp:175
Goblin goblin
Definition chonk.hpp:181
std::shared_ptr< MegaZKVerificationKey > hiding_vk
Definition chonk.hpp:185
std::shared_ptr< Transcript > prover_accumulation_transcript
Definition chonk.hpp:153
StdlibVerificationQueue stdlib_verification_queue
Definition chonk.hpp:176
const std::string & err() const
fq evaluation_challenge_x
Definition goblin.hpp:64
GoblinProof goblin_proof
Definition goblin.hpp:61
MergeProof prove_merge(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >()) const
Construct a single-step merge proof for the most recently merged subtable.
Definition goblin.cpp:28
void prove_eccvm()
Construct an ECCVM proof and IPA opening proof.
Definition goblin.cpp:35
fq translation_batching_challenge_v
Definition goblin.hpp:63
void prove_batch_merge()
Construct a batched merge proof for all subtables accumulated during the IVC.
Definition goblin.cpp:98
std::shared_ptr< OpQueue > op_queue
Definition goblin.hpp:59
std::shared_ptr< Transcript > transcript
Definition goblin.hpp:65
std::pair< PairingPoints, BatchRecursiveTableCommitments > recursively_verify_batch_merge(MegaBuilder &builder, const BatchMergeRecursiveVerifier::FF &hash) const
Recursively verify the batched merge proof inside the hiding kernel.
Definition goblin.cpp:115
HyperNova decider prover. Produces final opening proof for the accumulated claim.
HonkProof construct_proof(Accumulator &accumulator)
HyperNova decider verifier (native + recursive). Verifies final opening proof.
PairingPoints verify_proof(Accumulator &accumulator, const Proof &proof)
HyperNova folding prover. Folds circuit instances into accumulators, deferring PCS verification.
HonkProof export_proof()
Export the proof contained in the transcript.
Accumulator instance_to_accumulator(const std::shared_ptr< ProverInstance > &instance, const std::shared_ptr< VerificationKey > &honk_vk=nullptr)
Turn an instance into an accumulator by running Sumcheck.
std::pair< HonkProof, Accumulator > fold(Accumulator &&accumulator, const std::shared_ptr< ProverInstance > &instance, const std::shared_ptr< VerificationKey > &honk_vk=nullptr)
Fold an instance into an accumulator.
HyperNova folding verifier (native + recursive). Verifies folding proofs and maintains accumulators.
std::tuple< bool, bool, Accumulator > verify_folding_proof(const std::shared_ptr< typename HypernovaFoldingVerifier::VerifierInstance > &instance, const Proof &proof)
Verify folding proof. Return the new accumulator and the results of the two sumchecks.
std::pair< bool, Accumulator > instance_to_accumulator(const std::shared_ptr< VerifierInstance > &instance, const Proof &proof)
Turn an instance into an accumulator by executing sumcheck.
void queue_ecc_random_op()
Mechanism for populating two rows with randomness. This "operation" doesn't return a tuple representi...
ecc_op_tuple queue_ecc_eq(bool in_finalize=true)
Add point equality operation to the op queue based on the value of the internal accumulator and add c...
A container for commitment labels.
Container for all witness polynomials used/constructed by the prover.
An object storing two EC points that represent the inputs to a pairing check.
bool check() const
Verify the pairing equation e(P0, [1]₂) · e(P1, [x]₂) = 1.
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
Commitment get_kernel_return_data_commitment(Builder &builder)
Get the previously set kernel return data commitment if it exists, else a default one.
Definition databus.hpp:129
Commitment get_app_return_data_commitment(Builder &builder)
Get the previously set app return data commitment if it exists, else a default one.
Definition databus.hpp:142
void set_app_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:107
void set_kernel_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:101
Manages the data that is propagated on the public inputs of an application/function circuit.
void reconstruct_from_public(const std::vector< FF > &public_inputs)
Reconstructs the IO components from a public inputs array.
Manages the data that is propagated on the public inputs of a hiding kernel circuit.
Manages the data that is propagated on the public inputs of a kernel circuit.
void reconstruct_from_public(const std::vector< FF > &public_inputs)
Reconstructs the IO components from a public inputs array.
#define info(...)
Definition log.hpp:93
#define vinfo(...)
Definition log.hpp:94
bool use_memory_profile
MemoryProfile GLOBAL_MEMORY_PROFILE
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< fr > HonkProof
Definition proof.hpp:15
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::shared_ptr< RecursiveVKAndHash > honk_vk_and_hash
Definition chonk.hpp:131
std::shared_ptr< MegaVerificationKey > honk_vk
Definition chonk.hpp:122
std::vector< FF > proof
Definition chonk.hpp:121
HonkProof eccvm_proof
Definition types.hpp:23
HonkProof ipa_proof
Definition types.hpp:24
bool compare_with_verifier_claim(const MultilinearBatchingVerifierClaim< curve::BN254 > &verifier_claim)
Debug helper to compare prover claim against verifier claim.
Verifier's claim for multilinear batching - contains commitments and evaluation claims.
void add_checkpoint(const std::string &stage)
static PairingPoints aggregate_multiple(std::vector< PairingPoints > &pairing_points, bool handle_edge_cases=true)
Aggregate multiple PairingPoints using random linear combination.
void throw_or_abort(std::string const &err)