28 : num_circuits(num_circuits)
46 bool vkeys_provided = !input_keys.empty();
50 "Incorrect number of verification keys provided in "
51 "stdlib verification queue instantiation.");
64 stdlib_vk_and_hash = input_keys[key_idx++];
97 switch (verifier_inputs.
type) {
99 vinfo(
"Recursively verifying accumulation of the first app circuit.");
100 auto [_, new_verifier_accumulator] =
102 output_accumulator =
std::move(new_verifier_accumulator);
107 vinfo(
"Recursively verifying inner accumulation.");
108 auto [_first_verified, _second_verified, new_verifier_accumulator] =
110 output_accumulator =
std::move(new_verifier_accumulator);
114 vinfo(
"Recursively verifying accumulation of the tail kernel.");
117 auto [_first_verified, _second_verified, final_verifier_accumulator] =
122 pairing_points.emplace_back(decider_verifier.
verify_proof(final_verifier_accumulator, stdlib_decider_proof));
126 throw_or_abort(
"Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
157 "Kernel circuits should be folded.");
167 bool kernel_return_data_match =
168 kernel_input.
kernel_return_data.get_value() == witness_commitments.kernel_calldata.get_value();
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);
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();
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]);
192 bool accum_hash_match = kernel_input.
output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
194 "output_hn_accum_hash mismatch: proof contains "
196 << prev_accum_hash->get_value());
237 BB_BENCH_NAME(
"Chonk::recursive_verification_and_consistency_checks");
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);
250 BB_ASSERT_EQ(input_verifier_accumulator.has_value(),
false);
252 auto [output_accumulator, folding_points] =
253 verify_folding(circuit, verifier_inputs, verifier_instance, accumulation_recursive_transcript);
261 verifier_inputs, public_inputs, witness_commitments, prev_accum_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();
271 auto ecc_op_col_commitments = witness_commitments.
get_ecc_op_wires().get_copy();
273 ecc_op_col_commitments.end());
278 all_points.insert(all_points.end(), folding_points.begin(), folding_points.end());
279 all_points.emplace_back(
std::move(io_pairing_points));
281 return {
std::move(output_accumulator),
std::move(all_points), updated_hash.value() };
316 bool is_hiding_kernel =
326 "DataBusDepot has stale app return-data slots at kernel-completion boundary");
330 if (!is_init_kernel) {
331 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
337 auto [output_stdlib_verifier_accumulator, pairing_points, updated_hash] =
340 current_stdlib_verifier_accumulator,
342 accumulation_recursive_transcript);
343 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
344 running_hash = updated_hash;
347 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
353 BB_ASSERT_EQ(running_hash.has_value(),
true,
"Running hash should be set for public input propagation");
356 if (is_hiding_kernel) {
357 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(),
false);
360 auto [batch_pairing_points, batch_merged_table_commitments] =
364 points_accumulator.emplace_back(batch_pairing_points);
375 std::move(batch_merged_table_commitments) };
376 hiding_output.set_public();
378 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(),
false);
388 for (
size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
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);
398 info(
"Chonk recursive verification: accumulator hash set in the public inputs matches the one "
399 "computed natively: ",
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();
438 throw_or_abort(
"Chonk::get_queue_type: num_circuits_accumulated out of range");
447 vinfo(
"Constructing hiding kernel instance (proving deferred to prove())");
450 for (
auto& block : circuit.
blocks.
get()) {
458 "hiding-kernel precomputed VK reuse relies on MegaZKFlavor inheriting VerificationKey from MegaFlavor");
459 if (precomputed_vk) {
488 if (!prover_instance) {
493 for (
auto& block : circuit.
blocks.
get()) {
511 auto verifier_transcript =
517 switch (queue_type) {
519 vinfo(
"Accumulating first app circuit");
520 BB_ASSERT_EQ(is_kernel,
false,
"First circuit accumulated must always be an app");
533 vinfo(
"Accumulating tail kernel");
543 BB_ASSERT(
false,
"Unexpected queue type");
578 BB_ASSERT(precomputed_vk !=
nullptr,
"Chonk::accumulate - VK expected for the provided circuit");
594 prover_instance.reset();
642 vinfo(
"prove eccvm...");
644 vinfo(
"finished eccvm proving.");
652 vinfo(
"prove translator and joint...");
653 auto joint_proof = batched_prover.
prove(translator_key);
654 vinfo(
"finished translator and joint proving.");
675 const std::shared_ptr<Transcript>& verifier_transcript)
677 info(
"======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
684 auto [_first_verified, new_accumulator] =
688 info(
"Sumcheck: instance to accumulator verified: ", _first_verified ?
"true" :
"false");
690 auto [_first_verified, _second_verified, new_accumulator] =
694 info(
"Sumcheck: instance to accumulator verified: ", _first_verified ?
"true" :
"false");
695 info(
"Sumcheck: batch two accumulators verified: ", _second_verified ?
"true" :
"false");
702 info(
"Decider: pairing points verified? ", pairing_points.
check() ?
"true" :
"false");
706 info(
"Chonk accumulate: prover and verifier accumulators match: ",
712 if (update_verifier_accum_hash) {
714 info(
"Chonk accumulate: hash of verifier accumulator computed natively set in previous kernel IO: ",
720 info(
"======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
727 info(
"======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
731 info(
"Did we find a failure? ", circuit.
failed() ?
"true" :
"false");
733 info(
"\t\t\tError message? ", circuit.
err());
738 info(
"Does the precomputed vk match with the one generated during accumulation? ",
741 info(
"======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
#define BB_ASSERT(expression,...)
#define BB_ASSERT_GTE(left, right,...)
#define BB_ASSERT_DEBUG(expression,...)
#define BB_ASSERT_NEQ(actual, expected,...)
#define BB_ASSERT_EQ(actual, expected,...)
#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 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)
HonkProof prove_mega_zk_oink()
ProverAccumulator prover_accumulator
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.
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.
VerifierAccumulator native_verifier_accum
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.
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()).
Chonk(size_t num_circuits)
void update_native_verifier_accumulator(const VerifierInputs &queue_entry, const std::shared_ptr< Transcript > &verifier_transcript)
Update native verifier accumulator. Useful for debugging.
static void hide_op_queue_content_in_hiding(ClientCircuit &circuit)
Adds two random non-ops to the hiding kernel for zero-knowledge.
std::shared_ptr< Transcript > transcript
size_t num_circuits_accumulated
void debug_incoming_circuit(ClientCircuit &circuit, const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
FF native_verifier_accum_hash
QUEUE_TYPE
Proof type determining recursive verification logic in kernel circuits.
bool has_last_app_been_accumulated
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...
ChonkProof prove()
Construct Chonk proof using the batched MegaZK + Translator protocol.
RecursiveFlavor::FF StdlibFF
FoldingProver::Accumulator ProverAccumulator
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.
VerifierAccumulator recursive_verifier_native_accum
bool is_previous_circuit_a_kernel
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...
std::shared_ptr< HidingKernelProverInstance > hiding_prover_inst
void accumulate(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
Perform prover work for accumulation (e.g. HN folding, merge proving)
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.
VerificationQueue verification_queue
std::shared_ptr< MegaZKVerificationKey > hiding_vk
std::shared_ptr< Transcript > prover_accumulation_transcript
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 IPA 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)
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.
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
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)