Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::Chonk Class Reference

The IVC scheme used by the aztec client for private function execution. More...

#include <chonk.hpp>

Inheritance diagram for bb::Chonk:
bb::IVCBase

Classes

struct  FoldingResult
 
struct  PublicInputsResult
 
struct  StdlibVerifierInputs
 
struct  VerifierInputs
 

Public Types

enum class  QUEUE_TYPE : uint8_t {
  OINK , HN , HN_TAIL , HN_FINAL ,
  MEGA
}
 Proof type determining recursive verification logic in kernel circuits. More...
 
using Flavor = MegaFlavor
 
using MegaVerificationKey = Flavor::VerificationKey
 
using MegaZKVerificationKey = MegaZKFlavor::VerificationKey
 
using FF = Flavor::FF
 
using Commitment = Flavor::Commitment
 
using ProverPolynomials = Flavor::ProverPolynomials
 
using Point = Flavor::Curve::AffineElement
 
using ProverInstance = ProverInstance_< Flavor >
 
using HidingKernelProverInstance = ProverInstance_< MegaZKFlavor >
 
using VerifierInstance = VerifierInstance_< Flavor >
 
using ClientCircuit = MegaCircuitBuilder
 
using ECCVMVerificationKey = bb::ECCVMFlavor::VerificationKey
 
using TranslatorVerificationKey = bb::TranslatorFlavor::VerificationKey
 
using MegaProver = UltraProver_< Flavor >
 
using Transcript = NativeTranscript
 
using RecursiveFlavor = MegaRecursiveFlavor_< bb::MegaCircuitBuilder >
 
using StdlibFF = RecursiveFlavor::FF
 
using RecursiveCommitment = RecursiveFlavor::Commitment
 
using RecursiveVerifierInstance = VerifierInstance_< RecursiveFlavor >
 
using RecursiveVerificationKey = RecursiveFlavor::VerificationKey
 
using RecursiveVKAndHash = RecursiveFlavor::VKAndHash
 
using RecursiveTranscript = RecursiveFlavor::Transcript
 
using PairingPoints = stdlib::recursion::PairingPoints< stdlib::bn254< ClientCircuit > >
 
using KernelIO = bb::stdlib::recursion::honk::KernelIO
 
using HidingKernelIO = bb::stdlib::recursion::honk::HidingKernelIO< ClientCircuit >
 
using AppIO = bb::stdlib::recursion::honk::AppIO
 
using StdlibProof = stdlib::Proof< ClientCircuit >
 
using WitnessCommitments = RecursiveFlavor::WitnessCommitments
 
using DataBusDepot = stdlib::DataBusDepot< ClientCircuit >
 
using TableCommitments = std::array< RecursiveFlavor::Commitment, ClientCircuit::NUM_WIRES >
 
using FoldingProver = HypernovaFoldingProver
 
using FoldingVerifier = HypernovaFoldingVerifier< Flavor >
 
using RecursiveFoldingVerifier = HypernovaFoldingVerifier< RecursiveFlavor >
 
using DeciderProver = HypernovaDeciderProver
 
using RecursiveDeciderVerifier = HypernovaDeciderVerifier< RecursiveFlavor >
 
using ProverAccumulator = FoldingProver::Accumulator
 
using VerifierAccumulator = FoldingVerifier::Accumulator
 
using RecursiveVerifierAccumulator = RecursiveFoldingVerifier::Accumulator
 
using VerificationQueue = std::deque< VerifierInputs >
 
using StdlibVerificationQueue = std::deque< StdlibVerifierInputs >
 
- Public Types inherited from bb::IVCBase
using ClientCircuit = MegaCircuitBuilder
 
using MegaVerificationKey = MegaZKFlavor::VerificationKey
 

Public Member Functions

size_t get_num_circuits () const
 
Goblinget_goblin () override
 
const Goblinget_goblin () const override
 
 Chonk (size_t num_circuits)
 
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::tuple< std::optional< RecursiveVerifierAccumulator >, std::vector< PairingPoints >, StdlibFFrecursive_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 circuit.
 
void complete_kernel_circuit_logic (ClientCircuit &circuit)
 Append logic to complete a kernel circuit.
 
