Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::DeciderProvingKey_< Flavor > Class Template Reference

A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the information required by an Mega Honk prover to create a proof. A DeciderProvingKey is also the result of running the Protogalaxy prover, in which case it becomes a relaxed counterpart with the folding parameters (target sum and gate challenges set to non-zero values). More...

#include <decider_proving_key.hpp>

Public Types

using Trace = TraceToPolynomials< Flavor >
 

Public Member Functions

void set_dyadic_size (size_t size)
 
void set_overflow_size (size_t size)
 
void set_final_active_wire_idx (size_t idx)
 
size_t dyadic_size () const
 
size_t log_dyadic_size () const
 
size_t pub_inputs_offset () const
 
size_t num_public_inputs () const
 
MetaData get_metadata () const
 
size_t get_overflow_size () const
 
size_t get_final_active_wire_idx () const
 
Flavor::PrecomputedData get_precomputed ()
 
 DeciderProvingKey_ (Circuit &circuit, TraceSettings trace_settings={}, const CommitmentKey &commitment_key=CommitmentKey())
 
 DeciderProvingKey_ ()=default
 
 ~DeciderProvingKey_ ()=default
 
bool get_is_structured ()
 

Public Attributes

std::vector< FFpublic_inputs
 
ProverPolynomials polynomials
 
SubrelationSeparators alphas
 
bb::RelationParameters< FFrelation_parameters
 
std::vector< FFgate_challenges
 
FF target_sum { 0 }
 
HonkProof ipa_proof
 
bool from_first_instance = false
 
bool is_complete = false
 
std::vector< uint32_t > memory_read_records
 
std::vector< uint32_t > memory_write_records
 
CommitmentKey commitment_key
 
ActiveRegionData active_region_data
 

Private Types

using Circuit = typename Flavor::CircuitBuilder
 
using CommitmentKey = typename Flavor::CommitmentKey
 
using FF = typename Flavor::FF
 
using ProverPolynomials = typename Flavor::ProverPolynomials
 
using Polynomial = typename Flavor::Polynomial
 
using SubrelationSeparators = typename Flavor::SubrelationSeparators
 

Private Member Functions

size_t compute_dyadic_size (Circuit &)
 Helper method to compute quantities like total number of gates and dyadic circuit size.
 
void allocate_wires ()
 
void allocate_permutation_argument_polynomials ()
 
void allocate_lagrange_polynomials ()
 
void allocate_selectors (const Circuit &)
 
void allocate_table_lookup_polynomials (const Circuit &)
 
void allocate_ecc_op_polynomials (const Circuit &)
 
void allocate_databus_polynomials (const Circuit &)
 
size_t compute_structured_dyadic_size (Circuit &circuit)
 Compute dyadic size based on a structured trace with fixed block size.
 
void construct_databus_polynomials (Circuit &)
 
void populate_memory_records (const Circuit &circuit)
 Copy RAM/ROM record of reads and writes from the circuit to the proving key.
 

Static Private Member Functions

static void move_structured_trace_overflow_to_overflow_block (Circuit &circuit)
 Check that the number of gates in each block does not exceed its fixed capacity. Move any overflow to the overflow block.
 

Private Attributes

bool is_structured
 
MetaData metadata
 
size_t overflow_size { 0 }
 
size_t final_active_wire_idx { 0 }
 

Static Private Attributes

static constexpr size_t num_zero_rows = Flavor::has_zero_row ? 1 : 0
 
static constexpr size_t NUM_WIRES = Circuit::NUM_WIRES
 

Detailed Description

template<IsUltraOrMegaHonk Flavor>
class bb::DeciderProvingKey_< Flavor >

A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the information required by an Mega Honk prover to create a proof. A DeciderProvingKey is also the result of running the Protogalaxy prover, in which case it becomes a relaxed counterpart with the folding parameters (target sum and gate challenges set to non-zero values).

This is the equivalent of ω in the paper.

Definition at line 36 of file decider_proving_key.hpp.

