Overview
Thepolycommit module implements polynomial commitment schemes that allow a prover to commit to a polynomial and later prove evaluations at specific points. The implementations are based on Kate-Zaverucha-Goldberg (KZG10) commitments.
KZG10
Overview
KZG10 is a polynomial commitment scheme based on elliptic curve pairings. It provides constant-size commitments and evaluation proofs.Setup
load_srs
Loads the structured reference string (SRS) for a given maximum degree.usize
Maximum polynomial degree supported
Result<UniversalParams<E>>
Universal parameters supporting polynomials up to max_degree
Commitment Operations
commit
Commits to a polynomial.&Powers<E>
Powers of the secret evaluation point
&Polynomial<'_, E::Fr>
The polynomial to commit to (dense or sparse)
Option<usize>
Optional hiding degree for zero-knowledge
Option<&mut dyn RngCore>
Random number generator (required if hiding_bound is Some)
Result<(KZGCommitment<E>, KZGRandomness<E>)>
Commitment and randomness (for later opening)
commit_lagrange
Commits to a polynomial given in Lagrange basis (evaluations).&LagrangeBasis<E>
Lagrange basis powers
&[E::Fr]
Polynomial evaluations over the domain
Result<(KZGCommitment<E>, KZGRandomness<E>)>
Commitment and randomness
Opening Proofs
open
Creates an evaluation proof at a specific point.&Powers<E>
Powers of the secret
&DensePolynomial<E::Fr>
The committed polynomial
E::Fr
Evaluation point
&KZGRandomness<E>
Randomness from commitment
Result<KZGProof<E>>
Evaluation proof
open_lagrange
Creates an evaluation proof from Lagrange evaluations.&[E::Fr]
Elements of the evaluation domain
&[E::Fr]
Polynomial evaluations
E::Fr
Evaluation point (must not be in domain)
E::Fr
Expected value at the point
Result<KZGProof<E>>
Evaluation proof
Verification
check
Verifies a single evaluation proof.&VerifierKey<E>
Verifier key
&KZGCommitment<E>
Polynomial commitment
E::Fr
Evaluation point
E::Fr
Claimed evaluation
&KZGProof<E>
Evaluation proof
Result<bool>
True if the proof is valid
batch_check
Verifies multiple evaluation proofs with a single pairing check.&[KZGCommitment<E>]
Vector of polynomial commitments
&[E::Fr]
Vector of evaluation points
&[E::Fr]
Vector of claimed evaluations
&[KZGProof<E>]
Vector of evaluation proofs
&mut R
Random number generator for challenge sampling
Result<bool>
True if all proofs are valid
SonicKZG10
Overview
SonicKZG10 extends KZG10 with batching and degree bound enforcement from the Sonic and AuroraLight protocols.Setup
trim
Specializes universal parameters for specific degree bounds and circuit sizes.&UniversalParams<E>
Universal parameters
usize
Maximum polynomial degree
impl IntoIterator<Item = usize>
Lagrange basis sizes to support
usize
Maximum hiding polynomial degree
Option<&[usize]>
Degree bounds to enforce
Result<(CommitterKey<E>, UniversalVerifier<E>)>
Committer key and universal verifier
Batched Operations
commit
Commits to multiple labeled polynomials.impl IntoIterator<Item = LabeledPolynomialWithBasis>
Labeled polynomials to commit to
Result<(Vec<LabeledCommitment>, Vec<Randomness>)>
Labeled commitments and randomness values
batch_open
Opens multiple polynomials at multiple points.impl ExactSizeIterator<Item = &'a LabeledPolynomial>
Polynomials to open
&QuerySet<E::Fr>
Set of (label, point) queries
impl ExactSizeIterator<Item = &'a Randomness>
Randomness from commitments
&mut S
Fiat-Shamir sponge
Result<BatchProof<E>>
Batch opening proof
batch_check
Verifies batch opening proofs.impl IntoIterator<Item = &'a LabeledCommitment>
Labeled commitments
&Evaluations<E::Fr>
Claimed evaluation values
&BatchProof<E>
Batch proof to verify
Result<bool>
True if the batch proof is valid
Key Structures
UniversalParams
Universal structured reference string.Powers
Powers of the secret for commitment.KZGCommitment
A polynomial commitment.KZGProof
An evaluation proof.KZGRandomness
Randomness used for hiding commitments.Degree Bounds
KZGDegreeBounds Enum
Specifies which degree bounds to enforce.Degree Bound Enforcement
Degree bounds are enforced by committing with shifted powers:Complete Example
See Also
- FFT Operations - Polynomial arithmetic
- SNARK Implementations - Uses polynomial commitments
- Cryptographic Hash Functions - Fiat-Shamir transformation