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 , goblin(bn254_commitment_key)
26{
27 BB_ASSERT_GT(num_circuits, 0UL, "Number of circuits must be specified and greater than 0.");
28 // Allocate BN254 commitment key based on translator circuit size.
29 // https://github.com/AztecProtocol/barretenberg/issues/1319): Account for Translator only when it's necessary
30 size_t commitment_key_size = 1UL << TranslatorFlavor::CONST_TRANSLATOR_LOG_N;
31 info("BN254 commitment key size: ", commitment_key_size);
33}
34
46 const std::vector<std::shared_ptr<RecursiveVKAndHash>>& input_keys)
47{
48 bool vkeys_provided = !input_keys.empty();
49 if (vkeys_provided) {
51 input_keys.size(),
52 "Incorrect number of verification keys provided in "
53 "stdlib verification queue instantiation.");
54 }
55
56 size_t key_idx = 0;
57 while (!verification_queue.empty()) {
58 const VerifierInputs& entry = verification_queue.front();
59
60 // Construct stdlib proof directly from the internal native queue data
61 StdlibProof stdlib_proof(circuit, entry.proof);
62
63 // Use the provided stdlib vkey if present, otherwise construct one from the internal native queue
64 std::shared_ptr<RecursiveVKAndHash> stdlib_vk_and_hash;
65 if (vkeys_provided) {
66 stdlib_vk_and_hash = input_keys[key_idx++];
67 } else {
68 stdlib_vk_and_hash = std::make_shared<RecursiveVKAndHash>(circuit, entry.honk_vk);
69 }
70
71 stdlib_verification_queue.emplace_back(stdlib_proof, stdlib_vk_and_hash, entry.type, entry.is_kernel);
72
73 verification_queue.pop_front(); // the native data is not needed beyond this point
74 }
75}
76
99 ClientCircuit& circuit,
100 const StdlibVerifierInputs& verifier_inputs,
101 const std::optional<RecursiveVerifierAccumulator>& input_verifier_accumulator,
102 const TableCommitments& T_prev_commitments,
103 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript)
104{
106
107 // PairingPoints to be returned for aggregation
108 std::vector<PairingPoints> pairing_points;
109
110 // Input commitments to be passed to the merge recursive verification
111 MergeCommitments merge_commitments{ .T_prev_commitments = T_prev_commitments };
112
113 auto verifier_instance = std::make_shared<RecursiveVerifierInstance>(verifier_inputs.honk_vk_and_hash);
114
115 std::optional<RecursiveVerifierAccumulator> output_verifier_accumulator;
116 std::optional<StdlibFF> prev_accum_hash = std::nullopt;
117
118 // Update previous accumulator hash so that we can check it against the one extracted from the public inputs
119 if (verifier_inputs.is_kernel) {
120 prev_accum_hash = input_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
121 }
122
123 RecursiveFoldingVerifier folding_verifier(accumulation_recursive_transcript);
124 switch (verifier_inputs.type) {
125 case QUEUE_TYPE::OINK: {
126 vinfo("Recursively verifying accumulation of the first app circuit.");
127 BB_ASSERT_EQ(input_verifier_accumulator.has_value(), false);
128
129 auto [_, new_verifier_accumulator] =
130 folding_verifier.instance_to_accumulator(verifier_instance, verifier_inputs.proof);
131 output_verifier_accumulator = std::move(new_verifier_accumulator);
132
133 // T_prev = 0 in the first recursive verification
134 merge_commitments.T_prev_commitments = stdlib::recursion::honk::empty_ecc_op_tables(circuit);
135 break;
136 }
137 case QUEUE_TYPE::HN:
138 case QUEUE_TYPE::HN_TAIL: {
139 vinfo("Recursively verifying inner accumulation.");
140 auto [_first_verified, _second_verified, new_verifier_accumulator] =
141 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
142 output_verifier_accumulator = std::move(new_verifier_accumulator);
143 break;
144 }
146 vinfo("Recursively verifying accumulation of the tail kernel.");
147 BB_ASSERT_EQ(stdlib_verification_queue.size(), size_t(1));
148
149 auto [_first_verified, _second_verified, final_verifier_accumulator] =
150 folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof);
151
152 RecursiveDeciderVerifier decider_verifier(accumulation_recursive_transcript);
153 StdlibProof stdlib_decider_proof(circuit, decider_proof);
154 pairing_points.emplace_back(decider_verifier.verify_proof(final_verifier_accumulator, stdlib_decider_proof));
155
156 BB_ASSERT_EQ(output_verifier_accumulator.has_value(), false);
157 break;
158 }
159 default: {
160 throw_or_abort("Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
161 }
162 }
163
164 // Extract the witness commitments and public inputs from the incoming verifier instance
165 WitnessCommitments witness_commitments = std::move(verifier_instance->witness_commitments);
166 std::vector<StdlibFF> public_inputs = std::move(verifier_instance->public_inputs);
167
168 if (verifier_inputs.is_kernel) {
169 // Reconstruct the input from the previous kernel from its public inputs
170 KernelIO kernel_input; // pairing points, databus return data commitments
171 kernel_input.reconstruct_from_public(public_inputs);
172 // Add pairing points for aggregation
173 pairing_points.emplace_back(kernel_input.pairing_inputs);
174 // Perform databus consistency checks
175 bool kernel_return_data_match =
176 kernel_input.kernel_return_data.get_value() == witness_commitments.calldata.get_value();
177 BB_ASSERT_DEBUG(kernel_return_data_match,
178 "kernel_return_data mismatch: proof contains " << kernel_input.kernel_return_data.get_value()
179 << " but calldata commitment is "
180 << witness_commitments.calldata.get_value());
181 kernel_input.kernel_return_data.incomplete_assert_equal(witness_commitments.calldata);
182
183 bool app_return_data_match =
184 kernel_input.app_return_data.get_value() == witness_commitments.secondary_calldata.get_value();
185 BB_ASSERT_DEBUG(app_return_data_match,
186 "app_return_data mismatch: proof contains "
187 << kernel_input.app_return_data.get_value() << " but secondary_calldata commitment is "
188 << witness_commitments.secondary_calldata.get_value());
189 kernel_input.app_return_data.incomplete_assert_equal(witness_commitments.secondary_calldata);
190
191 // T_prev is read by the public input of the previous kernel K_{i-1} at the beginning of the recursive
192 // verification of of the folding of K_{i-1} (kernel), A_{i} (app). This verification happens in K_{i}
193 merge_commitments.T_prev_commitments = std::move(kernel_input.ecc_op_tables);
194
195 BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::HN || verifier_inputs.type == QUEUE_TYPE::HN_TAIL ||
196 verifier_inputs.type == QUEUE_TYPE::HN_FINAL,
197 true,
198 "Kernel circuits should be folded.");
199 // Get the previous accum hash
200 info("Accumulator hash from IO: ", kernel_input.output_hn_accum_hash);
201 BB_ASSERT(prev_accum_hash.has_value());
202 bool accum_hash_match = kernel_input.output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
203 BB_ASSERT_DEBUG(accum_hash_match,
204 "output_hn_accum_hash mismatch: proof contains "
205 << kernel_input.output_hn_accum_hash.get_value() << " but expected "
206 << prev_accum_hash->get_value());
207 kernel_input.output_hn_accum_hash.assert_equal(*prev_accum_hash);
208
209 // Set the kernel return data commitment to be propagated via the public inputs
210 bus_depot.set_kernel_return_data_commitment(witness_commitments.return_data);
211 } else {
212 // Reconstruct the input from the previous app from its public inputs
213 AppIO app_input; // pairing points
214 app_input.reconstruct_from_public(public_inputs);
215 // Add pairing points for aggregation
216 pairing_points.emplace_back(app_input.pairing_inputs);
217
218 // Set the app return data commitment to be propagated via the public inputs
219 bus_depot.set_app_return_data_commitment(witness_commitments.return_data);
220 }
221
222 // Extract the commitments to the subtable corresponding to the incoming circuit
223 merge_commitments.t_commitments = witness_commitments.get_ecc_op_wires().get_copy();
224
225 // Recursively verify the corresponding merge proof
226 auto [merge_pairing_points, merged_table_commitments] =
227 goblin.recursively_verify_merge(circuit, merge_commitments, accumulation_recursive_transcript);
228 pairing_points.emplace_back(merge_pairing_points);
229
230 return { output_verifier_accumulator, pairing_points, merged_table_commitments };
231}
232
247{
248 // Step 1: SETUP - Initialize state and determine kernel type
249
250 // Transcript is shared across recursive verification of the folding of K_{i-1} (kernel) and A_{i} (app)
251 auto accumulation_recursive_transcript = std::make_shared<RecursiveTranscript>();
252
253 // T_prev: commitment to previous merged table, propagated via public inputs
254 TableCommitments T_prev_commitments;
255
256 // Convert native verification queue to circuit witnesses
257 if (stdlib_verification_queue.empty()) {
259 }
260
261 // Determine kernel type from queue contents
262 bool is_init_kernel =
264
265 bool is_tail_kernel =
267
268 bool is_hiding_kernel =
270
271 // For ZK: Tail kernel adds masking at op queue start
272 // The ECC-op subtable for a kernel begins with an eq-and-reset to ensure that the preceeding circuit's subtable
273 // cannot affect the ECC-op accumulator for the kernel. For the tail kernel, we additionally add a preceeding no-op
274 // to ensure the op queue wires in translator are shiftable, i.e. their 0th coefficient is 0. (The tail kernel
275 // subtable is at the top of the final aggregate table since it is the last to be prepended).
276 if (is_tail_kernel) {
277 BB_ASSERT_EQ(circuit.op_queue->get_current_subtable_size(),
278 0U,
279 "tail kernel ecc ops table should be empty at this point");
280 circuit.queue_ecc_no_op();
281 // Add randomness at the begining of the tail kernel (whose ecc ops fall at the beginning of the op queue table)
282 // to ensure the CHONK proof doesn't leak information about the actual content of the op queue
284
285 // Add the hiding op with random (non-curve) Px, Py values for statistical hiding of accumulated_result.
287 }
288 circuit.queue_ecc_eq();
289
290 // Step 2: VERIFICATION LOOP - Recursively verify each proof in the queue
291
292 std::vector<PairingPoints> points_accumulator;
293 std::optional<RecursiveVerifierAccumulator> current_stdlib_verifier_accumulator;
294 if (!is_init_kernel) {
295 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
297 }
298 while (!stdlib_verification_queue.empty()) {
299 const StdlibVerifierInputs& verifier_input = stdlib_verification_queue.front();
300
301 auto [output_stdlib_verifier_accumulator, pairing_points, merged_table_commitments] =
303 verifier_input,
304 current_stdlib_verifier_accumulator,
305 T_prev_commitments,
306 accumulation_recursive_transcript);
307 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
308 // Update commitment to the status of the op_queue
309 T_prev_commitments = merged_table_commitments;
310 // Update the output verifier accumulator
311 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
312
313 stdlib_verification_queue.pop_front();
314 }
315
316 // Step 3: OUTPUT - Set public inputs for propagation to next kernel
317
318 PairingPoints pairing_points_aggregator = PairingPoints::aggregate_multiple(points_accumulator);
319
320 // Output differs based on kernel type: HidingKernelIO (no accum hash) vs KernelIO (with accum hash)
321 if (is_hiding_kernel) {
322 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(), false);
323 // Add randomness at the end of the hiding kernel (whose ecc ops fall right at the end of the op queue table) to
324 // ensure the Chonk proof doesn't leak information about the actual content of the op queue
326
327 HidingKernelIO hiding_output{ pairing_points_aggregator,
329 T_prev_commitments };
330 hiding_output.set_public();
331 } else {
332 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(), false);
333 // Extract native verifier accumulator from the stdlib accum to use it in the next round
334 recursive_verifier_native_accum = current_stdlib_verifier_accumulator->get_value<VerifierAccumulator>();
335
336 KernelIO kernel_output;
337 kernel_output.pairing_inputs = pairing_points_aggregator;
338 kernel_output.kernel_return_data = bus_depot.get_kernel_return_data_commitment(circuit);
339 kernel_output.app_return_data = bus_depot.get_app_return_data_commitment(circuit);
340 kernel_output.ecc_op_tables = T_prev_commitments;
341 RecursiveTranscript hash_transcript;
342 kernel_output.output_hn_accum_hash =
343 current_stdlib_verifier_accumulator->hash_with_origin_tagging(hash_transcript);
344 info("Kernel output accumulator hash: ", kernel_output.output_hn_accum_hash);
345#ifndef NDEBUG
346 info("Chonk recursive verification: accumulator hash set in the public inputs matches the one "
347 "computed natively: ",
348 kernel_output.output_hn_accum_hash.get_value() == native_verifier_accum_hash ? "true" : "false");
349#endif
350 kernel_output.set_public();
351 }
352}
353
358{
359 // first app
360 if (num_circuits_accumulated == 0) {
361 return QUEUE_TYPE::OINK;
362 }
363 // app (excluding first) or kernel (inner or reset)
365 return QUEUE_TYPE::HN;
366 }
367 // last kernel prior to tail kernel
369 return QUEUE_TYPE::HN_TAIL;
370 }
371 // tail kernel
374 }
375 // hiding kernel
377 return QUEUE_TYPE::MEGA;
378 }
379 return QUEUE_TYPE{};
380}
381
398{
400 num_circuits_accumulated, num_circuits, "Chonk: Attempting to accumulate more circuits than expected.");
401
402 BB_ASSERT(precomputed_vk != nullptr, "Chonk::accumulate - VK expected for the provided circuit");
403
404 // Construct the prover instance for circuit
406
407#ifndef NDEBUG
408 debug_incoming_circuit(circuit, prover_instance, precomputed_vk);
409#endif
410
411 // If the current circuit exceeds the current size of the commitment key, reinitialize accordingly.
412 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1319)
413 if (prover_instance->dyadic_size() > bn254_commitment_key.dyadic_size) {
414 bn254_commitment_key = CommitmentKey<curve::BN254>(prover_instance->dyadic_size());
416 }
417 prover_instance->commitment_key = bn254_commitment_key;
418
419 // We're accumulating a kernel if the verification queue is empty (because the kernel circuit contains recursive
420 // verifiers for all the entries previously present in the verification queue) and if it's not the first accumulate
421 // call (which will always be for an app circuit).
422 bool is_kernel = verification_queue.empty() && num_circuits_accumulated > 0;
423
424 // Transcript to be shared across folding of K_{i} (kernel) (the current kernel), A_{i+1,1} (app), .., A_{i+1,
425 // n} (app)
426 if (is_kernel) {
428 }
429
430#ifndef NDEBUG
431 // Make a copy of the prover_accumulation_transcript for the native verifier to use, only happens in debugging
432 // builds
433 auto verifier_transcript =
435#endif
436
437 QUEUE_TYPE queue_type = get_queue_type();
438
440 HonkProof proof;
441 switch (queue_type) {
442 case QUEUE_TYPE::OINK:
443 vinfo("Accumulating first app circuit");
444 BB_ASSERT_EQ(is_kernel, false, "First circuit accumulated must always be an app");
445
446 prover_accumulator = prover.instance_to_accumulator(prover_instance, precomputed_vk);
447 proof = prover.export_proof();
448 break;
449 case QUEUE_TYPE::HN:
451 vinfo("Accumulating circuit number ", num_circuits_accumulated + 1);
452 std::tie(proof, prover_accumulator) = prover.fold(prover_accumulator, prover_instance, precomputed_vk);
453 break;
455 vinfo("Accumulating tail kernel");
456 std::tie(proof, prover_accumulator) = prover.fold(prover_accumulator, prover_instance, precomputed_vk);
459 break;
460 }
461 case QUEUE_TYPE::MEGA:
462 vinfo("Generating proof for hiding kernel");
463 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1555): Method for constructing hiding kernel proof
464 // constructs a new ProverInstance (with ZK Flavor). For now just do a hacky shared ptr deallocation to avoid
465 // double memory for storing two instances.
466 prover_instance.reset();
467 proof = construct_honk_proof_for_hiding_kernel(circuit, precomputed_vk);
468 break;
469 }
470
471 VerifierInputs queue_entry{ std::move(proof), precomputed_vk, queue_type, is_kernel };
472 verification_queue.push_back(queue_entry);
473
474 // Construct merge proof (excluded for hiding kernel since accumulation terminates with
475 // tail kernel and hiding merge proof is constructed as part of goblin proving)
476 if (queue_entry.type != QUEUE_TYPE::MEGA) {
477#ifndef NDEBUG
478 // In debugging builds update native verifier accumulator
479 update_native_verifier_accumulator(queue_entry, verifier_transcript);
480#endif
482 }
483
485}
486
497{
498 // Use random Fq field elements as Px and Py.
499 using Fq = curve::Grumpkin::ScalarField; // Same as BN254::BaseField
500 circuit.queue_ecc_hiding_op(Fq::random_element(), Fq::random_element());
501}
502
509{
510 circuit.queue_ecc_random_op();
511 circuit.queue_ecc_random_op();
512 circuit.queue_ecc_random_op();
513}
514
525
531 const std::shared_ptr<MegaVerificationKey>& verification_key)
532{
533 auto hiding_prover_inst = std::make_shared<DeciderZKProvingKey>(circuit, bn254_commitment_key);
534
535 // Hiding kernel is proven by a MegaZKProver
536 MegaZKProver prover(hiding_prover_inst, verification_key, transcript);
537 HonkProof proof = prover.construct_proof();
538
539 return proof;
540}
541
548{
549 // deallocate the accumulator
551 auto mega_proof = verification_queue.front().proof;
552
553 // A transcript is shared between the Hiding kernel prover and the Goblin prover
555
556 // Returns a proof for the Hiding kernel and the Goblin proof. The latter consists of Translator and ECCVM proof
557 // for the whole ecc op table and the merge proof for appending the subtable coming from the Hiding kernel. The
558 // final merging is done via appending to facilitate creating a zero-knowledge merge proof. This enables us to add
559 // randomness to the beginning of the tail kernel and the end of the hiding kernel, hiding the commitments and
560 // evaluations of both the previous table and the incoming subtable.
561 return ChonkProof{ mega_proof, goblin.prove(MergeSettings::APPEND) };
562};
563
565{
566 BB_ASSERT_EQ(verification_queue.size(), 1UL, "Expected single hiding kernel VK in queue");
567 BB_ASSERT(verification_queue.front().type == QUEUE_TYPE::MEGA, "Expected MEGA proof type");
569}
570
571#ifndef NDEBUG
573 const std::shared_ptr<Transcript>& verifier_transcript)
574{
575 info("======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
576
577 auto verifier_inst =
579
580 FoldingVerifier native_verifier(verifier_transcript);
581 if (queue_entry.type == QUEUE_TYPE::OINK) {
582 auto [_first_verified, new_accumulator] =
583 native_verifier.instance_to_accumulator(verifier_inst, queue_entry.proof);
584 native_verifier_accum = std::move(new_accumulator);
585
586 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
587 } else {
588 auto [_first_verified, _second_verified, new_accumulator] =
589 native_verifier.verify_folding_proof(verifier_inst, queue_entry.proof);
590 native_verifier_accum = std::move(new_accumulator);
591
592 info("Sumcheck: instance to accumulator verified: ", _first_verified ? "true" : "false");
593 info("Sumcheck: batch two accumulators verified: ", _second_verified ? "true" : "false");
594
595 if (queue_entry.type == QUEUE_TYPE::HN_FINAL) {
596 HypernovaDeciderVerifier<MegaFlavor> decider_verifier(verifier_transcript);
597 bb::PairingPoints<curve::BN254> pairing_points =
599
600 info("Decider: pairing points verified? ", pairing_points.check() ? "true" : "false");
601 }
602 }
603
604 if (!queue_entry.is_kernel) {
605 native_verifier_accum_hash = native_verifier_accum.hash_with_origin_tagging(*verifier_transcript);
606 }
607
608 info("Chonk accumulate: prover and verifier accumulators match: ",
610 info("Chonk accumulate: hash of verifier accumulator computed natively ", native_verifier_accum_hash);
611
612 info("======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
613}
614
616 const std::shared_ptr<ProverInstance>& prover_instance,
617 const std::shared_ptr<MegaVerificationKey>& precomputed_vk)
618{
619 info("======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
620
621 info("Accumulating circuit ", num_circuits_accumulated + 1, " of ", num_circuits);
622 info("Is the circuit valid? ", CircuitChecker::check(circuit) ? "true" : "false");
623 info("Did we find a failure? ", circuit.failed() ? "true" : "false");
624 if (circuit.failed()) {
625 info("\t\t\tError message? ", circuit.err());
626 }
627
628 // Compare precomputed VK with the one generated during accumulation
629 auto vk = std::make_shared<MegaVerificationKey>(prover_instance->get_precomputed());
630 info("Does the precomputed vk match with the one generated during accumulation? ",
631 vk->compare(*precomputed_vk, MegaFlavor::CommitmentLabels().get_precomputed()) ? "true" : "false");
632
633 info("======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
634}
635#endif
636
637} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:80
#define BB_ASSERT_GT(left, right,...)
Definition assert.hpp:123
#define BB_ASSERT_DEBUG(expression,...)
Definition assert.hpp:55
#define BB_ASSERT_NEQ(actual, expected,...)
Definition assert.hpp:108
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:93
#define BB_ASSERT_LT(left, right,...)
Definition assert.hpp:153
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:136
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:45
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:530
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:564
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
Definition chonk.cpp:246
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:98
VerifierAccumulator native_verifier_accum
Definition chonk.hpp:142
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:572
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:520
std::array< RecursiveFlavor::Commitment, ClientCircuit::NUM_WIRES > TableCommitments
Definition chonk.hpp:72
DataBusDepot bus_depot
Definition chonk.hpp:154
std::shared_ptr< Transcript > transcript
Definition chonk.hpp:127
size_t num_circuits_accumulated
Definition chonk.hpp:134
void debug_incoming_circuit(ClientCircuit &circuit, const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
Definition chonk.cpp:615
HonkProof decider_proof
Definition chonk.hpp:138
FF native_verifier_accum_hash
Definition chonk.hpp:143
QUEUE_TYPE
Proof type determining recursive verification logic in kernel circuits.
Definition chonk.hpp:105
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:357
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:508
ChonkProof prove()
Construct Chonk proof, which, if verified, fully establishes the correctness of RCG.
Definition chonk.cpp:547
FoldingProver::Accumulator ProverAccumulator
Definition chonk.hpp:79
VerifierAccumulator recursive_verifier_native_accum
Definition chonk.hpp:140
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:496
MegaFlavor::CommitmentKey bn254_commitment_key
Definition chonk.hpp:156
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:397
size_t num_circuits
Definition chonk.hpp:132
VerificationQueue verification_queue
Definition chonk.hpp:150
Goblin goblin
Definition chonk.hpp:158
std::shared_ptr< Transcript > prover_accumulation_transcript
Definition chonk.hpp:130
StdlibVerificationQueue stdlib_verification_queue
Definition chonk.hpp:151
const std::string & err() const
CommitmentKey object over a pairing group 𝔾₁.
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:91
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:29
GoblinProof prove(const MergeSettings merge_settings=MergeSettings::PREPEND)
Constuct a full Goblin proof (ECCVM, Translator, merge)
Definition goblin.cpp:62
CommitmentKey< curve::BN254 > commitment_key
Definition goblin.hpp:49
std::shared_ptr< Transcript > transcript
Definition goblin.hpp:55
HyperNova decider prover. Produces final opening proof for the accumulated claim.
HonkProof construct_proof(const CommitmentKey &ck, 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.
std::pair< HonkProof, Accumulator > fold(const Accumulator &accumulator, const std::shared_ptr< ProverInstance > &instance, const std::shared_ptr< VerificationKey > &honk_vk=nullptr)
Fold an instance into an accumulator. Folding happens in place.
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.
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
Perform the pairing check.
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
static constexpr size_t CONST_TRANSLATOR_LOG_N
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 vinfo(...)
Definition log.hpp:94
void info(Args... args)
Definition log.hpp:89
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)
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)
curve::BN254::BaseField Fq