void accumulate (ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
 Perform prover work for accumulation (e.g. HN folding, merge proving)
 
ChonkProof prove ()
 Construct Chonk proof using the batched MegaZK + Translator protocol.
 
std::shared_ptr< MegaZKFlavor::VKAndHashget_hiding_kernel_vk_and_hash () const
 Get the hiding kernel verification key and hash for Chonk verification.
 
- Public Member Functions inherited from bb::IVCBase
virtual ~IVCBase ()=default
 

Static Public Member Functions

static void hide_op_queue_content_in_hiding (ClientCircuit &circuit)
 Adds two random non-ops to the hiding kernel for zero-knowledge.
 

Public Attributes

size_t num_circuits_accumulated = 0
 
ProverAccumulator prover_accumulator
 
HonkProof decider_proof
 
VerifierAccumulator recursive_verifier_native_accum
 
VerifierAccumulator native_verifier_accum
 
FF native_verifier_accum_hash
 
bool is_previous_circuit_a_kernel = true
 
bool has_last_app_been_accumulated = false
 
VerificationQueue verification_queue
 
StdlibVerificationQueue stdlib_verification_queue
 
DataBusDepot bus_depot
 
Goblin goblin
 
std::shared_ptr< HidingKernelProverInstancehiding_prover_inst
 
std::shared_ptr< MegaZKVerificationKeyhiding_vk
 

Private Member Functions

void update_native_verifier_accumulator (const VerifierInputs &queue_entry, const std::shared_ptr< Transcript > &verifier_transcript)
 Update native verifier accumulator. Useful for debugging.
 
void debug_incoming_circuit (ClientCircuit &circuit, const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &precomputed_vk)
 
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.
 
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.
 
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()).
 
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.
 
QUEUE_TYPE get_queue_type () const
 Get queue type for the proof of a circuit about to be accumulated based on num circuits accumulated so far.
 

Private Attributes

std::shared_ptr< Transcripttranscript = std::make_shared<Transcript>()
 
std::shared_ptr< Transcriptprover_accumulation_transcript = std::make_shared<Transcript>()
 
size_t num_circuits
 

Additional Inherited Members

- Protected Member Functions inherited from bb::IVCBase
 IVCBase ()=default
 

Detailed Description

The IVC scheme used by the aztec client for private function execution.

Combines HyperNova with Goblin to accumulate one circuit at a time with efficient EC group operations. It is assumed that the circuits being accumulated correspond alternatingly to an app and a kernel, as is the case in Aztec. Two recursive folding verifiers are appended to each kernel (except the first one) to verify the folding of a previous kernel and an app/function circuit. Due to this structure it is enforced that the total number of circuits being accumulated is even.

Definition at line 39 of file chonk.hpp.

Member Typedef Documentation

◆ AppIO

Definition at line 69 of file chonk.hpp.

◆ ClientCircuit

Definition at line 53 of file chonk.hpp.

◆ Commitment

Definition at line 47 of file chonk.hpp.

◆ DataBusDepot

◆ DeciderProver

Definition at line 78 of file chonk.hpp.

◆ ECCVMVerificationKey

◆ FF

Definition at line 46 of file chonk.hpp.

◆ Flavor

Definition at line 43 of file chonk.hpp.

◆ FoldingProver

Definition at line 75 of file chonk.hpp.

◆ FoldingVerifier

◆ HidingKernelIO

◆ HidingKernelProverInstance

◆ KernelIO

◆ MegaProver

Definition at line 56 of file chonk.hpp.

◆ MegaVerificationKey

◆ MegaZKVerificationKey

◆ PairingPoints

◆ Point

using bb::Chonk::Point = Flavor::Curve::AffineElement

Definition at line 49 of file chonk.hpp.

◆ ProverAccumulator

◆ ProverInstance

Definition at line 50 of file chonk.hpp.

◆ ProverPolynomials

◆ RecursiveCommitment

◆ RecursiveDeciderVerifier

◆ RecursiveFlavor

◆ RecursiveFoldingVerifier

◆ RecursiveTranscript

◆ RecursiveVerificationKey

◆ RecursiveVerifierAccumulator

◆ RecursiveVerifierInstance

◆ RecursiveVKAndHash

◆ StdlibFF

Definition at line 60 of file chonk.hpp.

◆ StdlibProof

Definition at line 70 of file chonk.hpp.

◆ StdlibVerificationQueue

Definition at line 146 of file chonk.hpp.

◆ TableCommitments

◆ Transcript

Definition at line 57 of file chonk.hpp.

◆ TranslatorVerificationKey

◆ VerificationQueue

Definition at line 126 of file chonk.hpp.

◆ VerifierAccumulator

◆ VerifierInstance

Definition at line 52 of file chonk.hpp.