Member Typedef Documentation

◆ Circuit

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::Circuit = typename Flavor::CircuitBuilder
private

Definition at line 37 of file decider_proving_key.hpp.

◆ CommitmentKey

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::CommitmentKey = typename Flavor::CommitmentKey
private

Definition at line 38 of file decider_proving_key.hpp.

◆ FF

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::FF = typename Flavor::FF
private

Definition at line 39 of file decider_proving_key.hpp.

◆ Polynomial

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::Polynomial = typename Flavor::Polynomial
private

Definition at line 41 of file decider_proving_key.hpp.

◆ ProverPolynomials

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::ProverPolynomials = typename Flavor::ProverPolynomials
private

Definition at line 40 of file decider_proving_key.hpp.

◆ SubrelationSeparators

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::SubrelationSeparators = typename Flavor::SubrelationSeparators
private

Definition at line 42 of file decider_proving_key.hpp.

◆ Trace

template<IsUltraOrMegaHonk Flavor>
using bb::DeciderProvingKey_< Flavor >::Trace = TraceToPolynomials<Flavor>

Definition at line 52 of file decider_proving_key.hpp.

Constructor & Destructor Documentation

◆ DeciderProvingKey_() [1/2]

template<IsUltraOrMegaHonk Flavor>
bb::DeciderProvingKey_< Flavor >::DeciderProvingKey_ ( Circuit circuit,
TraceSettings  trace_settings = {},
const CommitmentKey commitment_key = CommitmentKey() 
)
inline

Definition at line 92 of file decider_proving_key.hpp.

◆ DeciderProvingKey_() [2/2]

template<IsUltraOrMegaHonk Flavor>
bb::DeciderProvingKey_< Flavor >::DeciderProvingKey_ ( )
default

◆ ~DeciderProvingKey_()

template<IsUltraOrMegaHonk Flavor>
bb::DeciderProvingKey_< Flavor >::~DeciderProvingKey_ ( )
default

Member Function Documentation

◆ allocate_databus_polynomials()

template<IsUltraOrMegaHonk Flavor>
requires HasDataBus<Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_databus_polynomials ( const Circuit circuit)
private

Definition at line 149 of file decider_proving_key.cpp.

◆ allocate_ecc_op_polynomials()

template<IsUltraOrMegaHonk Flavor>
requires IsMegaFlavor<Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_ecc_op_polynomials ( const Circuit circuit)
private

Definition at line 135 of file decider_proving_key.cpp.

◆ allocate_lagrange_polynomials()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_lagrange_polynomials ( )
private

Definition at line 61 of file decider_proving_key.cpp.

◆ allocate_permutation_argument_polynomials()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_permutation_argument_polynomials ( )
private

Definition at line 48 of file decider_proving_key.cpp.

◆ allocate_selectors()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_selectors ( const Circuit circuit)
private

Definition at line 76 of file decider_proving_key.cpp.

◆ allocate_table_lookup_polynomials()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_table_lookup_polynomials ( const Circuit circuit)
private

Definition at line 101 of file decider_proving_key.cpp.

◆ allocate_wires()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::allocate_wires ( )
private

Definition at line 39 of file decider_proving_key.cpp.

◆ compute_dyadic_size()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::compute_dyadic_size ( Circuit circuit)
private

Helper method to compute quantities like total number of gates and dyadic circuit size.

Template Parameters
Flavor
Parameters
circuit

Definition at line 22 of file decider_proving_key.cpp.

◆ compute_structured_dyadic_size()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::compute_structured_dyadic_size ( Circuit circuit)
inlineprivate

Compute dyadic size based on a structured trace with fixed block size.

Definition at line 247 of file decider_proving_key.hpp.

◆ construct_databus_polynomials()

template<IsUltraOrMegaHonk Flavor>
requires HasDataBus<Flavor>
void bb::DeciderProvingKey_< Flavor >::construct_databus_polynomials ( Circuit circuit)
private
Template Parameters
Flavor
Parameters
circuit

