27template <
typename NativeFlavor>
36 bool sumcheck_verified =
38 info(
"Sumcheck: instance to accumulator verified: ", sumcheck_verified ?
"true" :
"false");
40 info(
"Chonk accumulate: prover and verifier sumcheck claims match: ",
41 folding_prover->get_cached_claims().back().compare_with_verifier_claim(
47template <
typename InstanceFlavor>
52 info(
"======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
56 info(
"Did we find a failure? ", circuit.
failed() ?
"true" :
"false");
58 info(
"\t\t\tError message? ", circuit.
err());
63 info(
"Does the precomputed vk match with the one generated during accumulation? ",
64 vk->compare(*precomputed_vk,
typename InstanceFlavor::CommitmentLabels().get_precomputed()) ?
"true"
67 info(
"======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
72 info(
"======= DEBUGGING INFO FOR NATIVE SUMCHECK STEP =======");
75 run_native_instance_sumcheck<KernelFlavor>(queue_entry.
kernel_honk_vk, queue_entry);
77 run_native_instance_sumcheck<AppFlavor>(queue_entry.
app_honk_vk, queue_entry);
80 info(
"======= END OF DEBUGGING INFO FOR NATIVE SUMCHECK STEP =======");
85 info(
"======= DEBUGGING INFO FOR NATIVE MULTILINEAR BATCHING STEP =======");
91 auto [batching_verified, new_accumulator] =
95 info(
"Multilinear batching: claims to accumulator verified: ", batching_verified ?
"true" :
"false");
97 info(
"Chonk accumulate: prover and verifier accumulators match: ",
101 info(
"Chonk accumulate: hash of verifier accumulator computed natively: ",
104 info(
"======= END OF DEBUGGING INFO FOR NATIVE MULTILINEAR BATCHING STEP =======");
109 info(
"======= DEBUGGING INFO FOR NATIVE DECIDER STEP =======");
114 info(
"Decider: pairing points verified? ", pairing_points.
check() ?
"true" :
"false");
116 info(
"======= END OF DEBUGGING INFO FOR NATIVE DECIDER STEP =======");
122 : circuit_kinds(
std::move(circuit_kinds))
123 , num_circuits(
this->circuit_kinds.size())
134 const bool is_valid_kind =
136 if (!is_valid_kind) {
140 if (!is_valid_hiding_kernel_position) {
141 throw_or_abort(
"Chonk: HidingKernel must be the final circuit in the IVC stack and nowhere else");
143 const bool is_first_circuit_app = this->circuit_kinds.front() ==
CircuitKind::App;
144 if (!is_first_circuit_app) {
145 throw_or_abort(
"Chonk: the first circuit in the IVC stack must be an app");
163 const bool vkeys_provided = !input_keys.empty();
164 if (vkeys_provided) {
167 "Incorrect number of verification keys provided in "
168 "stdlib verification queue instantiation.");
171 size_t input_idx = 0;
178 auto stdlib_vk_and_hash = vkeys_provided
183 auto stdlib_vk_and_hash = vkeys_provided
217 bool kernel_return_data_match =
219 if (!kernel_return_data_match) {
220 info(
"kernel_return_data mismatch: proof contains ",
222 " but kernel_calldata commitment is ",
233 static_assert(
std::tuple_size_v<
decltype(app_calldata_commitments)> == MAX_APPS_PER_KERNEL,
234 "app_calldata_commitments must list one commitment per app bus column");
235 for (
size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
237 bool app_return_data_match =
238 kernel_input.
app_return_data[idx].get_value() == app_calldata_commitments[idx]->get_value();
239 if (!app_return_data_match) {
240 info(
"app_return_data mismatch: proof contains ",
242 " but app calldata commitment ",
245 app_calldata_commitments[idx]->get_value());
248 kernel_input.
app_return_data[idx].incomplete_assert_equal(*app_calldata_commitments[idx]);
256 bool accum_hash_match = kernel_input.
output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
257 if (!accum_hash_match) {
258 info(
"output_hn_accum_hash mismatch: proof contains ",
261 prev_accum_hash->get_value());
299 BB_BENCH_NAME(
"Chonk::recursive_verification_and_consistency_checks");
306 auto verifier_instance =
314 auto ecc_op_col_commitments = witness_commitments.get_ecc_op_wires().get_copy();
315 ecc_op_col_commitments_vec.assign(ecc_op_col_commitments.begin(), ecc_op_col_commitments.end());
324 auto ecc_op_col_commitments = witness_commitments.get_ecc_op_wires().get_copy();
325 ecc_op_col_commitments_vec.assign(ecc_op_col_commitments.begin(), ecc_op_col_commitments.end());
330 if (public_inputs_result.
ecc_op_hash.has_value()) {
331 BB_ASSERT_EQ(verifier_inputs.
is_kernel(),
true,
"previous_ecc_op_hash should only be set for kernels");
332 BB_ASSERT(!running_ecc_op_hash.has_value(),
333 "Running ECC op hash should not be set when recursively verifying a kernel");
334 updated_hash = public_inputs_result.
ecc_op_hash.value();
339 return { public_inputs_result.
pairing_points, updated_hash.value() };
383 "DataBusDepot has stale app return-data slots at kernel-completion boundary");
390 BB_ASSERT_LTE(num_claims, CHONK_MAX_CLAIMS_PER_KERNEL,
"Per-kernel batch width exceeds the supported maximum");
401 prev_stdlib_verifier_accumulator =
403 prev_stdlib_accum_hash =
404 prev_stdlib_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
413 verifier_input, folding_verifier, prev_stdlib_accum_hash, running_ecc_op_hash);
414 points_accumulator.push_back(pairing_points);
415 running_ecc_op_hash = updated_ecc_hash;
421 running_ecc_op_hash.has_value(),
true,
"Running ECC op hash should be set for public input propagation");
426 auto [batch_verified, output_accumulator] =
427 folding_verifier.
finalize(stdlib_multilinear_batch_proof,
std::move(prev_stdlib_verifier_accumulator));
428 vinfo(
"Per-kernel folding verified: ", batch_verified ?
"true" :
"false");
433 BB_ASSERT_EQ(num_claims, 2U,
"In the hiding kernel the number of claims should always be equal to 2");
436 points_accumulator.emplace_back(decider_verifier.
verify_proof(output_accumulator, stdlib_decider_proof));
439 auto [batch_pairing_points, batch_merged_table_commitments] =
443 points_accumulator.emplace_back(batch_pairing_points);
454 std::move(batch_merged_table_commitments) };
455 hiding_output.set_public();
465 for (
size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
471 StdlibFF current_verifier_accum_hash = output_accumulator.hash_with_origin_tagging(hash_transcript);
472 info(
"Kernel output accumulator hash: ", current_verifier_accum_hash);
475 KernelIO kernel_output{ pairing_points_aggregator,
476 kernel_return_data_commitment,
477 app_return_data_commitments,
478 running_ecc_op_hash.value(),
479 current_verifier_accum_hash };
480 kernel_output.set_public();
488 const std::shared_ptr<MegaZKVerificationKey>& precomputed_vk)
496 throw_or_abort(
"Chonk::accumulate_hiding_kernel must be the final circuit in the IVC stack");
499 vinfo(
"Constructing hiding kernel instance (proving deferred to prove())");
503 for (
auto& block : circuit.
blocks.
get()) {
507 if (precomputed_vk) {
510 BB_ASSERT(*precomputed_vk == *computed_vk,
511 "Chonk::accumulate_hiding_kernel - precomputed MegaZK VK does not match computed VK");
523template <
typename InstanceFlavor>
528 BB_ASSERT(
vk !=
nullptr,
"Chonk::accumulate_and_fold - VK expected for the provided circuit");
532 debug_incoming_circuit<InstanceFlavor>(circuit, prover_instance,
vk);
535 for (
auto& block : circuit.
blocks.
get()) {
542 return folding_prover->template accumulate_instance<InstanceFlavor>(prover_instance,
vk);
555 "Chonk::accumulate_and_fold: CircuitKind disagrees with the IVC state machine");
575 queue_entry.
kind = kind;
578 proof = instance_to_accumulator<KernelFlavor>(circuit, kernel_vk);
582 proof = instance_to_accumulator<AppFlavor>(circuit, app_vk);
625 "is_init_kernel: stdlib verification queue must hold the current kernel's group");
689 BB_ASSERT_LTE(num_claims, CHONK_MAX_CLAIMS_PER_KERNEL,
"Per-kernel batch width exceeds the supported maximum");
697 BB_ASSERT_EQ(proof.empty(), num_claims == 1,
"A single-claim group must produce no batching proof");
748 vinfo(
"prove eccvm...");
750 vinfo(
"finished eccvm proving.");
758 vinfo(
"prove translator and joint...");
759 auto joint_proof = batched_prover.
prove(translator_key);
760 vinfo(
"finished translator and joint proving.");
#define BB_ASSERT(expression,...)
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_ASSERT_LTE(left, right,...)
#define BB_ASSERT_LT(left, right,...)
#define BB_BENCH_NAME(name)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
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)
HonkProof prove_mega_zk_oink()
PublicInputsResult process_app_public_inputs(std::vector< StdlibFF > &public_inputs, AppWitnessCommitments &witness_commitments)
ProverAccumulator prover_accumulator
std::shared_ptr< FoldingProver > folding_prover
void verify_decider_natively()
std::shared_ptr< MegaZKFlavor::VKAndHash > get_hiding_kernel_vk_and_hash() const
Get the hiding kernel verification key and hash for Chonk verification.
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
void run_native_instance_sumcheck(const std::shared_ptr< typename NativeFlavor::VerificationKey > &honk_vk, const VerifierInputs &queue_entry)
Templated native verification of the instance to accumulator sumcheck.
CircuitKind current_kind() const
Kind of the circuit currently being accumulated (or, between accumulate calls, the next one expected)...
VerifierAccumulator native_verifier_accum
void prove_multilinear_batching()
Generate multilinear batching proof for the current group of accumulators.
void accumulate(ClientCircuit &circuit, const CircuitVerificationKey &vk)
Accumulate a circuit into the running IVC.
static void hide_op_queue_content_in_hiding(ClientCircuit &circuit)
Adds two random non-ops to the hiding kernel for zero-knowledge.
void accumulate_hiding_kernel(ClientCircuit &circuit, const std::shared_ptr< MegaZKVerificationKey > &precomputed_vk)
Build the hiding kernel's ZK proving key and verification key (proving is deferred to prove()).
Chonk(std::vector< CircuitKind > circuit_kinds)
KernelRecursiveFlavor::FF StdlibFF
std::shared_ptr< Transcript > transcript
size_t num_circuits_accumulated
std::pair< PairingPoints, EccOpRunningHash > recursive_verification_and_consistency_checks(const StdlibVerifierInputs &verifier_inputs, HypernovaFoldingRecursiveVerifier &folding_verifier, const std::optional< StdlibFF > &prev_stdlib_acc_hash, const std::optional< EccOpRunningHash > &running_ecc_op_hash)
Run sumcheck on a single proof in the group and perform its databus/accumulator-hash consistency chec...
std::vector< CircuitKind > circuit_kinds
void update_native_verifier_accumulator(bool is_init_group)
Natively verify the multilinear batching proof and update the native verifier accumulator....
bb::CircuitVerificationKey CircuitVerificationKey
ChonkProof prove()
Construct Chonk proof using the batched MegaZK + Translator protocol.
std::shared_ptr< HypernovaFoldingNativeVerifier > native_folding_verifier
void instantiate_stdlib_verification_queue(ClientCircuit &circuit, const std::vector< StdlibCircuitVKAndHash > &input_keys={})
Instantiate a stdlib verification queue for use in the kernel completion logic.
VerifierAccumulator recursive_verifier_native_accum
PublicInputsResult process_kernel_public_inputs(std::vector< StdlibFF > &public_inputs, KernelWitnessCommitments &witness_commitments, const std::optional< StdlibFF > &prev_accum_hash)
Process public inputs from a verified circuit and perform databus consistency checks.
std::shared_ptr< HidingKernelProverInstance > hiding_prover_inst
CircuitKind next_kind() const
Kind of the circuit that follows the one currently being accumulated, or CircuitKind::None if the cur...
std::shared_ptr< Transcript > native_verifier_accumulation_transcript
bool is_hiding_kernel() const
Whether the circuit currently being accumulated/completed is the hiding kernel.
void accumulate_and_fold(ClientCircuit &circuit, const CircuitVerificationKey &vk)
Turn the incoming instance into an accumulator. If a kernel follows, also produce a multilinear batch...
void debug_incoming_circuit(ClientCircuit &circuit, const std::shared_ptr< ProverInstance_< InstanceFlavor > > &prover_instance, const std::shared_ptr< typename InstanceFlavor::VerificationKey > &precomputed_vk)
VerificationQueue verification_queue
static constexpr size_t group_claim_count(bool has_previous_accumulator, size_t group_size)
Number of claims a kernel batches: the previous accumulator (absent for the init kernel) plus one sum...
HonkProof multilinear_batch_proof
std::shared_ptr< MegaZKVerificationKey > hiding_vk
bool is_init_kernel() const
Whether the kernel currently being completed is the init kernel (the first kernel,...
std::shared_ptr< Transcript > prover_accumulation_transcript
HonkProof instance_to_accumulator(ClientCircuit &circuit, const std::shared_ptr< typename InstanceFlavor::VerificationKey > &vk)
void verify_native_instance_sumcheck(const VerifierInputs &queue_entry)
Natively verify the instance-to-accumulator sumcheck of the circuit just accumulated....
StdlibVerificationQueue stdlib_verification_queue
const std::string & err() const
fq evaluation_challenge_x
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.
void prove_eccvm()
Construct an ECCVM proof and TripleIPA opening proof.
fq translation_batching_challenge_v
void prove_batch_merge()
Construct a batched merge proof for all subtables accumulated during the IVC.
std::shared_ptr< OpQueue > op_queue
std::shared_ptr< Transcript > transcript
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.
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)
Stateful HyperNova folding verifier (native + recursive). Verifies a series of instances against a st...
std::pair< bool, Accumulator > finalize(const Proof &batching_proof, std::optional< Accumulator > previous_accumulator=std::nullopt)
Batch the previous accumulator (if any) and the cached claims into a single accumulator.
bool accumulate_instance(const std::shared_ptr< VerifierInstance< InstanceFlavor > > &instance, const Proof &proof)
Verify the instance-to-accumulator sumcheck of one incoming proof and cache the resulting claim.
Recursive counterpart to MegaAppFlavor.
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...
DataType & fourth_app_calldata()
DataType & fifth_app_calldata()
DataType & kernel_calldata()
DataType & third_app_calldata()
DataType & first_app_calldata()
DataType & second_app_calldata()
Recursive counterpart to MegaKernelFlavor.
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.
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
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.
bool app_return_data_slots_are_empty() const
Whether all app return-data slots are currently empty.
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.
void set_app_return_data_commitment(const Commitment &commitment)
Record an app return-data commitment in the next available slot.
void set_kernel_return_data_commitment(const Commitment &commitment)
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.
PairingInputs pairing_inputs
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.
AppReturnDataCommitments app_return_data
void reconstruct_from_public(const std::vector< FF > &public_inputs)
Reconstructs the IO components from a public inputs array.
PairingInputs pairing_inputs
std::array< G1, N > AppReturnDataCommitments
MemoryProfile GLOBAL_MEMORY_PROFILE
Entry point for Barretenberg command-line interface.
std::vector< fr > HonkProof
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
bool compare_with_verifier_claim(const MultilinearBatchingVerifierClaim< curve::BN254 > &verifier_claim) const
Debug helper to compare prover claim against verifier claim.
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)