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>

Classes

struct  CommitBatch
 

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.
 
std::span< Commitmentget_monomial_points () const
 
size_t get_monomial_size () const
 
Commitment commit (PolynomialSpan< const Fr > polynomial, bool has_duplicates_hint=false) const
 Uses the ProverSRS to create a commitment to p(X)
 
std::vector< Commitmentbatch_commit (RefSpan< Polynomial< Fr > > polynomials, std::span< const uint32_t > dedup_infos={}) const
 Batch commitment to multiple polynomials.
 
CommitBatch start_batch ()
 

Static Public Member Functions

static constexpr size_t round_up_to_even (size_t n)
 

Public Attributes

size_t srs_size
 

Protected Attributes

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

Private Types

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

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 39 of file commitment_key.hpp.

Member Typedef Documentation

◆ Commitment

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

Definition at line 42 of file commitment_key.hpp.

◆ Fr

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

Definition at line 41 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
num_pointsNumber of points needed for commitments. Always rounded up to the next even value so that callers which need one extra SRS point (e.g. sparse masking polynomials that round their top pair up to an even index) always fit.

Definition at line 61 of file commitment_key.hpp.

Member Function Documentation

◆ batch_commit()

template<class Curve >
std::vector< Commitment > bb::CommitmentKey< Curve >::batch_commit ( RefSpan< Polynomial< Fr > >  polynomials,
std::span< const uint32_t >  dedup_infos = {} 
) const
inline

Batch commitment to multiple polynomials.

Uses batch_multi_scalar_mul for more efficient processing when committing to multiple polynomials. The input polynomials are not const because batch_mul modifies them and then restores them back.

Parameters
polynomialsvector of polynomial spans to commit to
has_duplicates_hintsoptional per-polynomial hints (parallel to polynomials): a non-zero entry opts that polynomial's MSM into the dedup pre-pass.
Returns
std::vector<Commitment> vector of commitments, one for each polynomial

Definition at line 104 of file commitment_key.hpp.

◆ commit()

template<class Curve >
Commitment bb::CommitmentKey< Curve >::commit ( PolynomialSpan< const Fr polynomial,
bool  has_duplicates_hint = false 
) 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 81 of file commitment_key.hpp.

◆ get_monomial_points()

template<class Curve >
std::span< Commitment > bb::CommitmentKey< Curve >::get_monomial_points ( ) const
inline

Definition at line 72 of file commitment_key.hpp.

◆ get_monomial_size()

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

Definition at line 73 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 70 of file commitment_key.hpp.

◆ round_up_to_even()

template<class Curve >
static constexpr size_t bb::CommitmentKey< Curve >::round_up_to_even ( size_t  n)
inlinestaticconstexpr

Definition at line 52 of file commitment_key.hpp.

◆ start_batch()

template<class Curve >
CommitBatch bb::CommitmentKey< Curve >::start_batch ( )
inline

Definition at line 158 of file commitment_key.hpp.

Member Data Documentation

◆ srs

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

Definition at line 45 of file commitment_key.hpp.

◆ srs_size

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

Definition at line 48 of file commitment_key.hpp.


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