Definition at line 187 of file decider_proving_key.cpp.

◆ dyadic_size()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::dyadic_size ( ) const
inline

Definition at line 75 of file decider_proving_key.hpp.

◆ get_final_active_wire_idx()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::get_final_active_wire_idx ( ) const
inline

Definition at line 85 of file decider_proving_key.hpp.

◆ get_is_structured()

template<IsUltraOrMegaHonk Flavor>
bool bb::DeciderProvingKey_< Flavor >::get_is_structured ( )
inline

Definition at line 219 of file decider_proving_key.hpp.

◆ get_metadata()

template<IsUltraOrMegaHonk Flavor>
MetaData bb::DeciderProvingKey_< Flavor >::get_metadata ( ) const
inline

Definition at line 83 of file decider_proving_key.hpp.

◆ get_overflow_size()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::get_overflow_size ( ) const
inline

Definition at line 84 of file decider_proving_key.hpp.

◆ get_precomputed()

template<IsUltraOrMegaHonk Flavor>
Flavor::PrecomputedData bb::DeciderProvingKey_< Flavor >::get_precomputed ( )
inline

Definition at line 87 of file decider_proving_key.hpp.

◆ log_dyadic_size()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::log_dyadic_size ( ) const
inline

Definition at line 76 of file decider_proving_key.hpp.

◆ move_structured_trace_overflow_to_overflow_block()

template<IsUltraOrMegaHonk Flavor>
requires IsMegaFlavor<Flavor>
void bb::DeciderProvingKey_< Flavor >::move_structured_trace_overflow_to_overflow_block ( Circuit circuit)
staticprivate

Check that the number of gates in each block does not exceed its fixed capacity. Move any overflow to the overflow block.

Using a structured trace (fixed capcity for each gate type) optimizes the efficiency of folding. However, to accommodate circuits which cannot fit into a prescribed trace, gates which overflow their corresponding block are placed into an overflow block which can contain arbitrary gate types.

Note
One sublety is that gates at row i may in general utilize the values at row i+1 via shifts. If the last row in a full-capacity block is such a gate, then moving the overflow out of sequence will cause that gate not to be satisfied. To avoid this, when a block overflows, the final gate in the block is duplicated, once in the main block with the selectors turned off but the wires values maintained (so that the prior gate can read into it but it does not itself try to read into the next row) and again as a normal gate in the overflow block. Therefore, the total number of gates in the circuit increases by one for each block that overflows.
Template Parameters
Flavor
Parameters
circuit

Definition at line 247 of file decider_proving_key.cpp.

◆ num_public_inputs()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::num_public_inputs ( ) const
inline

Definition at line 78 of file decider_proving_key.hpp.

◆ populate_memory_records()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::populate_memory_records ( const Circuit circuit)
private

Copy RAM/ROM record of reads and writes from the circuit to the proving key.

The memory records in the circuit store indices within the memory block where a read/write is performed. They are stored in the DPK as indices into the full trace by accounting for the offset of the memory block.

Definition at line 347 of file decider_proving_key.cpp.

◆ pub_inputs_offset()

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::pub_inputs_offset ( ) const
inline

Definition at line 77 of file decider_proving_key.hpp.

◆ set_dyadic_size()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::set_dyadic_size ( size_t  size)
inline

Definition at line 72 of file decider_proving_key.hpp.

◆ set_final_active_wire_idx()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::set_final_active_wire_idx ( size_t  idx)
inline

Definition at line 74 of file decider_proving_key.hpp.

◆ set_overflow_size()

template<IsUltraOrMegaHonk Flavor>
void bb::DeciderProvingKey_< Flavor >::set_overflow_size ( size_t  size)
inline

Definition at line 73 of file decider_proving_key.hpp.

Member Data Documentation

◆ active_region_data

template<IsUltraOrMegaHonk Flavor>
ActiveRegionData bb::DeciderProvingKey_< Flavor >::active_region_data

Definition at line 70 of file decider_proving_key.hpp.

◆ alphas

