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  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 DeciderZKProvingKey = 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 >, TableCommitmentsperform_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 accumulation proof and (2) the associated databus commitment consistency checks.
 
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, which, if verified, fully establishes the correctness of RCG.
 
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_accumulation_result (ClientCircuit &circuit)
 Add a hiding op with fully random Px, Py field elements to prevent information leakage in Translator proof.
 
static void hide_op_queue_content_in_tail (ClientCircuit &circuit)
 Adds three random non-ops to the tail kernel for zero-knowledge.
 
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
 
VerificationQueue verification_queue
 
StdlibVerificationQueue stdlib_verification_queue
 
DataBusDepot bus_depot
 
MegaFlavor::CommitmentKey bn254_commitment_key
 
Goblin goblin
 

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)
 
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, merge and decider 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 38 of file chonk.hpp.

Member Typedef Documentation

◆ AppIO

Definition at line 68 of file chonk.hpp.

◆ ClientCircuit

Definition at line 52 of file chonk.hpp.

◆ Commitment

Definition at line 46 of file chonk.hpp.

◆ DataBusDepot

◆ DeciderProver

Definition at line 77 of file chonk.hpp.

◆ DeciderZKProvingKey

◆ ECCVMVerificationKey

◆ FF

Definition at line 45 of file chonk.hpp.

◆ Flavor

Definition at line 42 of file chonk.hpp.

◆ FoldingProver

Definition at line 74 of file chonk.hpp.

◆ FoldingVerifier

◆ HidingKernelIO

◆ KernelIO

◆ MegaProver

Definition at line 55 of file chonk.hpp.

◆ MegaVerificationKey

◆ MegaZKVerificationKey

◆ PairingPoints

◆ Point

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

Definition at line 48 of file chonk.hpp.

◆ ProverAccumulator

◆ ProverInstance

Definition at line 49 of file chonk.hpp.

◆ ProverPolynomials

◆ RecursiveCommitment

◆ RecursiveDeciderVerifier

◆ RecursiveFlavor

◆ RecursiveFoldingVerifier

◆ RecursiveTranscript

◆ RecursiveVerificationKey

◆ RecursiveVerifierAccumulator

◆ RecursiveVerifierInstance

◆ RecursiveVKAndHash

◆ StdlibFF

Definition at line 59 of file chonk.hpp.

◆ StdlibProof

Definition at line 69 of file chonk.hpp.

◆ StdlibVerificationQueue

Definition at line 123 of file chonk.hpp.

◆ TableCommitments

◆ Transcript

Definition at line 56 of file chonk.hpp.

◆ TranslatorVerificationKey

◆ VerificationQueue

Definition at line 114 of file chonk.hpp.

◆ VerifierAccumulator

◆ VerifierInstance

Definition at line 51 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) - adds ZK masking at op queue start
  • 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 105 of file chonk.hpp.

Constructor & Destructor Documentation

◆ Chonk()

bb::Chonk::Chonk ( size_t  num_circuits)

Definition at line 23 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.

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.

Creates proofs that will later be recursively verified in kernel circuits.

Prover actions per QUEUE_TYPE (see chonk.hpp for verifier perspective):

  • OINK: instance_to_accumulator (first app, circuit 0)
  • HN: fold (circuits 1..n-4: apps, inner kernels, reset kernels)
  • HN_TAIL: fold (circuit n-3)
  • HN_FINAL: fold + decider (tail kernel, circuit n-2)
  • MEGA: MegaZK proof (hiding kernel, circuit n-1)
Parameters
circuitThe circuit to accumulate
precomputed_vkPrecomputed verification key for the circuit

Implements bb::IVCBase.

Definition at line 397 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, determine kernel type, add ZK masking for tail kernel
  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 246 of file chonk.cpp.

◆ construct_honk_proof_for_hiding_kernel()

HonkProof bb::Chonk::construct_honk_proof_for_hiding_kernel ( ClientCircuit circuit,
const std::shared_ptr< MegaVerificationKey > &  verification_key 
)
private

Construct a zero-knowledge proof for the Hiding kernel, which recursively verifies the last folding, merge and decider proof.

Definition at line 530 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 615 of file chonk.cpp.

◆ get_goblin() [1/2]

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

