pub trait PolynomialCommitmentScheme {
type SRS: Clone + Debug + StructuredReferenceString;
type Polynomial: Clone + Debug + Hash + PartialEq + Eq;
type Point: Clone + Ord + Debug + Sync + Hash + PartialEq + Eq;
type Evaluation: Field;
type Commitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash;
type BatchCommitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash;
type BatchProof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
// Required methods
fn trim(
srs: impl Borrow<Self::SRS>,
supported_degree: usize,
supported_num_vars: Option<usize>,
) -> Result<(<Self::SRS as StructuredReferenceString>::ProverParam, <Self::SRS as StructuredReferenceString>::VerifierParam), PCSError>;
fn commit(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
poly: &Self::Polynomial,
) -> Result<Self::Commitment, PCSError>;
fn batch_commit(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polys: &[Self::Polynomial],
) -> Result<Self::BatchCommitment, PCSError>;
fn open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polynomial: &Self::Polynomial,
point: &Self::Point,
) -> Result<(Self::Proof, Self::Evaluation), PCSError>;
fn batch_open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
batch_commitment: &Self::BatchCommitment,
polynomials: &[Self::Polynomial],
points: &[Self::Point],
) -> Result<(Self::BatchProof, Vec<Self::Evaluation>), PCSError>;
fn verify(
verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam,
commitment: &Self::Commitment,
point: &Self::Point,
value: &Self::Evaluation,
proof: &Self::Proof,
) -> Result<bool, PCSError>;
fn batch_verify<R: RngCore + CryptoRng>(
verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam,
multi_commitment: &Self::BatchCommitment,
points: &[Self::Point],
values: &[Self::Evaluation],
batch_proof: &Self::BatchProof,
rng: &mut R,
) -> Result<bool, PCSError>;
// Provided methods
fn load_srs_from_file(
supported_degree: usize,
file: Option<&str>,
) -> Result<Self::SRS, PCSError> { ... }
fn multi_open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polynomial: &Self::Polynomial,
points: &[Self::Point],
) -> Result<(Vec<Self::Proof>, Vec<Self::Evaluation>), PCSError> { ... }
}
Expand description
This trait defines APIs for polynomial commitment schemes. Note that for our usage, this PCS is not hiding. TODO(#187): add hiding property.
Required Associated Types§
Sourcetype SRS: Clone + Debug + StructuredReferenceString
type SRS: Clone + Debug + StructuredReferenceString
Structured reference string
Sourcetype Evaluation: Field
type Evaluation: Field
Polynomial Evaluation
Sourcetype Commitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash
type Commitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash
Commitments
Sourcetype BatchCommitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq
type BatchCommitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq
Batch commitments
Required Methods§
Sourcefn trim(
srs: impl Borrow<Self::SRS>,
supported_degree: usize,
supported_num_vars: Option<usize>,
) -> Result<(<Self::SRS as StructuredReferenceString>::ProverParam, <Self::SRS as StructuredReferenceString>::VerifierParam), PCSError>
fn trim( srs: impl Borrow<Self::SRS>, supported_degree: usize, supported_num_vars: Option<usize>, ) -> Result<(<Self::SRS as StructuredReferenceString>::ProverParam, <Self::SRS as StructuredReferenceString>::VerifierParam), PCSError>
Trim the universal parameters to specialize the public parameters.
Input both supported_degree
for univariate and
supported_num_vars
for multilinear.
§Note on function signature
Usually, data structure like SRS and ProverParam are huge and users
might wish to keep them in heap using different kinds of smart pointers
(instead of only in stack) therefore our impl Borrow<_>
interface
allows for passing in any pointer type, e.g.: trim(srs: &Self::SRS, ..)
or trim(srs: Box<Self::SRS>, ..)
or trim(srs: Arc<Self::SRS>, ..)
etc.
Sourcefn commit(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
poly: &Self::Polynomial,
) -> Result<Self::Commitment, PCSError>
fn commit( prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>, poly: &Self::Polynomial, ) -> Result<Self::Commitment, PCSError>
Generate a binding (but not hiding) commitment for a polynomial
Sourcefn batch_commit(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polys: &[Self::Polynomial],
) -> Result<Self::BatchCommitment, PCSError>
fn batch_commit( prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>, polys: &[Self::Polynomial], ) -> Result<Self::BatchCommitment, PCSError>
Batch commit a list of polynomials
Sourcefn open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polynomial: &Self::Polynomial,
point: &Self::Point,
) -> Result<(Self::Proof, Self::Evaluation), PCSError>
fn open( prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>, polynomial: &Self::Polynomial, point: &Self::Point, ) -> Result<(Self::Proof, Self::Evaluation), PCSError>
On input a polynomial p
and a point point
, outputs a proof for the
same.
Sourcefn batch_open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
batch_commitment: &Self::BatchCommitment,
polynomials: &[Self::Polynomial],
points: &[Self::Point],
) -> Result<(Self::BatchProof, Vec<Self::Evaluation>), PCSError>
fn batch_open( prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>, batch_commitment: &Self::BatchCommitment, polynomials: &[Self::Polynomial], points: &[Self::Point], ) -> Result<(Self::BatchProof, Vec<Self::Evaluation>), PCSError>
Input a list of polynomials, and a same number of points, compute a batch opening for all the polynomials.
Sourcefn verify(
verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam,
commitment: &Self::Commitment,
point: &Self::Point,
value: &Self::Evaluation,
proof: &Self::Proof,
) -> Result<bool, PCSError>
fn verify( verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam, commitment: &Self::Commitment, point: &Self::Point, value: &Self::Evaluation, proof: &Self::Proof, ) -> Result<bool, PCSError>
Verifies that value
is the evaluation at x
of the polynomial
committed inside comm
.
Sourcefn batch_verify<R: RngCore + CryptoRng>(
verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam,
multi_commitment: &Self::BatchCommitment,
points: &[Self::Point],
values: &[Self::Evaluation],
batch_proof: &Self::BatchProof,
rng: &mut R,
) -> Result<bool, PCSError>
fn batch_verify<R: RngCore + CryptoRng>( verifier_param: &<Self::SRS as StructuredReferenceString>::VerifierParam, multi_commitment: &Self::BatchCommitment, points: &[Self::Point], values: &[Self::Evaluation], batch_proof: &Self::BatchProof, rng: &mut R, ) -> Result<bool, PCSError>
Verifies that value_i
is the evaluation at x_i
of the polynomial
poly_i
committed inside comm
.
Provided Methods§
Sourcefn load_srs_from_file(
supported_degree: usize,
file: Option<&str>,
) -> Result<Self::SRS, PCSError>
fn load_srs_from_file( supported_degree: usize, file: Option<&str>, ) -> Result<Self::SRS, PCSError>
Load public parameter in production environment.
These parameters are loaded from files with serialized pp
bytes, and
the actual setup is usually carried out via MPC and should be
implemented else where. We only load them into memory here.
If file=None
, we load the default choice of SRS.
Sourcefn multi_open(
prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>,
polynomial: &Self::Polynomial,
points: &[Self::Point],
) -> Result<(Vec<Self::Proof>, Vec<Self::Evaluation>), PCSError>
fn multi_open( prover_param: impl Borrow<<Self::SRS as StructuredReferenceString>::ProverParam>, polynomial: &Self::Polynomial, points: &[Self::Point], ) -> Result<(Vec<Self::Proof>, Vec<Self::Evaluation>), PCSError>
Open a single polynomial at multiple points. The naive default implementation just open them individually.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.