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#include <array>
23
24namespace bb {
25
26// Constructor
27Chonk::Chonk(size_t num_circuits)
28 : num_circuits(num_circuits)
29{
30 BB_ASSERT_GTE(num_circuits, 4UL, "Number of circuits must be at least 4 (get_queue_type uses num_circuits - 3).");
31}
32
44 const std::vector<std::shared_ptr<RecursiveVKAndHash>>& input_keys)
45{
46 bool vkeys_provided = !input_keys.empty();
47 if (vkeys_provided) {
49 input_keys.size(),
50 "Incorrect number of verification keys provided in "
51 "stdlib verification queue instantiation.");
52 }
53
54 size_t key_idx = 0;
55 while (!verification_queue.empty()) {
56 const VerifierInputs& entry = verification_queue.front();
57
58 // Construct stdlib proof directly from the internal native queue data
59 StdlibProof stdlib_proof(circuit, entry.proof);
60
61 // Use the provided stdlib vkey if present, otherwise construct one from the internal native queue
62 std::shared_ptr<RecursiveVKAndHash> stdlib_vk_and_hash;
63 if (vkeys_provided) {
64 stdlib_vk_and_hash = input_keys[key_idx++];
65 } else {
66 stdlib_vk_and_hash = std::make_shared<RecursiveVKAndHash>(circuit, entry.honk_vk);
67 }
68
69 stdlib_verification_queue.emplace_back(stdlib_proof, stdlib_vk_and_hash, entry.type, entry.is_kernel);
70
71 verification_queue.pop_front(); // the native data is not needed beyond this point
72 }
73}
74
88 ClientCircuit& circuit,
89 const StdlibVerifierInputs& verifier_inputs,
90 const std::shared_ptr<RecursiveVerifierInstance>& verifier_instance,
91 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript) const
92{
93 std::vector<PairingPoints> pairing_points;
95
96 RecursiveFoldingVerifier folding_verifier(accumulation_recursive_transcript);
97 switch (verifier_inputs.type) {
98 case QUEUE_TYPE::OINK: {
99 vinfo("Recursively verifying accumulation of the first app circuit.");
100 auto [_, new_verifier_accumulator] =
101 folding_verifier.instance_to_accumulator(verifier_instance, verifier_inputs.proof);
102 output_accumulator = std::move(new_verifier_accumulator);
103 break;
104 }
105 case QUEUE_TYPE::HN:
106 case QUEUE_TYPE::HN_TAIL: {
107 vinfo("Recursively verifying inner accumulation.");
108 auto [_first_verified, _second_verified, new_verifier_accumulator] =
109 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
110 output_accumulator = std::move(new_verifier_accumulator);
111 break;
112 }
114 vinfo("Recursively verifying accumulation of the tail kernel.");
115 BB_ASSERT_EQ(stdlib_verification_queue.size(), size_t(1));
116
117 auto [_first_verified, _second_verified, final_verifier_accumulator] =
118 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
119
120 RecursiveDeciderVerifier decider_verifier(accumulation_recursive_transcript);
121 StdlibProof stdlib_decider_proof(circuit, decider_proof);
122 pairing_points.emplace_back(decider_verifier.verify_proof(final_verifier_accumulator, stdlib_decider_proof));
123 break;
124 }
125 default: {
126 throw_or_abort("Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
127 }
128 }
129
130 return { std::move(output_accumulator), std::move(pairing_points) };
131}
132
148 const StdlibVerifierInputs& verifier_inputs,
149 std::vector<StdlibFF>& public_inputs,
150 WitnessCommitments& witness_commitments,
151 const std::optional<StdlibFF>& prev_accum_hash)
152{
153 if (verifier_inputs.is_kernel) {
154 BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::HN || verifier_inputs.type == QUEUE_TYPE::HN_TAIL ||
155 verifier_inputs.type == QUEUE_TYPE::HN_FINAL,
156 true,
157 "Kernel circuits should be folded.");
158
159 // ============= Reconstruct the public inputs of the previous kernel =============
160
161 KernelIO kernel_input; // pairing points, ecc op tables, databus commitments
162 kernel_input.reconstruct_from_public(public_inputs);
163
164 // ============= Perform databus consistency checks ===============================
165
166 // Kernel return data
167 bool kernel_return_data_match =
168 kernel_input.kernel_return_data.get_value() == witness_commitments.kernel_calldata.get_value();
169 BB_ASSERT_DEBUG(kernel_return_data_match,
170 "kernel_return_data mismatch: proof contains "
171 << kernel_input.kernel_return_data.get_value() << " but kernel_calldata commitment is "
172 << witness_commitments.kernel_calldata.get_value());
173 kernel_input.kernel_return_data.incomplete_assert_equal(witness_commitments.kernel_calldata);
174
175 const std::array app_calldata_commitments{ &witness_commitments.first_app_calldata,
176 &witness_commitments.second_app_calldata,
177 &witness_commitments.third_app_calldata };
178 for (size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
179 bool app_return_data_match =
180 kernel_input.app_return_data[idx].get_value() == app_calldata_commitments[idx]->get_value();
181 BB_ASSERT_DEBUG(app_return_data_match,
182 "app_return_data mismatch: proof contains "
183 << kernel_input.app_return_data[idx].get_value() << " but app calldata commitment "
184 << idx << " is " << app_calldata_commitments[idx]->get_value());
185 kernel_input.app_return_data[idx].incomplete_assert_equal(*app_calldata_commitments[idx]);
186 }
187
188 // ============= Perform accumulator hash consistency check =========================
189
190 info("Accumulator hash from IO: ", kernel_input.output_hn_accum_hash);
191 BB_ASSERT(prev_accum_hash.has_value());
192 bool accum_hash_match = kernel_input.output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
193 BB_ASSERT_DEBUG(accum_hash_match,
194 "output_hn_accum_hash mismatch: proof contains "
195 << kernel_input.output_hn_accum_hash.get_value() << " but expected "
196 << prev_accum_hash->get_value());
197 kernel_input.output_hn_accum_hash.assert_equal(*prev_accum_hash);
198
199 // ============= Set the kernel return data commitment ==============================
200
201 bus_depot.set_kernel_return_data_commitment(witness_commitments.return_data);
202
203 return { std::move(kernel_input.pairing_inputs), std::move(kernel_input.ecc_op_hash) };
204 }
205
206 // App circuit path
207 AppIO app_input; // pairing points
208 app_input.reconstruct_from_public(public_inputs);
209
210 // Set the app return data commitment to be propagated via the public inputs. The depot owns slot allocation.
211 bus_depot.set_app_return_data_commitment(witness_commitments.return_data);
212
213 return { std::move(app_input.pairing_inputs), std::nullopt };
214}
215
231 ClientCircuit& circuit,
232 const StdlibVerifierInputs& verifier_inputs,
233 const std::optional<RecursiveVerifierAccumulator>& input_verifier_accumulator,
234 const std::optional<StdlibFF>& running_hash,
235 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript)
236{
237 BB_BENCH_NAME("Chonk::recursive_verification_and_consistency_checks");
238
239 auto verifier_instance = std::make_shared<RecursiveVerifierInstance>(verifier_inputs.honk_vk_and_hash);
240
241 // Compute prev_accum_hash before folding (transcript state changes during verification)
242 std::optional<StdlibFF> prev_accum_hash;
243 if (verifier_inputs.is_kernel) {
244 BB_ASSERT(input_verifier_accumulator.has_value(), "Previous accumulator expected for kernel circuit folding");
245 prev_accum_hash = input_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
246 }
247
248 // Step 1: Recursive folding verification
249 if (verifier_inputs.type == QUEUE_TYPE::OINK) {
250 BB_ASSERT_EQ(input_verifier_accumulator.has_value(), false);
251 }
252 auto [output_accumulator, folding_points] =
253 verify_folding(circuit, verifier_inputs, verifier_instance, accumulation_recursive_transcript);
254
255 // Extract the witness commitments and public inputs from the verified instance
256 WitnessCommitments witness_commitments = std::move(verifier_instance->witness_commitments);
257 std::vector<StdlibFF> public_inputs = std::move(verifier_instance->public_inputs);
258
259 // Step 2: Process public inputs and perform databus consistency checks
260 auto [io_pairing_points, previous_ecc_op_hash] = process_public_inputs_and_consistency_checks(
261 verifier_inputs, public_inputs, witness_commitments, prev_accum_hash);
262
263 std::optional<StdlibFF> updated_hash = running_hash;
264 if (previous_ecc_op_hash.has_value()) {
265 BB_ASSERT_EQ(verifier_inputs.is_kernel, true, "previous_ecc_op_hash should only be set for kernels");
266 BB_ASSERT(!running_hash.has_value(), "Running hash should not be set when recursively verifying a kernel");
267 updated_hash = previous_ecc_op_hash.value();
268 }
269
270 // Step 3: Update the running ECC op hash with this circuit's ECC op column commitments.
271 auto ecc_op_col_commitments = witness_commitments.get_ecc_op_wires().get_copy();
272 const std::vector<RecursiveCommitment> ecc_op_col_commitments_vec(ecc_op_col_commitments.begin(),
273 ecc_op_col_commitments.end());
274 updated_hash = Goblin::BatchMergeRecursiveVerifier::ecc_op_hash_step(ecc_op_col_commitments_vec, updated_hash);
275
276 // Combine all pairing points
278 all_points.insert(all_points.end(), folding_points.begin(), folding_points.end());
279 all_points.emplace_back(std::move(io_pairing_points));
280
281 return { std::move(output_accumulator), std::move(all_points), updated_hash.value() };
282}
283
298{
299 BB_BENCH_NAME("Chonk::complete_kernel_circuit_logic");
300 // Step 1: SETUP - Initialize state and determine kernel type
301
302 // Transcript is shared across recursive verification of the folding of K_{i-1} (kernel) and A_{i} (app)
303 auto accumulation_recursive_transcript = std::make_shared<RecursiveTranscript>();
304
305 // Running Poseidon2 hash over ECC op column commitments, propagated through kernel public inputs.
307
308 // Convert native verification queue to circuit witnesses
309 if (stdlib_verification_queue.empty()) {
311 }
312
313 // Determine kernel type from queue contents
314 bool is_init_kernel = stdlib_verification_queue.front().type == QUEUE_TYPE::OINK;
315
316 bool is_hiding_kernel =
318
319 // The ECC-op subtable for a kernel begins with an eq-and-reset to ensure that the preceding circuit's subtable
320 // cannot affect the ECC-op accumulator for the kernel.
321 circuit.queue_ecc_eq();
322
323 // Step 2: VERIFICATION LOOP - Recursively verify each proof in the queue
324
326 "DataBusDepot has stale app return-data slots at kernel-completion boundary");
327
328 std::vector<PairingPoints> points_accumulator;
329 std::optional<RecursiveVerifierAccumulator> current_stdlib_verifier_accumulator;
330 if (!is_init_kernel) {
331 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
333 }
334 while (!stdlib_verification_queue.empty()) {
335 const StdlibVerifierInputs& verifier_input = stdlib_verification_queue.front();
336
337 auto [output_stdlib_verifier_accumulator, pairing_points, updated_hash] =
339 verifier_input,
340 current_stdlib_verifier_accumulator,
341 running_hash,
342 accumulation_recursive_transcript);
343 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
344 running_hash = updated_hash;
345
346 // Update the output verifier accumulator
347 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
348
349 stdlib_verification_queue.pop_front();
350 }
351
352 // Step 3: OUTPUT - Set public inputs for propagation to next kernel
353 BB_ASSERT_EQ(running_hash.has_value(), true, "Running hash should be set for public input propagation");
354
355 // Output differs based on kernel type: HidingKernelIO (no accum hash) vs KernelIO (with accum hash)
356 if (is_hiding_kernel) {
357 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(), false);
358
359 // Perform batch merge verification
360 auto [batch_pairing_points, batch_merged_table_commitments] =
361 goblin.recursively_verify_batch_merge(circuit, running_hash.value());
362
363 // Append batch merge pairing points to the list of pairing points
364 points_accumulator.emplace_back(batch_pairing_points);
365
366 // Compute aggregated pairing points for output
367 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
368
369 // Add randomness at the end of the hiding kernel (whose ecc ops fall right at the end of the op queue table) to
370 // ensure the Chonk proof doesn't leak information about the actual content of the op queue
372
373 HidingKernelIO hiding_output{ pairing_points_aggregator,
375 std::move(batch_merged_table_commitments) };
376 hiding_output.set_public();
377 } else {
378 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(), false);
379
380 // Compute aggregated pairing points for output
381 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
382
383 // Extract native verifier accumulator from the stdlib accum to use it in the next round
384 recursive_verifier_native_accum = current_stdlib_verifier_accumulator->get_value<VerifierAccumulator>();
385
386 auto kernel_return_data_commitment = bus_depot.get_kernel_return_data_commitment(circuit);
387 KernelIO::AppReturnDataCommitments app_return_data_commitments;
388 for (size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
389 app_return_data_commitments[idx] = bus_depot.get_app_return_data_commitment(circuit, idx);
390 }
391
392 // Compute hash of output accumulator
393 RecursiveTranscript hash_transcript;
394 StdlibFF current_verifier_accum_hash =
395 current_stdlib_verifier_accumulator->hash_with_origin_tagging(hash_transcript);
396 info("Kernel output accumulator hash: ", current_verifier_accum_hash);
397#ifndef NDEBUG
398 info("Chonk recursive verification: accumulator hash set in the public inputs matches the one "
399 "computed natively: ",
400 current_verifier_accum_hash.get_value() == native_verifier_accum_hash ? "true" : "false");
401#endif
402
403 // Propagate public inputs
404 KernelIO kernel_output{ pairing_points_aggregator,
405 kernel_return_data_commitment,
406 app_return_data_commitments,
407 running_hash.value(),
408 current_verifier_accum_hash };
409 kernel_output.set_public();
410 }
411}
412
417{
418 // first app
419 if (num_circuits_accumulated == 0) {
420 return QUEUE_TYPE::OINK;
421 }
422 // app (excluding first) or kernel (inner or reset)
424 return QUEUE_TYPE::HN;
425 }
426 // last kernel prior to tail kernel
428 return QUEUE_TYPE::HN_TAIL;
429 }
430 // tail kernel
433 }
434 // hiding kernel
436 return QUEUE_TYPE::MEGA;
437 }
438 throw_or_abort("Chonk::get_queue_type: num_circuits_accumulated out of range");
439}
440
445{
446 BB_BENCH_NAME("Chonk::accumulate_hiding_kernel");
447 vinfo("Constructing hiding kernel instance (proving deferred to prove())");
449 // Free circuit block memory now that trace data has been copied to prover polynomials
450 for (auto& block : circuit.blocks.get()) {
451 block.free_data();
452 }
453 // MegaZKFlavor inherits VerificationKey from MegaFlavor unchanged, so MegaZKVerificationKey
454 // and MegaVerificationKey are the same type. Reuse the caller-supplied precomputed VK when
455 // present to skip the 31 sequential commitments in the NativeVerificationKey_ ctor.
456 static_assert(
458 "hiding-kernel precomputed VK reuse relies on MegaZKFlavor inheriting VerificationKey from MegaFlavor");
459 if (precomputed_vk) {
460 hiding_vk = precomputed_vk;
461 } else {
463 }
464
465 // Push VK to queue so get_hiding_kernel_vk_and_hash() can find it.
466 VerifierInputs queue_entry{ {}, hiding_vk, QUEUE_TYPE::MEGA, /*is_kernel=*/true };
467 verification_queue.push_back(queue_entry);
469}
470
482 const std::shared_ptr<MegaVerificationKey>& precomputed_vk,
483 QUEUE_TYPE queue_type,
484 std::shared_ptr<ProverInstance> prover_instance)
485{
486 BB_BENCH_NAME("Chonk::accumulate_and_fold");
487 // Construct the prover instance for circuit (may already exist from debug path)
488 if (!prover_instance) {
489 prover_instance = std::make_shared<ProverInstance>(circuit);
490 }
491
492 // Free circuit block memory (wires and selectors) now that they've been copied to prover polynomials
493 for (auto& block : circuit.blocks.get()) {
494 block.free_data();
495 }
496
497 // We're accumulating a kernel if the verification queue is empty (because the kernel circuit contains recursive
498 // verifiers for all the entries previously present in the verification queue) and if it's not the first accumulate
499 // call (which will always be for an app circuit).
500 bool is_kernel = verification_queue.empty() && num_circuits_accumulated > 0;
501
502 // Transcript to be shared across folding of K_{i} (kernel) (the current kernel), A_{i+1,1} (app), .., A_{i+1,
503 // n} (app)
504 if (is_kernel) {
506 }
507
508#ifndef NDEBUG
509 // Make a copy of the prover_accumulation_transcript for the native verifier to use, only happens in debugging
510 // builds
511 auto verifier_transcript =
513#endif
514
516 HonkProof proof;
517 switch (queue_type) {
518 case QUEUE_TYPE::OINK:
519 vinfo("Accumulating first app circuit");
520 BB_ASSERT_EQ(is_kernel, false, "First circuit accumulated must always be an app");
521
522 prover_accumulator = prover.instance_to_accumulator(prover_instance, precomputed_vk);
523 proof = prover.export_proof();
524 break;
525 case QUEUE_TYPE::HN:
527 vinfo("Accumulating circuit number ", num_circuits_accumulated + 1);
528 // Move old accumulator into fold, receive new accumulator back
529 std::tie(proof, prover_accumulator) =
530 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
531 break;
533 vinfo("Accumulating tail kernel");
534 // Move old accumulator into fold, receive new accumulator back
535 std::tie(proof, prover_accumulator) =
536 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
537 // Decider uses the NEW prover_accumulator (result of fold)
540 break;
541 }
542 default:
543 BB_ASSERT(false, "Unexpected queue type");
544 break;
545 }
546
550 }
551
552 VerifierInputs queue_entry{ std::move(proof), precomputed_vk, queue_type, is_kernel };
553 verification_queue.push_back(queue_entry);
554
555#ifndef NDEBUG
556 update_native_verifier_accumulator(queue_entry, verifier_transcript);
557#endif
558 // Keep one subtable per folded circuit and prove the batched merge after the tail kernel.
559 goblin.op_queue->merge();
560
562}
563
574{
575 BB_BENCH_NAME("Chonk::accumulate");
577 num_circuits_accumulated, num_circuits, "Chonk: Attempting to accumulate more circuits than expected.");
578 BB_ASSERT(precomputed_vk != nullptr, "Chonk::accumulate - VK expected for the provided circuit");
579
580 QUEUE_TYPE queue_type = get_queue_type();
581
582 std::shared_ptr<ProverInstance> prover_instance;
583#ifndef NDEBUG
584 prover_instance = std::make_shared<ProverInstance>(circuit);
585 debug_incoming_circuit(circuit, prover_instance, precomputed_vk);
586#endif
587
588 if (queue_type == QUEUE_TYPE::MEGA) {
589 accumulate_hiding_kernel(circuit, precomputed_vk);
590 } else {
591 accumulate_and_fold(circuit, precomputed_vk, queue_type, std::move(prover_instance));
592 }
593
594 prover_instance.reset();
595 if (queue_type == QUEUE_TYPE::HN_FINAL) {
596 prover_accumulator = ProverAccumulator(); // Free the prover accumulator now that it's no longer needed in the
597 // remaining fold of the hiding kernel
599 }
600}
601
612
627{
628 BB_BENCH_NAME("Chonk::prove");
629
630 // Share transcript between all provers.
632
633 // Phase 1: MegaZK Oink on the shared transcript.
635 auto hiding_oink_proof = batched_prover.prove_mega_zk_oink();
636
637 // Phase 2: Merge proof on the shared transcript (fixed append — hiding kernel's subtable).
638 auto merge_proof = goblin.prove_merge(transcript);
639 info("Goblin: num ultra ops = ", goblin.op_queue->get_ultra_ops_count());
640
641 // Phase 3: ECCVM proof on the shared transcript.
642 vinfo("prove eccvm...");
644 vinfo("finished eccvm proving.");
645
646 // Phase 4: Build translator proving key from ECCVM-derived challenges.
647 TranslatorCircuitBuilder translator_builder(
649 auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder);
650
651 // Phase 5: Translator Oink + Joint Sumcheck + Joint PCS on the shared transcript.
652 vinfo("prove translator and joint...");
653 auto joint_proof = batched_prover.prove(translator_key);
654 vinfo("finished translator and joint proving.");
655
656 // Release the hiding kernel instance now that proving is complete.
657 hiding_prover_inst.reset();
658
659 return ChonkProof{ std::move(hiding_oink_proof),
660 std::move(merge_proof),
663 std::move(joint_proof) };
664}
665
667{
668 BB_ASSERT_EQ(verification_queue.size(), 1UL, "Expected single hiding kernel VK in queue");
669 BB_ASSERT(verification_queue.front().type == QUEUE_TYPE::MEGA, "Expected MEGA proof type");
671}
672
673#ifndef NDEBUG
675 const std::shared_ptr<Transcript>& verifier_transcript)
676{
677 info("======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
678
679 auto verifier_inst =
681
682 FoldingVerifier native_verifier(verifier_transcript);
683 if (queue_entry.type == QUEUE_TYPE::OINK) {
684 auto [_first_verified, new_accumulator] =
685 native_verifier.instance_to_accumulator(verifier_inst, queue_entry.proof);
686 native_verifier_accum = std::move(new_accumulator);
687
688 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
689 } else {
690 auto [_first_verified, _second_verified, new_accumulator] =
691 native_verifier.verify_folding_proof(verifier_inst, queue_entry.proof);
692 native_verifier_accum = std::move(new_accumulator);
693
694 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
695 info("Sumcheck: batch two accumulators verified: ", _second_verified ? "true" : "false");
696
697 if (queue_entry.type == QUEUE_TYPE::HN_FINAL) {
698 HypernovaDeciderVerifier<MegaFlavor> decider_verifier(verifier_transcript);
699 bb::PairingPoints<curve::BN254> pairing_points =
701
702 info("Decider: pairing points verified? ", pairing_points.check() ? "true" : "false");
703 }
704 }
705
706 info("Chonk accumulate: prover and verifier accumulators match: ",
708
709 // Update the native verifier accumulator hash if we are accumulating an app (i.e. the previous circuit was a
710 // kernel) or if the last app has been accumulated (i.e. the current circuit is the tail kernel)
711 bool update_verifier_accum_hash = is_previous_circuit_a_kernel || has_last_app_been_accumulated;
712 if (update_verifier_accum_hash) {
713 native_verifier_accum_hash = native_verifier_accum.hash_with_origin_tagging(*verifier_transcript);
714 info("Chonk accumulate: hash of verifier accumulator computed natively set in previous kernel IO: ",
716 }
719
720 info("======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
721}
722
724 const std::shared_ptr<ProverInstance>& prover_instance,
725 const std::shared_ptr<MegaVerificationKey>& precomputed_vk)
726{
727 info("======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
728
729 info("Accumulating circuit ", num_circuits_accumulated + 1, " of ", num_circuits);
730 info("Is the circuit valid? ", CircuitChecker::check(circuit) ? "true" : "false");
731 info("Did we find a failure? ", circuit.failed() ? "true" : "false");
732 if (circuit.failed()) {
733 info("\t\t\tError message? ", circuit.err());
734 }
735
736 // Compare precomputed VK with the one generated during accumulation
737 auto vk = std::make_shared<MegaVerificationKey>(prover_instance->get_precomputed());
738 info("Does the precomputed vk match with the one generated during accumulation? ",
739 vk->compare(*precomputed_vk, MegaFlavor::CommitmentLabels().get_precomputed()) ? "true" : "false");
740
741 info("======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
742}
743#endif
744
745} // 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:43
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:666
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
Definition chonk.cpp:297
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:481
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:444
Chonk(size_t num_circuits)
Definition chonk.cpp:27
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:674
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:607
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:723
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:416
ChonkProof prove()
Construct Chonk proof using the batched MegaZK + Translator protocol.
Definition chonk.cpp:626
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:147
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:230
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:573
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:87
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:169
bool app_return_data_slots_are_empty() const
Whether all app return-data slots are currently empty.
Definition databus.hpp:124
Commitment get_app_return_data_commitment(Builder &builder, const size_t idx)
Get the previously set app return data commitment if it exists, else a default one.
Definition databus.hpp:182
void set_app_return_data_commitment(const Commitment &commitment)
Record an app return-data commitment in the next available slot.
Definition databus.hpp:141
void set_kernel_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:112
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)