pub struct HyraxPC<G: AffineRepr, P: MultilinearExtension<G::ScalarField>> { /* private fields */ }
Expand description
Hyrax polynomial committment scheme: A polynomial commitment scheme based on the hardness of the discrete logarithm problem in prime-order groups. This is a Fiat-Shamired version of the PCS described in the Hyrax paper [WTsTW17].
§Future optimisations
- Add parallelisation. There is at least one natural place where parallelisation could bring performance gains: in essence, the prover commits to the polynomial by expressing it as an evaluation matrix and Pederson-multi-committing to each row. Each of this commitments can be computed independently from the rest, and therefore, in parallel. It is still to be seen how much of an improvement this would entail, since each Pederson multi-commitment boils down to a multi-exponentiation and this operation is itself parallelised.
- Due to the homomorphic nature of Pedersen commitments, it is likely
some of the following methods can be designed more efficiently than their
default implementations:
batch_open
,batch_check
,open_combinations
,check_combinations
. This is not discussed in the reference article, but the IPA and KZG modules might be a good starting point. - On a related note to the previous point, there might be a more
efficient way to open several polynomials at a single point (this is the
functionality of the
open
method) than the currently implemented technique, where only the computation of the vectorsL
andR
is shared across polynomials. - The cited article proposes an optimisation in the section Reducing the cost of proof-of-dot-prod. It allows for non-square matrices (and hence removes the requirement for the number of variables to be even) and introduces a tradeoff between proof size and verifier time. It is probably worth pursuing.
Trait Implementations§
Source§impl<G, P> PolynomialCommitment<<G as AffineRepr>::ScalarField, P> for HyraxPC<G, P>
impl<G, P> PolynomialCommitment<<G as AffineRepr>::ScalarField, P> for HyraxPC<G, P>
Source§fn setup<R: RngCore>(
_max_degree: usize,
num_vars: Option<usize>,
_rng: &mut R,
) -> Result<Self::UniversalParams, Self::Error>
fn setup<R: RngCore>( _max_degree: usize, num_vars: Option<usize>, _rng: &mut R, ) -> Result<Self::UniversalParams, Self::Error>
Outputs mock universal parameters for the Hyrax polynomial commitment scheme. It does not return random keys across calls and should never be used in settings where security is required - it is only useful for testing.
§Panics
Panics if num_vars
is None or contains an odd value.
Source§fn trim(
pp: &Self::UniversalParams,
_supported_degree: usize,
_supported_hiding_bound: usize,
_enforced_degree_bounds: Option<&[usize]>,
) -> Result<(Self::CommitterKey, Self::VerifierKey), Self::Error>
fn trim( pp: &Self::UniversalParams, _supported_degree: usize, _supported_hiding_bound: usize, _enforced_degree_bounds: Option<&[usize]>, ) -> Result<(Self::CommitterKey, Self::VerifierKey), Self::Error>
Trims a key into a prover key and a verifier key. This should only amount to discarding some of the points in said key if the prover and verifier only wish to commit to polynomials with fewer variables than the key can support. Since the number of variables is not considered in the prototype, this function currently simply clones the key.
Source§fn commit<'a>(
ck: &Self::CommitterKey,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
rng: Option<&mut dyn RngCore>,
) -> Result<(Vec<LabeledCommitment<Self::Commitment>>, Vec<Self::CommitmentState>), Self::Error>where
P: 'a,
fn commit<'a>(
ck: &Self::CommitterKey,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
rng: Option<&mut dyn RngCore>,
) -> Result<(Vec<LabeledCommitment<Self::Commitment>>, Vec<Self::CommitmentState>), Self::Error>where
P: 'a,
Produces a list of commitments to the passed polynomials. Cf. the section “Square-root commitment scheme” from the reference article.
§Panics
Panics if rng
is None, since Hyrax requires randomness in order to
commit to a polynomial
Source§fn open<'a>(
ck: &Self::CommitterKey,
labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
point: &'a P::Point,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<Self::Proof, Self::Error>where
Self::Commitment: 'a,
Self::CommitmentState: 'a,
P: 'a,
fn open<'a>(
ck: &Self::CommitterKey,
labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
point: &'a P::Point,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<Self::Proof, Self::Error>where
Self::Commitment: 'a,
Self::CommitmentState: 'a,
P: 'a,
Opens a list of polynomial commitments at a desired point. This
requires the list of original polynomials (labeled_polynomials
) as
well as the random values using by the Pedersen multi-commits during
the commitment phase (randomness
). Cf. sections “Square-root
commitment scheme” and appendix A.2 from the reference article.
§Panics
Panics if
rng
is None, since Hyrax requires randomness in order to open the commitment to a polynomial.- The point doesn’t have an even number of variables.
- The labels of a commitment doesn’t match that of the corresponding polynomial.
- The number of variables of a polynomial doesn’t match that of the point.
Source§fn check<'a>(
vk: &Self::VerifierKey,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
point: &'a P::Point,
_values: impl IntoIterator<Item = G::ScalarField>,
proof: &Self::Proof,
sponge: &mut impl CryptographicSponge,
_rng: Option<&mut dyn RngCore>,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
fn check<'a>(
vk: &Self::VerifierKey,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
point: &'a P::Point,
_values: impl IntoIterator<Item = G::ScalarField>,
proof: &Self::Proof,
sponge: &mut impl CryptographicSponge,
_rng: Option<&mut dyn RngCore>,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
Verifies a list of opening proofs and confirms the evaluation of the committed polynomials at the desired point.
§Panics
- If the point doesn’t have an even number of variables.
- If the length of a commitment does not correspond to the length of the point (specifically, commitment length should be 2^(point-length/2)).
§Disregarded arguments
rng
Source§type UniversalParams = HyraxUniversalParams<G>
type UniversalParams = HyraxUniversalParams<G>
Self::CommitterKey
and Self::VerifierKey
by Self::trim
.Source§type CommitterKey = HyraxUniversalParams<G>
type CommitterKey = HyraxUniversalParams<G>
Source§type VerifierKey = HyraxUniversalParams<G>
type VerifierKey = HyraxUniversalParams<G>
Source§type Commitment = HyraxCommitment<G>
type Commitment = HyraxCommitment<G>
Source§type CommitmentState = HyraxCommitmentState<<G as AffineRepr>::ScalarField>
type CommitmentState = HyraxCommitmentState<<G as AffineRepr>::ScalarField>
commit
phase.
It contains information that can be reused by the committer
during the open
phase, such as the commitment randomness.
Not to be shared with the verifier.Source§type Proof = Vec<HyraxProof<G>>
type Proof = Vec<HyraxProof<G>>
Source§type BatchProof = Vec<<HyraxPC<G, P> as PolynomialCommitment<<G as AffineRepr>::ScalarField, P>>::Proof>
type BatchProof = Vec<<HyraxPC<G, P> as PolynomialCommitment<<G as AffineRepr>::ScalarField, P>>::Proof>
Source§fn batch_open<'a>(
ck: &Self::CommitterKey,
labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<Self::BatchProof, Self::Error>where
P: 'a,
Self::CommitmentState: 'a,
Self::Commitment: 'a,
fn batch_open<'a>(
ck: &Self::CommitterKey,
labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<Self::BatchProof, Self::Error>where
P: 'a,
Self::CommitmentState: 'a,
Self::Commitment: 'a,
Source§fn batch_check<'a, R: RngCore>(
vk: &Self::VerifierKey,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
evaluations: &Evaluations<P::Point, F>,
proof: &Self::BatchProof,
sponge: &mut impl CryptographicSponge,
rng: &mut R,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
fn batch_check<'a, R: RngCore>(
vk: &Self::VerifierKey,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
evaluations: &Evaluations<P::Point, F>,
proof: &Self::BatchProof,
sponge: &mut impl CryptographicSponge,
rng: &mut R,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
Source§fn open_combinations<'a>(
ck: &Self::CommitterKey,
linear_combinations: impl IntoIterator<Item = &'a LinearCombination<F>>,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<BatchLCProof<F, Self::BatchProof>, Self::Error>where
Self::CommitmentState: 'a,
Self::Commitment: 'a,
P: 'a,
fn open_combinations<'a>(
ck: &Self::CommitterKey,
linear_combinations: impl IntoIterator<Item = &'a LinearCombination<F>>,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
query_set: &QuerySet<P::Point>,
sponge: &mut impl CryptographicSponge,
states: impl IntoIterator<Item = &'a Self::CommitmentState>,
rng: Option<&mut dyn RngCore>,
) -> Result<BatchLCProof<F, Self::BatchProof>, Self::Error>where
Self::CommitmentState: 'a,
Self::Commitment: 'a,
P: 'a,
Source§fn check_combinations<'a, R: RngCore>(
vk: &Self::VerifierKey,
linear_combinations: impl IntoIterator<Item = &'a LinearCombination<F>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
eqn_query_set: &QuerySet<P::Point>,
eqn_evaluations: &Evaluations<P::Point, F>,
proof: &BatchLCProof<F, Self::BatchProof>,
sponge: &mut impl CryptographicSponge,
rng: &mut R,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
fn check_combinations<'a, R: RngCore>(
vk: &Self::VerifierKey,
linear_combinations: impl IntoIterator<Item = &'a LinearCombination<F>>,
commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
eqn_query_set: &QuerySet<P::Point>,
eqn_evaluations: &Evaluations<P::Point, F>,
proof: &BatchLCProof<F, Self::BatchProof>,
sponge: &mut impl CryptographicSponge,
rng: &mut R,
) -> Result<bool, Self::Error>where
Self::Commitment: 'a,
Auto Trait Implementations§
impl<G, P> Freeze for HyraxPC<G, P>
impl<G, P> RefUnwindSafe for HyraxPC<G, P>where
G: RefUnwindSafe,
P: RefUnwindSafe,
impl<G, P> Send for HyraxPC<G, P>where
P: Send,
impl<G, P> Sync for HyraxPC<G, P>
impl<G, P> Unpin for HyraxPC<G, P>
impl<G, P> UnwindSafe for HyraxPC<G, P>where
G: UnwindSafe,
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more