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

CommitmentKey object over a pairing group 𝔾₁. More...

#include <commitment_key.hpp>

Public Types

enum class  CommitType { Default , Structured , Sparse , StructuredNonZeroComplement }
 

Public Member Functions

 CommitmentKey ()=default
 
 CommitmentKey (const size_t num_points)
 Construct a new Kate Commitment Key object from existing SRS.
 
bool initialized () const
 Checks the commitment key is properly initialized.
 
Commitment commit (PolynomialSpan< const Fr > polynomial) const
 Uses the ProverSRS to create a commitment to p(X)
 
Commitment commit_structured (PolynomialSpan< const Fr > polynomial, const std::vector< std::pair< size_t, size_t > > &active_ranges, size_t final_active_wire_idx=0)
 Efficiently commit to a polynomial whose nonzero elements are arranged in discrete blocks.
 
Commitment commit_structured_with_nonzero_complement (PolynomialSpan< const Fr > polynomial, const std::vector< std::pair< size_t, size_t > > &active_ranges, size_t final_active_wire_idx=0)
 Efficiently commit to a polynomial with discrete blocks of arbitrary elements and constant elements.
 
Commitment commit_with_type (PolynomialSpan< const Fr > poly, CommitType type, const std::vector< std::pair< size_t, size_t > > &active_ranges={}, size_t final_active_wire_idx=0)
 

Public Attributes

std::shared_ptr< srs::factories::Crs< Curve > > srs
 
size_t dyadic_size
 

Private Types

using Fr = typename Curve::ScalarField
 
using Commitment = typename Curve::AffineElement
 
using G1 = typename Curve::AffineElement
 

Static Private Member Functions

static size_t get_num_needed_srs_points (size_t num_points)
 

Static Private Attributes

static constexpr size_t EXTRA_SRS_POINTS_FOR_ECCVM_IPA = 1
 

Detailed Description

template<class Curve>
class bb::CommitmentKey< Curve >

CommitmentKey object over a pairing group 𝔾₁.

Commitments are computed as C = [p(x)] = ∑ᵢ aᵢ⋅Gᵢ where Gᵢ is the i-th element of the SRS. For BN254, the SRS is given as a list of 𝔾₁ points { [xʲ]₁ }ⱼ where 'x' is unknown. For Grumpkin, they are random points. The SRS stored in the commitment key is after applying the pippenger_point_table thus being double the size of what is loaded from path.

Definition at line 40 of file commitment_key.hpp.

Member Typedef Documentation

◆ Commitment

template<class Curve >
using bb::CommitmentKey< Curve >::Commitment = typename Curve::AffineElement
private

Definition at line 43 of file commitment_key.hpp.

◆ Fr

template<class Curve >
using bb::CommitmentKey< Curve >::Fr = typename Curve::ScalarField
private

Definition at line 42 of file commitment_key.hpp.

◆ G1

template<class Curve >
using bb::CommitmentKey< Curve >::G1 = typename Curve::AffineElement
private

Definition at line 44 of file commitment_key.hpp.

Member Enumeration Documentation

◆ CommitType

template<class Curve >
enum class bb::CommitmentKey::CommitType
strong
Enumerator
Default 
Structured 
Sparse 
StructuredNonZeroComplement 

Definition at line 256 of file commitment_key.hpp.

Constructor & Destructor Documentation

◆ CommitmentKey() [1/2]

template<class Curve >
bb::CommitmentKey< Curve >::CommitmentKey ( )
default

◆ CommitmentKey() [2/2]

template<class Curve >
bb::CommitmentKey< Curve >::CommitmentKey ( const size_t  num_points)
inline

Construct a new Kate Commitment Key object from existing SRS.

Parameters
n
path

Definition at line 70 of file commitment_key.hpp.

Member Function Documentation

◆ commit()

template<class Curve >
Commitment bb::CommitmentKey< Curve >::commit ( PolynomialSpan< const Fr polynomial) const
inline

Uses the ProverSRS to create a commitment to p(X)

Parameters
polynomiala univariate polynomial p(X) = ∑ᵢ aᵢ⋅Xⁱ
Returns
Commitment computed as C = [p(x)] = ∑ᵢ aᵢ⋅Gᵢ

Definition at line 87 of file commitment_key.hpp.

◆ commit_structured()

template<class Curve >
Commitment bb::CommitmentKey< Curve >::commit_structured ( PolynomialSpan< const Fr polynomial,
const std::vector< std::pair< size_t, size_t > > &  active_ranges,
size_t  final_active_wire_idx = 0 
)
inline

Efficiently commit to a polynomial whose nonzero elements are arranged in discrete blocks.

Given a set of ranges where the polynomial takes non-zero values, copy the non-zero inputs (scalars, points) into contiguous memory and commit to them using the normal pippenger algorithm. Defaults to the conventional commit method if the number of non-zero entries is beyond a threshold relative to the full polynomial size.

Note
The wire polynomials have the described form when a structured execution trace is in use.
Warning
Method makes a copy of all {point, scalar} pairs that comprise the reduced input. May not be efficient in terms of memory or computation for polynomials beyond a certain sparseness threshold.
Parameters
polynomial
active_ranges
Returns
Commitment

Definition at line 121 of file commitment_key.hpp.

◆ commit_structured_with_nonzero_complement()

template<class Curve >
Commitment bb::CommitmentKey< Curve >::commit_structured_with_nonzero_complement ( PolynomialSpan< const Fr polynomial,
const std::vector< std::pair< size_t, size_t > > &  active_ranges,
size_t  final_active_wire_idx = 0 
)
inline

Efficiently commit to a polynomial with discrete blocks of arbitrary elements and constant elements.

Similar to method commit_structured() except the complement to the "active" region cantains non-zero constant values (which are assumed to differ between blocks). This is exactly the structure of the permutation grand product polynomial z_perm when a structured execution trace is in use.

Warning
Requires a copy of all {point, scalar} pairs (including endo points) corresponding to the primary blocks and a copy of all of the points (without endo points) corresponding to their complement.
Parameters
polynomial
active_ranges
Returns
Commitment

Definition at line 183 of file commitment_key.hpp.

◆ commit_with_type()

template<class Curve >
Commitment bb::CommitmentKey< Curve >::commit_with_type ( PolynomialSpan< const Fr poly,
CommitType  type,
const std::vector< std::pair< size_t, size_t > > &  active_ranges = {},
size_t  final_active_wire_idx = 0 
)
inline

Definition at line 258 of file commitment_key.hpp.

◆ get_num_needed_srs_points()

template<class Curve >
static size_t bb::CommitmentKey< Curve >::get_num_needed_srs_points ( size_t  num_points)
inlinestaticprivate

Definition at line 47 of file commitment_key.hpp.

◆ initialized()

template<class Curve >
bool bb::CommitmentKey< Curve >::initialized ( ) const
inline

Checks the commitment key is properly initialized.

Returns
bool

Definition at line 79 of file commitment_key.hpp.

Member Data Documentation

◆ dyadic_size

template<class Curve >
size_t bb::CommitmentKey< Curve >::dyadic_size

Definition at line 59 of file commitment_key.hpp.

◆ EXTRA_SRS_POINTS_FOR_ECCVM_IPA

template<class Curve >
constexpr size_t bb::CommitmentKey< Curve >::EXTRA_SRS_POINTS_FOR_ECCVM_IPA = 1
staticconstexprprivate

Definition at line 45 of file commitment_key.hpp.

◆ srs

template<class Curve >
std::shared_ptr<srs::factories::Crs<Curve> > bb::CommitmentKey< Curve >::srs

Definition at line 58 of file commitment_key.hpp.


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