24 : num_circuits(num_circuits)
25 , goblin(bn254_commitment_key)
31 info(
"BN254 commitment key size: ", commitment_key_size);
48 bool vkeys_provided = !input_keys.empty();
52 "Incorrect number of verification keys provided in "
53 "stdlib verification queue instantiation.");
66 stdlib_vk_and_hash = input_keys[key_idx++];
120 prev_accum_hash = input_verifier_accumulator->hash_with_origin_tagging(*accumulation_recursive_transcript);
124 switch (verifier_inputs.
type) {
126 vinfo(
"Recursively verifying accumulation of the first app circuit.");
127 BB_ASSERT_EQ(input_verifier_accumulator.has_value(),
false);
129 auto [_, new_verifier_accumulator] =
131 output_verifier_accumulator =
std::move(new_verifier_accumulator);
139 vinfo(
"Recursively verifying inner accumulation.");
140 auto [_first_verified, _second_verified, new_verifier_accumulator] =
142 output_verifier_accumulator =
std::move(new_verifier_accumulator);
146 vinfo(
"Recursively verifying accumulation of the tail kernel.");
149 auto [_first_verified, _second_verified, final_verifier_accumulator] =
154 pairing_points.emplace_back(decider_verifier.
verify_proof(final_verifier_accumulator, stdlib_decider_proof));
156 BB_ASSERT_EQ(output_verifier_accumulator.has_value(),
false);
160 throw_or_abort(
"Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported");
175 bool kernel_return_data_match =
176 kernel_input.
kernel_return_data.get_value() == witness_commitments.calldata.get_value();
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);
183 bool app_return_data_match =
184 kernel_input.
app_return_data.get_value() == witness_commitments.secondary_calldata.get_value();
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);
198 "Kernel circuits should be folded.");
202 bool accum_hash_match = kernel_input.
output_hn_accum_hash.get_value() == prev_accum_hash->get_value();
204 "output_hn_accum_hash mismatch: proof contains "
206 << prev_accum_hash->get_value());
223 merge_commitments.t_commitments = witness_commitments.
get_ecc_op_wires().get_copy();
226 auto [merge_pairing_points, merged_table_commitments] =
228 pairing_points.emplace_back(merge_pairing_points);
230 return { output_verifier_accumulator, pairing_points, merged_table_commitments };
262 bool is_init_kernel =
265 bool is_tail_kernel =
268 bool is_hiding_kernel =
276 if (is_tail_kernel) {
279 "tail kernel ecc ops table should be empty at this point");
294 if (!is_init_kernel) {
295 current_stdlib_verifier_accumulator = RecursiveVerifierAccumulator::stdlib_from_native<RecursiveFlavor::Curve>(
301 auto [output_stdlib_verifier_accumulator, pairing_points, merged_table_commitments] =
304 current_stdlib_verifier_accumulator,
306 accumulation_recursive_transcript);
307 points_accumulator.insert(points_accumulator.end(), pairing_points.begin(), pairing_points.end());
309 T_prev_commitments = merged_table_commitments;
311 current_stdlib_verifier_accumulator = output_stdlib_verifier_accumulator;
321 if (is_hiding_kernel) {
322 BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(),
false);
329 T_prev_commitments };
330 hiding_output.set_public();
332 BB_ASSERT_NEQ(current_stdlib_verifier_accumulator.has_value(),
false);
340 kernel_output.ecc_op_tables = T_prev_commitments;
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);
346 info(
"Chonk recursive verification: accumulator hash set in the public inputs matches the one "
347 "computed natively: ",
350 kernel_output.set_public();
402 BB_ASSERT(precomputed_vk !=
nullptr,
"Chonk::accumulate - VK expected for the provided circuit");
433 auto verifier_transcript =
441 switch (queue_type) {
443 vinfo(
"Accumulating first app circuit");
444 BB_ASSERT_EQ(is_kernel,
false,
"First circuit accumulated must always be an app");
455 vinfo(
"Accumulating tail kernel");
462 vinfo(
"Generating proof for hiding kernel");
466 prover_instance.reset();
573 const std::shared_ptr<Transcript>& verifier_transcript)
575 info(
"======= DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
582 auto [_first_verified, new_accumulator] =
586 info(
"Sumcheck: instance to accumulator verified: ", _first_verified ?
"true" :
"false");
588 auto [_first_verified, _second_verified, new_accumulator] =
592 info(
"Sumcheck: instance to accumulator verified: ", _first_verified ?
"true" :
"false");
593 info(
"Sumcheck: batch two accumulators verified: ", _second_verified ?
"true" :
"false");
600 info(
"Decider: pairing points verified? ", pairing_points.
check() ?
"true" :
"false");
608 info(
"Chonk accumulate: prover and verifier accumulators match: ",
612 info(
"======= END OF DEBUGGING INFO FOR NATIVE FOLDING STEP =======");
619 info(
"======= DEBUGGING INFO FOR INCOMING CIRCUIT =======");
623 info(
"Did we find a failure? ", circuit.
failed() ?
"true" :
"false");
625 info(
"\t\t\tError message? ", circuit.
err());
630 info(
"Does the precomputed vk match with the one generated during accumulation? ",
633 info(
"======= END OF DEBUGGING INFO FOR INCOMING CIRCUIT =======");
#define BB_ASSERT(expression,...)
#define BB_ASSERT_GT(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,...)
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
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.
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,...
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.
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...
VerifierAccumulator native_verifier_accum
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::array< RecursiveFlavor::Commitment, ClientCircuit::NUM_WIRES > TableCommitments
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.
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...
static void hide_op_queue_content_in_tail(ClientCircuit &circuit)
Adds three random non-ops to the tail kernel for zero-knowledge.
ChonkProof prove()
Construct Chonk proof, which, if verified, fully establishes the correctness of RCG.
FoldingProver::Accumulator ProverAccumulator
VerifierAccumulator recursive_verifier_native_accum
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 ...
MegaFlavor::CommitmentKey bn254_commitment_key
void accumulate(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
Perform prover work for accumulation (e.g. HN folding, merge proving)
VerificationQueue verification_queue
std::shared_ptr< Transcript > prover_accumulation_transcript
StdlibVerificationQueue stdlib_verification_queue
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.
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...
GoblinProof prove(const MergeSettings merge_settings=MergeSettings::PREPEND)
Constuct a full Goblin proof (ECCVM, Translator, merge)
CommitmentKey< curve::BN254 > commitment_key
std::shared_ptr< Transcript > transcript
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.
Commitment get_app_return_data_commitment(Builder &builder)
Get the previously set app return data commitment if it exists, else a default one.
void set_app_return_data_commitment(const Commitment &commitment)
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.
void reconstruct_from_public(const std::vector< FF > &public_inputs)
Reconstructs the IO components from a public inputs array.
PairingInputs pairing_inputs
TableCommitments ecc_op_tables
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.
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)
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