◆ WitnessCommitments

Member Enumeration Documentation

◆ QUEUE_TYPE

enum class bb::Chonk::QUEUE_TYPE : uint8_t
strong

Proof type determining recursive verification logic in kernel circuits.

This enum has dual semantics depending on context:

PROVER PERSPECTIVE (in accumulate): Type assigned to the circuit being accumulated. State machine transitions based on num_circuits_accumulated:

  • OINK: First app (circuit 0) - no prior accumulator, just Oink verification
  • HN: Apps 1..n-3, inner kernels, and reset kernels - full HyperNova folding verification
  • HN_TAIL: Circuit n-3 (last kernel before tail)
  • HN_FINAL: Circuit n-2 (tail kernel) - final folding + decider verification
  • MEGA: Circuit n-1 (hiding kernel) - MegaZK proof, no folding

VERIFIER PERSPECTIVE (in complete_kernel_circuit_logic): Type of the proof being verified.

  • If verifying OINK proof → this kernel is the init kernel (circuit 1)
  • If verifying HN proof → this kernel is an inner/reset kernel
  • If verifying HN_TAIL proof → this kernel IS the tail kernel (circuit n-2)
  • If verifying HN_FINAL proof → this kernel IS the hiding kernel (circuit n-1)

See get_queue_type() for assignment logic and README.md::circuit-structure for overview.

Enumerator
OINK 
HN 
HN_TAIL 
HN_FINAL 
MEGA 

Definition at line 117 of file chonk.hpp.

Constructor & Destructor Documentation

◆ Chonk()

bb::Chonk::Chonk ( size_t  num_circuits)

Definition at line 27 of file chonk.cpp.

Member Function Documentation

◆ accumulate()

void bb::Chonk::accumulate ( ClientCircuit circuit,
const std::shared_ptr< MegaVerificationKey > &  precomputed_vk 
)
overridevirtual

Perform prover work for accumulation (e.g. HN folding, merge proving)

Execute prover work for accumulation (e.g. HN folding, merge proving)

Parameters
circuitThe incoming statement
precomputed_vkThe verification key of the incoming statement OR a mocked key whose metadata needs to be set using the proving key produced from circuit in order to pass some assertions in the Oink prover.
mock_vkA boolean to say whether the precomputed vk should have its metadata set.

Dispatches to accumulate_hiding_kernel (for MEGA/hiding kernel) or accumulate_and_fold (for all folding-based queue types). See chonk.hpp QUEUE_TYPE for the full state machine.

Parameters
circuitThe circuit to accumulate
precomputed_vkPrecomputed verification key for the circuit

Implements bb::IVCBase.

Definition at line 573 of file chonk.cpp.

◆ accumulate_and_fold()

void bb::Chonk::accumulate_and_fold ( ClientCircuit circuit,
const std::shared_ptr< MegaVerificationKey > &  precomputed_vk,
QUEUE_TYPE  queue_type,
std::shared_ptr< ProverInstance prover_instance 
)
private

Perform HyperNova folding for a circuit and produce the corresponding merge proof.

Handles OINK (first app), HN (inner folding), HN_TAIL (last pre-tail), and HN_FINAL (tail + decider).

Parameters
circuitThe circuit to fold
precomputed_vkPrecomputed verification key for the circuit
queue_typeThe folding type for this circuit
prover_instancePre-built prover instance (from debug path) or nullptr

Definition at line 481 of file chonk.cpp.

◆ accumulate_hiding_kernel()

void bb::Chonk::accumulate_hiding_kernel ( ClientCircuit circuit,
const std::shared_ptr< MegaVerificationKey > &  precomputed_vk 
)
private

Build the hiding kernel's ZK proving key and verification key (proving is deferred to prove()).

Definition at line 444 of file chonk.cpp.

◆ complete_kernel_circuit_logic()

void bb::Chonk::complete_kernel_circuit_logic ( ClientCircuit circuit)

Append logic to complete a kernel circuit.

This is the verifier counterpart to prover's accumulate(). While accumulate() creates proofs for each circuit, this method adds recursive verification constraints to kernel circuits.

The method performs the following steps:

  1. SETUP: Initialize transcript and determine kernel type
  2. VERIFICATION LOOP: Process each entry in stdlib_verification_queue (folding + merge + databus)
  3. OUTPUT: Set public inputs (KernelIO or HidingKernelIO) for propagation to next kernel
Parameters
circuitThe kernel circuit to append verification logic to