Implements bb::IVCBase.

Definition at line 164 of file chonk.hpp.

◆ get_goblin() [2/2]

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

Implements bb::IVCBase.

Definition at line 163 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 564 of file chonk.cpp.

◆ get_num_circuits()

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

Definition at line 160 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 357 of file chonk.cpp.

◆ hide_op_queue_accumulation_result()

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

Add a hiding op with fully random Px, Py field elements to prevent information leakage in Translator proof.

The Translator circuit builder evaluates a batched polynomial (representing the four op queue polynomials in UltraOp format) at a random challenge x. This evaluation result (called accumulated_result in translator) is included in the translator proof and verified against the equivalent computation performed by ECCVM (in verify_translation, establishing equivalence between ECCVM and UltraOp format).

Definition at line 496 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 520 of file chonk.cpp.

◆ hide_op_queue_content_in_tail()

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

Adds three random non-ops to the tail kernel for zero-knowledge.

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

Definition at line 508 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 45 of file chonk.cpp.

◆ perform_recursive_verification_and_databus_consistency_checks()

std::tuple< std::optional< Chonk::RecursiveVerifierAccumulator >, std::vector< Chonk::PairingPoints >, Chonk::TableCommitments > bb::Chonk::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 accumulation proof and (2) the associated databus commitment consistency checks.

The recursive verifier will be either Oink or Hypernova depending on the specified proof type. In either case, the verifier accumulator is updated in place via the verification algorithm. Databus commitment consistency checks are performed on the witness commitments and public inputs extracted from the proof by the verifier. Merge verification is performed with commitments to the subtable t_j extracted from the HN verifier. The computed commitment T is propagated to the next step of recursive verification.

Parameters
circuit
verifier_inputs{proof, vkey, type (Oink/HN)} A set of inputs for recursive verification
merge_commitmentsContainer for the commitments for the Merge recursive verification to be performed
accumulation_recursive_transcriptTranscript shared across recursive verification of the folding of K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n} (app)
Returns
Triple of output verifier accumulator, PairingPoints for final verification and commitments to the merged tables as read from the proof by the Merge verifier

Definition at line 98 of file chonk.cpp.

◆ prove()

ChonkProof bb::Chonk::prove ( )

Construct Chonk proof, which, if verified, fully establishes the correctness of RCG.

Returns
ChonkProof

Definition at line 547 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 572 of file chonk.cpp.

Member Data Documentation

◆ bn254_commitment_key

MegaFlavor::CommitmentKey bb::Chonk::bn254_commitment_key

Definition at line 156 of file chonk.hpp.

◆ bus_depot

DataBusDepot bb::Chonk::bus_depot

Definition at line 154 of file chonk.hpp.

◆ decider_proof

HonkProof bb::Chonk::decider_proof

Definition at line 138 of file chonk.hpp.

◆ goblin

Goblin bb::Chonk::goblin

Definition at line 158 of file chonk.hpp.

◆ native_verifier_accum

VerifierAccumulator bb::Chonk::native_verifier_accum

Definition at line 142 of file chonk.hpp.

◆ native_verifier_accum_hash

FF bb::Chonk::native_verifier_accum_hash

Definition at line 143 of file chonk.hpp.

◆ num_circuits

size_t bb::Chonk::num_circuits
private

Definition at line 132 of file chonk.hpp.

◆ num_circuits_accumulated

size_t bb::Chonk::num_circuits_accumulated = 0

Definition at line 134 of file chonk.hpp.

◆ prover_accumulation_transcript

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

Definition at line 130 of file chonk.hpp.

◆ prover_accumulator

ProverAccumulator bb::Chonk::prover_accumulator

Definition at line 136 of file chonk.hpp.

◆ recursive_verifier_native_accum

VerifierAccumulator bb::Chonk::recursive_verifier_native_accum

Definition at line 140 of file chonk.hpp.

◆ stdlib_verification_queue

StdlibVerificationQueue bb::Chonk::stdlib_verification_queue

Definition at line 151 of file chonk.hpp.

◆ transcript

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

Definition at line 127 of file chonk.hpp.

◆ verification_queue

VerificationQueue bb::Chonk::verification_queue

Definition at line 150 of file chonk.hpp.


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