template<IsUltraOrMegaHonk Flavor>
SubrelationSeparators bb::DeciderProvingKey_< Flavor >::alphas

Definition at line 56 of file decider_proving_key.hpp.

◆ commitment_key

template<IsUltraOrMegaHonk Flavor>
CommitmentKey bb::DeciderProvingKey_< Flavor >::commitment_key

Definition at line 68 of file decider_proving_key.hpp.

◆ final_active_wire_idx

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::final_active_wire_idx { 0 }
private

Definition at line 49 of file decider_proving_key.hpp.

◆ from_first_instance

template<IsUltraOrMegaHonk Flavor>
bool bb::DeciderProvingKey_< Flavor >::from_first_instance = false

Definition at line 63 of file decider_proving_key.hpp.

◆ gate_challenges

template<IsUltraOrMegaHonk Flavor>
std::vector<FF> bb::DeciderProvingKey_< Flavor >::gate_challenges

Definition at line 58 of file decider_proving_key.hpp.

◆ ipa_proof

template<IsUltraOrMegaHonk Flavor>
HonkProof bb::DeciderProvingKey_< Flavor >::ipa_proof

Definition at line 61 of file decider_proving_key.hpp.

◆ is_complete

template<IsUltraOrMegaHonk Flavor>
bool bb::DeciderProvingKey_< Flavor >::is_complete = false

Definition at line 64 of file decider_proving_key.hpp.

◆ is_structured

template<IsUltraOrMegaHonk Flavor>
bool bb::DeciderProvingKey_< Flavor >::is_structured
private

Definition at line 45 of file decider_proving_key.hpp.

◆ memory_read_records

template<IsUltraOrMegaHonk Flavor>
std::vector<uint32_t> bb::DeciderProvingKey_< Flavor >::memory_read_records

Definition at line 65 of file decider_proving_key.hpp.

◆ memory_write_records

template<IsUltraOrMegaHonk Flavor>
std::vector<uint32_t> bb::DeciderProvingKey_< Flavor >::memory_write_records

Definition at line 66 of file decider_proving_key.hpp.

◆ metadata

template<IsUltraOrMegaHonk Flavor>
MetaData bb::DeciderProvingKey_< Flavor >::metadata
private

Definition at line 47 of file decider_proving_key.hpp.

◆ NUM_WIRES

template<IsUltraOrMegaHonk Flavor>
constexpr size_t bb::DeciderProvingKey_< Flavor >::NUM_WIRES = Circuit::NUM_WIRES
staticconstexprprivate

Definition at line 223 of file decider_proving_key.hpp.

◆ num_zero_rows

template<IsUltraOrMegaHonk Flavor>
constexpr size_t bb::DeciderProvingKey_< Flavor >::num_zero_rows = Flavor::has_zero_row ? 1 : 0
staticconstexprprivate

Definition at line 222 of file decider_proving_key.hpp.

◆ overflow_size

template<IsUltraOrMegaHonk Flavor>
size_t bb::DeciderProvingKey_< Flavor >::overflow_size { 0 }
private

Definition at line 48 of file decider_proving_key.hpp.

◆ polynomials

template<IsUltraOrMegaHonk Flavor>
ProverPolynomials bb::DeciderProvingKey_< Flavor >::polynomials

Definition at line 55 of file decider_proving_key.hpp.

◆ public_inputs

template<IsUltraOrMegaHonk Flavor>
std::vector<FF> bb::DeciderProvingKey_< Flavor >::public_inputs

Definition at line 54 of file decider_proving_key.hpp.

◆ relation_parameters

template<IsUltraOrMegaHonk Flavor>
bb::RelationParameters<FF> bb::DeciderProvingKey_< Flavor >::relation_parameters

Definition at line 57 of file decider_proving_key.hpp.

◆ target_sum

template<IsUltraOrMegaHonk Flavor>
FF bb::DeciderProvingKey_< Flavor >::target_sum { 0 }

Definition at line 59 of file decider_proving_key.hpp.


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