Definition at line 297 of file chonk.cpp.

◆ debug_incoming_circuit()

void bb::Chonk::debug_incoming_circuit ( ClientCircuit circuit,
const std::shared_ptr< ProverInstance > &  prover_instance,
const std::shared_ptr< MegaVerificationKey > &  precomputed_vk 
)
private

Definition at line 723 of file chonk.cpp.

◆ get_goblin() [1/2]

const Goblin & bb::Chonk::get_goblin ( ) const
inlineoverridevirtual

Implements bb::IVCBase.

Definition at line 191 of file chonk.hpp.

◆ get_goblin() [2/2]

Goblin & bb::Chonk::get_goblin ( )
inlineoverridevirtual

Implements bb::IVCBase.

Definition at line 190 of file chonk.hpp.

◆ get_hiding_kernel_vk_and_hash()

std::shared_ptr< MegaZKFlavor::VKAndHash > bb::Chonk::get_hiding_kernel_vk_and_hash ( ) const

Get the hiding kernel verification key and hash for Chonk verification.

Returns
VKAndHash containing the MegaZK verification key and its hash

Definition at line 666 of file chonk.cpp.

◆ get_num_circuits()

size_t bb::Chonk::get_num_circuits ( ) const
inline

Definition at line 187 of file chonk.hpp.

◆ get_queue_type()

Chonk::QUEUE_TYPE bb::Chonk::get_queue_type ( ) const
private

Get queue type for the proof of a circuit about to be accumulated based on num circuits accumulated so far.

Definition at line 416 of file chonk.cpp.

◆ hide_op_queue_content_in_hiding()

void bb::Chonk::hide_op_queue_content_in_hiding ( ClientCircuit circuit)
static

Adds two random non-ops to the hiding kernel for zero-knowledge.

See MERGE_PROTOCOL.md (ZK Considerations) for detailed analysis.

Definition at line 607 of file chonk.cpp.

◆ instantiate_stdlib_verification_queue()

void bb::Chonk::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.

Construct a stdlib proof/verification_key for each entry in the native verification queue. By default, both are constructed from their counterpart in the native queue. Alternatively, Stdlib verification keys can be provided directly as input to this method. (The later option is used, for example, when constructing recursive verifiers based on the verification key witnesses from an acir recursion constraint. This option is not provided for proofs since valid proof witnesses are in general not known at the time of acir constraint generation).

Parameters
circuit

Definition at line 43 of file chonk.cpp.

◆ process_public_inputs_and_consistency_checks()

Chonk::PublicInputsResult bb::Chonk::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 
)
private

Process public inputs from a verified circuit and perform databus consistency checks.

For kernel circuits: reconstructs KernelIO from public inputs, verifies that databus return data commitments match witness commitments, checks accumulator hash consistency, and returns the kernel's ECC op running hash. For app circuits: reconstructs AppIO from public inputs and extracts pairing points. In both cases, updates the bus depot with the appropriate return data commitment.

Parameters
verifier_inputs{proof, vkey, type (Oink/HN)} A set of inputs for recursive verification
public_inputsThe public inputs extracted from the verifier instance that was folded into the running accumulator
witness_commitmentsThe witness commitments extracted from the verifier instance that was folded into the running accumulator
prev_accum_hashThe accumulator hash from the previous kernel

Definition at line 147 of file chonk.cpp.

◆ prove()

ChonkProof bb::Chonk::prove ( )

Construct Chonk proof using the batched MegaZK + Translator protocol.

Orchestrates the batched proving flow on a shared transcript:

  1. MegaZK Oink (pre-sumcheck commitments for the hiding kernel)
  2. Merge proof (fixed-location append of the final subtable from the hiding kernel)
  3. ECCVM proof (produces translation challenges v, x)
  4. IPA proof (separate transcript)
  5. Translator Oink + Joint sumcheck + Joint PCS

The joint sumcheck and PCS batch the MegaZK and translator circuits together, eliminating separate sumcheck/PCS phases and reducing proof size.

Definition at line 626 of file chonk.cpp.

◆ recursive_verification_and_consistency_checks()

std::tuple< std::optional< Chonk::RecursiveVerifierAccumulator >, std::vector< Chonk::PairingPoints >, Chonk::StdlibFF > bb::Chonk::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 circuit.

Delegates to three steps: (1) recursive folding verification via verify_folding, (2) public inputs processing and databus consistency checks via process_public_inputs_and_consistency_checks, and (3) merge recursive verification. Returns the output accumulator, aggregated pairing points, and merged table commitments.

