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
19
20namespace bb {
21
22// Constructor
23Chonk::Chonk(size_t num_circuits)
24 : num_circuits(num_circuits)
25{
26 BB_ASSERT_GT(num_circuits, 0UL, "Number of circuits must be specified and greater than 0.");
27}
28
40 const std::vector<std::shared_ptr<RecursiveVKAndHash>>& input_keys)
41{
42 bool vkeys_provided = !input_keys.empty();
43 if (vkeys_provided) {
45 input_keys.size(),
46 "Incorrect number of verification keys provided in "
47 "stdlib verification queue instantiation.");
48 }
49
50 size_t key_idx = 0;
51 while (!verification_queue.empty()) {
52 const VerifierInputs& entry = verification_queue.front();
53
54 // Construct stdlib proof directly from the internal native queue data
55 StdlibProof stdlib_proof(circuit, entry.proof);
56
57 // Use the provided stdlib vkey if present, otherwise construct one from the internal native queue
58 std::shared_ptr<RecursiveVKAndHash> stdlib_vk_and_hash;
59 if (vkeys_provided) {
60 stdlib_vk_and_hash = input_keys[key_idx++];
61 } else {
62 stdlib_vk_and_hash = std::make_shared<RecursiveVKAndHash>(circuit, entry.honk_vk);
63 }
64
65 stdlib_verification_queue.emplace_back(stdlib_proof, stdlib_vk_and_hash, entry.type, entry.is_kernel);
66
67 verification_queue.pop_front(); // the native data is not needed beyond this point
68 }
69}
70
93 ClientCircuit& circuit,
94 const StdlibVerifierInputs& verifier_inputs,
95 const std::optional<RecursiveVerifierAccumulator>& input_verifier_accumulator,
96 const TableCommitments& T_prev_commitments,
97 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript)
98{
100
101 // PairingPoints to be returned for aggregation
102 std::vector<PairingPoints> pairing_points;
103
104 // Input commitments to be passed to the merge recursive verification
105 MergeCommitments merge_commitments{ .T_prev_commitments = T_prev_commitments };
106
107 auto verifier_instance = std::make_shared<RecursiveVerifierInstance>(verifier_inputs.honk_vk_and_hash);
108
109 std::optional<RecursiveVerifierAccumulator> output_verifier_accumulator;
110 std::optional<StdlibFF> prev_accum_hash = std::nullopt;
111
112 // Update previous accumulator hash so that we can check it against the one extracted from the public inputs
113 if (verifier_inputs.is_kernel) {
114 prev_accum_hash = input_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
115 }
116
117 RecursiveFoldingVerifier folding_verifier(accumulation_recursive_transcript);
118 switch (verifier_inputs.type) {
119 case QUEUE_TYPE::OINK: {
120 vinfo("Recursively verifying accumulation of the first app circuit.");
121 BB_ASSERT_EQ(input_verifier_accumulator.has_value(), false);
122
123 auto [_, new_verifier_accumulator] =
124 folding_verifier.instance_to_accumulator(verifier_instance, verifier_inputs.proof);
125 output_verifier_accumulator = std::move(new_verifier_accumulator);
126
127 // T_prev = 0 in the first recursive verification
128 merge_commitments.T_prev_commitments = stdlib::recursion::honk::empty_ecc_op_tables(circuit);
129 break;
130 }
131 case QUEUE_TYPE::HN:
132 case QUEUE_TYPE::HN_TAIL: {
133 vinfo("Recursively verifying inner accumulation.");
134 auto [_first_verified, _second_verified, new_verifier_accumulator] =
135 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
136 output_verifier_accumulator = std::move(new_verifier_accumulator);
137 break;
138 }
140 vinfo("Recursively verifying accumulation of the tail kernel.");
141 BB_ASSERT_EQ(stdlib_verification_queue.size(), size_t(1));
142
143 auto [_first_verified, _second_verified, final_verifier_accumulator] =
144 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
145
146 RecursiveDeciderVerifier decider_verifier(accumulation_recursive_transcript);
147 StdlibProof stdlib_decider_proof(circuit, decider_proof);
148 pairing_points.emplace_back(decider_verifier.verify_proof(final_verifier_accumulator, stdlib_decider_proof));
149
150 BB_ASSERT_EQ(output_verifier_accumulator.has_value(), false);
151 break;
152 }
153 default: {
154 throw_or_abort("Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
155 }
156 }
157
158 // Extract the witness commitments and public inputs from the incoming verifier instance
159 WitnessCommitments witness_commitments = std::move(verifier_instance->witness_commitments);
160 std::vector<StdlibFF> public_inputs = std::move(verifier_instance->public_inputs);
161
162 if (verifier_inputs.is_kernel) {
163 // Reconstruct the input from the previous kernel from its public inputs
164 KernelIO kernel_input; // pairing points, databus return data commitments
165 kernel_input.reconstruct_from_public(public_inputs);
166 // Add pairing points for aggregation
167 pairing_points.emplace_back(kernel_input.pairing_inputs);
168 // Perform databus consistency checks
169 bool kernel_return_data_match =
170 kernel_input.kernel_return_data.get_value() == witness_commitments.calldata.get_value();
171 BB_ASSERT_DEBUG(kernel_return_data_match,
172 "kernel_return_data mismatch: proof contains " << kernel_input.kernel_return_data.get_value()
173 << " but calldata commitment is "
174 << witness_commitments.calldata.get_value());
175 kernel_input.kernel_return_data.incomplete_assert_equal(witness_commitments.calldata);
176
177 bool app_return_data_match =
178 kernel_input.app_return_data.get_value() == witness_commitments.secondary_calldata.get_value();
179 BB_ASSERT_DEBUG(app_return_data_match,
180 "app_return_data mismatch: proof contains "
181 << kernel_input.app_return_data.get_value() << " but secondary_calldata commitment is "
182 << witness_commitments.secondary_calldata.get_value());
183 kernel_input.app_return_data.incomplete_assert_equal(witness_commitments.secondary_calldata);
184
185 // T_prev is read by the public input of the previous kernel K_{i-1} at the beginning of the recursive
186 // verification of of the folding of K_{i-1} (kernel), A_{i} (app). This verification happens in K_{i}
187 merge_commitments.T_prev_commitments = std::move(kernel_input.ecc_op_tables);
188
189 BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::HN || verifier_inputs.type == QUEUE_TYPE::HN_TAIL ||
190 verifier_inputs.type == QUEUE_TYPE::HN_FINAL,
191 true,
192 "Kernel circuits should be folded.");
193 // Get the previous accum hash
194 info("Accumulator hash from IO: ", kernel_input.output_hn_accum_hash);
195 BB_ASSERT(prev_accum_hash.has_value());
196 bool accum_hash_match = kernel_input.output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
197 BB_ASSERT_DEBUG(accum_hash_match,
198 "output_hn_accum_hash mismatch: proof contains "
199 << kernel_input.output_hn_accum_hash.get_value() << " but expected "
200 << prev_accum_hash->get_value());
201 kernel_input.output_hn_accum_hash.assert_equal(*prev_accum_hash);
202
203 // Set the kernel return data commitment to be propagated via the public inputs
204 bus_depot.set_kernel_return_data_commitment(witness_commitments.return_data);
205 } else {
206 // Reconstruct the input from the previous app from its public inputs
207 AppIO app_input; // pairing points
208 app_input.reconstruct_from_public(public_inputs);
209 // Add pairing points for aggregation
210 pairing_points.emplace_back(app_input.pairing_inputs);
211
212 // Set the app return data commitment to be propagated via the public inputs
213 bus_depot.set_app_return_data_commitment(witness_commitments.return_data);
214 }
215
216 // Extract the commitments to the subtable corresponding to the incoming circuit
217 merge_commitments.t_commitments = witness_commitments.get_ecc_op_wires().get_copy();
218
219 // Recursively verify the corresponding merge proof
220 auto [merge_pairing_points, merged_table_commitments] =
221 goblin.recursively_verify_merge(circuit, merge_commitments, accumulation_recursive_transcript);
222 pairing_points.emplace_back(merge_pairing_points);
223
224 return { output_verifier_accumulator, pairing_points, merged_table_commitments };
225}
226
241{
242 // Step 1: SETUP - Initialize state and determine kernel type
243
244 // Transcript is shared across recursive verification of the folding of K_{i-1} (kernel) and A_{i} (app)
245 auto accumulation_recursive_transcript = std::make_shared<RecursiveTranscript>();
246
247 // T_prev: commitment to previous merged table, propagated via public inputs
248 TableCommitments T_prev_commitments;
249
250 // Convert native verification queue to circuit witnesses
251 if (stdlib_verification_queue.empty()) {
253 }
254
255 // Determine kernel type from queue contents
256 bool is_init_kernel =
258
259 bool is_tail_kernel =
261
262 bool is_hiding_kernel =
264
265 // For ZK: Tail kernel adds masking at op queue start
266 // The ECC-op subtable for a kernel begins with an eq-and-reset to ensure that the preceeding circuit's subtable
267 // cannot affect the ECC-op accumulator for the kernel. For the tail kernel, we additionally add a preceeding no-op
268 // to ensure the op queue wires in translator are shiftable, i.e. their 0th coefficient is 0. (The tail kernel
269 // subtable is at the top of the final aggregate table since it is the last to be prepended).
270 if (is_tail_kernel) {
271 BB_ASSERT_EQ(circuit.op_queue->get_current_subtable_size(),
272 0U,
273 "tail kernel ecc ops table should be empty at this point");
274 circuit.queue_ecc_no_op();
275 // Add randomness at the begining of the tail kernel (whose ecc ops fall at the beginning of the op queue table)
276 // to ensure the CHONK proof doesn't leak information about the actual content of the op queue
278
279 // Add the hiding op with random (non-curve) Px, Py values for statistical hiding of accumulated_result.
281 }
282 circuit.queue_ecc_eq();
283
284 // Step 2: VERIFICATION LOOP - Recursively verify each proof in the queue
285
286 std::vector<PairingPoints> points_accumulator;
287 std::optional<RecursiveVerifierAccumulator> current_stdlib_verifier_accumulator;
288 if (!is_init_kernel) {
289 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
291 }
292 while (!stdlib_verification_queue.empty()) {
293 const StdlibVerifierInputs& verifier_input = stdlib_verification_queue.front();
294
295 auto [output_stdlib_verifier_accumulator, pairing_points, merged_table_commitments] =
297 verifier_input,
298 current_stdlib_verifier_accumulator,
299 T_prev_commitments,
300 accumulation_recursive_transcript);
301 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
302 // Update commitment to the status of the op_queue
303 T_prev_commitments = merged_table_commitments;
304 // Update the output verifier accumulator
305 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
306
307 stdlib_verification_queue.pop_front();
308 }
309
310 // Step 3: OUTPUT - Set public inputs for propagation to next kernel
311
312 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
313
314 // Output differs based on kernel type: HidingKernelIO (no accum hash) vs KernelIO (with accum hash)
315 if (is_hiding_kernel) {
316 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(), false);
317 // Add randomness at the end of the hiding kernel (whose ecc ops fall right at the end of the op queue table) to
318 // ensure the Chonk proof doesn't leak information about the actual content of the op queue
320
321 HidingKernelIO hiding_output{ pairing_points_aggregator,
323 T_prev_commitments };
324 hiding_output.set_public();
325 } else {
326 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(), false);
327 // Extract native verifier accumulator from the stdlib accum to use it in the next round
328 recursive_verifier_native_accum = current_stdlib_verifier_accumulator->get_value<VerifierAccumulator>();
329
330 KernelIO kernel_output;
331 kernel_output.pairing_inputs = pairing_points_aggregator;
332 kernel_output.kernel_return_data = bus_depot.get_kernel_return_data_commitment(circuit);
333 kernel_output.app_return_data = bus_depot.get_app_return_data_commitment(circuit);
334 kernel_output.ecc_op_tables = T_prev_commitments;
335 RecursiveTranscript hash_transcript;
336 kernel_output.output_hn_accum_hash =
337 current_stdlib_verifier_accumulator->hash_with_origin_tagging(hash_transcript);
338 info("Kernel output accumulator hash: ", kernel_output.output_hn_accum_hash);
339#ifndef NDEBUG
340 info("Chonk recursive verification: accumulator hash set in the public inputs matches the one "
341 "computed natively: ",
342 kernel_output.output_hn_accum_hash.get_value() == native_verifier_accum_hash ? "true" : "false");
343#endif
344 kernel_output.set_public();
345 }
346}
347
352{
353 // first app
354 if (num_circuits_accumulated == 0) {
355 return QUEUE_TYPE::OINK;
356 }
357 // app (excluding first) or kernel (inner or reset)
359 return QUEUE_TYPE::HN;
360 }
361 // last kernel prior to tail kernel
363 return QUEUE_TYPE::HN_TAIL;
364 }
365 // tail kernel
368 }
369 // hiding kernel
371 return QUEUE_TYPE::MEGA;
372 }
373 return QUEUE_TYPE{};
374}
375
392{
394 num_circuits_accumulated, num_circuits, "Chonk: Attempting to accumulate more circuits than expected.");
395
396 BB_ASSERT(precomputed_vk != nullptr, "Chonk::accumulate - VK expected for the provided circuit");
397
398 QUEUE_TYPE queue_type = get_queue_type();
399
400 std::shared_ptr<ProverInstance> prover_instance;
401
402#ifndef NDEBUG
403 prover_instance = std::make_shared<ProverInstance>(circuit);
404 debug_incoming_circuit(circuit, prover_instance, precomputed_vk);
405#endif
406
407 // For the hiding kernel (MEGA), skip straight to the ZK prover — no non-ZK ProverInstance needed.
408 if (queue_type == QUEUE_TYPE::MEGA) {
409 vinfo("Generating proof for hiding kernel");
410 HonkProof proof = construct_honk_proof_for_hiding_kernel(circuit, precomputed_vk);
411 VerifierInputs queue_entry{ std::move(proof), precomputed_vk, queue_type, /*is_kernel=*/true };
412 verification_queue.push_back(queue_entry);
414 return;
415 }
416
417 // Construct the prover instance for circuit (may already exist from debug path above)
418 if (!prover_instance) {
419 prover_instance = std::make_shared<ProverInstance>(circuit);
420 }
421
422 // Free circuit block memory (wires and selectors) now that they've been copied to prover polynomials
423 for (auto& block : circuit.blocks.get()) {
424 block.free_data();
425 }
426
427 // We're accumulating a kernel if the verification queue is empty (because the kernel circuit contains recursive
428 // verifiers for all the entries previously present in the verification queue) and if it's not the first accumulate
429 // call (which will always be for an app circuit).
430 bool is_kernel = verification_queue.empty() && num_circuits_accumulated > 0;
431
432 // Transcript to be shared across folding of K_{i} (kernel) (the current kernel), A_{i+1,1} (app), .., A_{i+1,
433 // n} (app)
434 if (is_kernel) {
436 }
437
438#ifndef NDEBUG
439 // Make a copy of the prover_accumulation_transcript for the native verifier to use, only happens in debugging
440 // builds
441 auto verifier_transcript =
443#endif
444
446 HonkProof proof;
447 switch (queue_type) {
448 case QUEUE_TYPE::OINK:
449 vinfo("Accumulating first app circuit");
450 BB_ASSERT_EQ(is_kernel, false, "First circuit accumulated must always be an app");
451
452 prover_accumulator = prover.instance_to_accumulator(prover_instance, precomputed_vk);
453 proof = prover.export_proof();
454 break;
455 case QUEUE_TYPE::HN:
457 vinfo("Accumulating circuit number ", num_circuits_accumulated + 1);
458 // Move old accumulator into fold, receive new accumulator back
459 std::tie(proof, prover_accumulator) =
460 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
461 break;
463 vinfo("Accumulating tail kernel");
464 // Move old accumulator into fold, receive new accumulator back
465 std::tie(proof, prover_accumulator) =
466 prover.fold(std::move(prover_accumulator), prover_instance, precomputed_vk);
467 // Decider uses the NEW prover_accumulator (result of fold)
470 break;
471 }
472 default:
473 BB_ASSERT(false, "Unexpected queue type");
474 break;
475 }
476
477 VerifierInputs queue_entry{ std::move(proof), precomputed_vk, queue_type, is_kernel };
478 verification_queue.push_back(queue_entry);
479
480 // Construct merge proof (MEGA/hiding kernel is handled in the early return above)
481#ifndef NDEBUG
482 update_native_verifier_accumulator(queue_entry, verifier_transcript);
483#endif
485
487}
488
499{
500 // Use random Fq field elements as Px and Py.
501 using Fq = curve::Grumpkin::ScalarField; // Same as BN254::BaseField
503}
504
511{
512 circuit.queue_ecc_random_op();
513 circuit.queue_ecc_random_op();
514 circuit.queue_ecc_random_op();
515}
516
527
533 const std::shared_ptr<MegaVerificationKey>& verification_key)
534{
535 auto hiding_prover_inst = std::make_shared<DeciderZKProvingKey>(circuit);
536
537 // Free circuit block memory now that trace data has been copied to prover polynomials
538 for (auto& block : circuit.blocks.get()) {
539 block.free_data();
540 }
541
542 // Hiding kernel is proven by a MegaZKProver
543 MegaZKProver prover(hiding_prover_inst, verification_key, transcript);
544 HonkProof proof = prover.construct_proof();
545
546 return proof;
547}
548
555{
556 // deallocate the accumulator
558 auto mega_proof = verification_queue.front().proof;
559
560 // A transcript is shared between the Hiding kernel prover and the Goblin prover
562
563 // Returns a proof for the Hiding kernel and the Goblin proof. The latter consists of Translator and ECCVM proof
564 // for the whole ecc op table and the merge proof for appending the subtable coming from the Hiding kernel. The
565 // final merging is done via appending to facilitate creating a zero-knowledge merge proof. This enables us to add
566 // randomness to the beginning of the tail kernel and the end of the hiding kernel, hiding the commitments and
567 // evaluations of both the previous table and the incoming subtable.
568 return ChonkProof{ mega_proof, goblin.prove() };
569};
570
572{
573 BB_ASSERT_EQ(verification_queue.size(), 1UL, "Expected single hiding kernel VK in queue");
574 BB_ASSERT(verification_queue.front().type == QUEUE_TYPE::MEGA, "Expected MEGA proof type");
576}
577
578#ifndef NDEBUG
580 const std::shared_ptr<Transcript>& verifier_transcript)
581{
582 info("======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
583
584 auto verifier_inst =
586
587 FoldingVerifier native_verifier(verifier_transcript);
588 if (queue_entry.type == QUEUE_TYPE::OINK) {
589 auto [_first_verified, new_accumulator] =
590 native_verifier.instance_to_accumulator(verifier_inst, queue_entry.proof);
591 native_verifier_accum = std::move(new_accumulator);
592
593 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
594 } else {
595 auto [_first_verified, _second_verified, new_accumulator] =
596 native_verifier.verify_folding_proof(verifier_inst, queue_entry.proof);
597 native_verifier_accum = std::move(new_accumulator);
598
599 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
600 info("Sumcheck: batch two accumulators verified: ", _second_verified ? "true" : "false");
601
602 if (queue_entry.type == QUEUE_TYPE::HN_FINAL) {
603 HypernovaDeciderVerifier<MegaFlavor> decider_verifier(verifier_transcript);
604 bb::PairingPoints<curve::BN254> pairing_points =
606
607 info("Decider: pairing points verified? ", pairing_points.check() ? "true" : "false");
608 }
609 }
610
611 info("Chonk accumulate: prover and verifier accumulators match: ",
613
614 // Update the native verifier accumulator hash if we are accumulating an app (i.e. the previous circuit was a
615 // kernel) or if the last app has been accumulated (i.e. the current circuit is the tail kernel)
616 bool update_verifier_accum_hash = is_previous_circuit_a_kernel || has_last_app_been_accumulated;
617 if (update_verifier_accum_hash) {
618 native_verifier_accum_hash = native_verifier_accum.hash_with_origin_tagging(*verifier_transcript);
619 info("Chonk accumulate: hash of verifier accumulator computed natively set in previous kernel IO: ",
621 }
624
625 info("======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
626}
627
629 const std::shared_ptr<ProverInstance>& prover_instance,
630 const std::shared_ptr<MegaVerificationKey>& precomputed_vk)
631{
632 info("======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
633
634 info("Accumulating circuit ", num_circuits_accumulated + 1, " of ", num_circuits);
635 info("Is the circuit valid? ", CircuitChecker::check(circuit) ? "true" : "false");
636 info("Did we find a failure? ", circuit.failed() ? "true" : "false");
637 if (circuit.failed()) {
638 info("\t\t\tError message? ", circuit.err());
639 }
640
641 // Compare precomputed VK with the one generated during accumulation
642 auto vk = std::make_shared<MegaVerificationKey>(prover_instance->get_precomputed());
643 info("Does the precomputed vk match with the one generated during accumulation? ",
644 vk->compare(*precomputed_vk, MegaFlavor::CommitmentLabels().get_precomputed()) ? "true" : "false");
645
646 info("======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
647}
648#endif
649
650} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:70
#define BB_ASSERT_GT(left, right,...)
Definition assert.hpp:113
#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
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.
ProverAccumulator prover_accumulator
Definition chonk.hpp:147
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:39
HonkProof construct_honk_proof_for_hiding_kernel(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &verification_key)
Construct a zero-knowledge proof for the Hiding kernel, which recursively verifies the last folding,...
Definition chonk.cpp:532
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:571
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
Definition chonk.cpp:240
std::tuple< std::optional< RecursiveVerifierAccumulator >, std::vector< PairingPoints >, TableCommitments > perform_recursive_verification_and_databus_consistency_checks(ClientCircuit &circuit, const StdlibVerifierInputs &verifier_inputs, const std::optional< RecursiveVerifierAccumulator > &input_verifier_accumulator, const TableCommitments &T_prev_commitments, const std::shared_ptr< RecursiveTranscript > &accumulation_recursive_transcript)
Populate the provided circuit with constraints for (1) recursive verification of the provided accumul...
Definition chonk.cpp:92
VerifierAccumulator native_verifier_accum
Definition chonk.hpp:153
Chonk(size_t num_circuits)
Definition chonk.cpp:23
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:579
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:522
std::array< RecursiveFlavor::Commitment, ClientCircuit::NUM_WIRES > TableCommitments
Definition chonk.hpp:72
DataBusDepot bus_depot
Definition chonk.hpp:167
std::shared_ptr< Transcript > transcript
Definition chonk.hpp:138
size_t num_circuits_accumulated
Definition chonk.hpp:145
void debug_incoming_circuit(ClientCircuit &circuit, const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
Definition chonk.cpp:628
HonkProof decider_proof
Definition chonk.hpp:149
FF native_verifier_accum_hash
Definition chonk.hpp:154
QUEUE_TYPE
Proof type determining recursive verification logic in kernel circuits.
Definition chonk.hpp:105
bool has_last_app_been_accumulated
Definition chonk.hpp:156
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:351
static void hide_op_queue_content_in_tail(ClientCircuit &circuit)
Adds three random non-ops to the tail kernel for zero-knowledge.
Definition chonk.cpp:510
ChonkProof prove()
Construct Chonk proof, which, if verified, fully establishes the correctness of RCG.
Definition chonk.cpp:554
FoldingProver::Accumulator ProverAccumulator
Definition chonk.hpp:79
VerifierAccumulator recursive_verifier_native_accum
Definition chonk.hpp:151
bool is_previous_circuit_a_kernel
Definition chonk.hpp:155
static void hide_op_queue_accumulation_result(ClientCircuit &circuit)
Add a hiding op with fully random Px, Py field elements to prevent information leakage in Translator ...
Definition chonk.cpp:498
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:391
size_t num_circuits
Definition chonk.hpp:143
VerificationQueue verification_queue
Definition chonk.hpp:163
Goblin goblin
Definition chonk.hpp:169
std::shared_ptr< Transcript > prover_accumulation_transcript
Definition chonk.hpp:141
StdlibVerificationQueue stdlib_verification_queue
Definition chonk.hpp:164
const std::string & err() const
std::pair< PairingPoints, RecursiveTableCommitments > recursively_verify_merge(MegaBuilder &builder, const RecursiveMergeCommitments &merge_commitments, const std::shared_ptr< RecursiveTranscript > &transcript, const MergeSettings merge_settings=MergeSettings::PREPEND)
Recursively verify the next merge proof in the merge verification queue.
Definition goblin.cpp:90
GoblinProof prove()
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:61
void prove_merge(const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >(), const MergeSettings merge_settings=MergeSettings::PREPEND)
Construct a merge proof for the goblin ECC ops in the provided circuit; append the proof to the merge...
Definition goblin.cpp:28
std::shared_ptr< Transcript > transcript
Definition goblin.hpp:60
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...
std::shared_ptr< ECCOpQueue > op_queue
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...
ecc_op_tuple queue_ecc_no_op()
Logic for a no-op operation.
void queue_ecc_hiding_op(const curve::BN254::BaseField &Px, const curve::BN254::BaseField &Py)
Add a hiding op with random (possibly non-curve) Px, Py values to the op queue and circuit.
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.
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:106
void set_kernel_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:100
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
std::array< typename bn254< Builder >::Group, Builder::NUM_WIRES > empty_ecc_op_tables(Builder &builder)
Construct commitments to empty subtables.
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:119
std::shared_ptr< MegaVerificationKey > honk_vk
Definition chonk.hpp:110
std::vector< FF > proof
Definition chonk.hpp:109
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.
static field random_element(numeric::RNG *engine=nullptr) noexcept
An object storing two EC points that represent the inputs to a pairing check.
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)