Parameters
circuit
verifier_inputs{proof, vkey, type (Oink/HN)} A set of inputs for recursive verification
input_verifier_accumulatorThe accumulator from the previous step of recursive verification
running_hashRunning hash of ECC-op column commitments from prior steps in this kernel.
accumulation_recursive_transcriptTranscript shared across recursive verification of the folding of K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n} (app)

Definition at line 230 of file chonk.cpp.

◆ update_native_verifier_accumulator()

void bb::Chonk::update_native_verifier_accumulator ( const VerifierInputs queue_entry,
const std::shared_ptr< Transcript > &  verifier_transcript 
)
private

Update native verifier accumulator. Useful for debugging.

Parameters
queue_entryThe verifier inputs from the queue.
verifier_transcriptVerifier transcript corresponding to the prover transcript.

Definition at line 674 of file chonk.cpp.

◆ verify_folding()

Chonk::FoldingResult bb::Chonk::verify_folding ( ClientCircuit circuit,
const StdlibVerifierInputs verifier_inputs,
const std::shared_ptr< RecursiveVerifierInstance > &  verifier_instance,
const std::shared_ptr< RecursiveTranscript > &  accumulation_recursive_transcript 
) const
private

Perform recursive folding verification for a single circuit in the IVC.

Runs the appropriate folding verifier (Oink for first app, HyperNova for subsequent circuits) and returns the resulting accumulator. For HN_FINAL (tail kernel), also runs the decider verifier and returns its pairing points.

Parameters
circuit
verifier_inputs{proof, vkey, type (Oink/HN)} A set of inputs for recursive verification
verifier_instanceThe instance to be folded into the running accumulator
accumulation_recursive_transcriptTranscript shared across recursive verification of the folding of K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n} (app)

Definition at line 87 of file chonk.cpp.

Member Data Documentation

◆ bus_depot

DataBusDepot bb::Chonk::bus_depot

Definition at line 179 of file chonk.hpp.

◆ decider_proof

HonkProof bb::Chonk::decider_proof

Definition at line 161 of file chonk.hpp.

◆ goblin

Goblin bb::Chonk::goblin

Definition at line 181 of file chonk.hpp.

◆ has_last_app_been_accumulated

bool bb::Chonk::has_last_app_been_accumulated = false

Definition at line 168 of file chonk.hpp.

◆ hiding_prover_inst

std::shared_ptr<HidingKernelProverInstance> bb::Chonk::hiding_prover_inst

Definition at line 184 of file chonk.hpp.

◆ hiding_vk

std::shared_ptr<MegaZKVerificationKey> bb::Chonk::hiding_vk

Definition at line 185 of file chonk.hpp.

◆ is_previous_circuit_a_kernel

bool bb::Chonk::is_previous_circuit_a_kernel = true

Definition at line 167 of file chonk.hpp.

◆ native_verifier_accum

VerifierAccumulator bb::Chonk::native_verifier_accum

Definition at line 165 of file chonk.hpp.

◆ native_verifier_accum_hash

FF bb::Chonk::native_verifier_accum_hash

Definition at line 166 of file chonk.hpp.

◆ num_circuits

size_t bb::Chonk::num_circuits
private

Definition at line 155 of file chonk.hpp.

◆ num_circuits_accumulated

size_t bb::Chonk::num_circuits_accumulated = 0

Definition at line 157 of file chonk.hpp.

◆ prover_accumulation_transcript

std::shared_ptr<Transcript> bb::Chonk::prover_accumulation_transcript = std::make_shared<Transcript>()
private

Definition at line 153 of file chonk.hpp.

◆ prover_accumulator

ProverAccumulator bb::Chonk::prover_accumulator

Definition at line 159 of file chonk.hpp.

◆ recursive_verifier_native_accum

VerifierAccumulator bb::Chonk::recursive_verifier_native_accum

Definition at line 163 of file chonk.hpp.

◆ stdlib_verification_queue

StdlibVerificationQueue bb::Chonk::stdlib_verification_queue

Definition at line 176 of file chonk.hpp.

◆ transcript

std::shared_ptr<Transcript> bb::Chonk::transcript = std::make_shared<Transcript>()
private

Definition at line 150 of file chonk.hpp.

◆ verification_queue

VerificationQueue bb::Chonk::verification_queue

Definition at line 175 of file chonk.hpp.


The documentation for this class was generated from the following files: