jf_pcs

Trait PolynomialCommitmentScheme

Source
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§

Source

type SRS: Clone + Debug + StructuredReferenceString

Structured reference string

Source

type Polynomial: Clone + Debug + Hash + PartialEq + Eq

Polynomial and its associated types

Source

type Point: Clone + Ord + Debug + Sync + Hash + PartialEq + Eq

Polynomial input domain

Source

type Evaluation: Field

Polynomial Evaluation

Source

type Commitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash

Commitments

Source

type BatchCommitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq

Batch commitments

Source

type Proof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq + Hash

Proofs

Source

type BatchProof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq

Batch proofs

Required Methods§

Source

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.

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

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§

Source

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.

Source

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.

Implementors§

Source§

impl<E: Pairing> PolynomialCommitmentScheme for MultilinearKzgPCS<E>

Source§

type SRS = (MultilinearUniversalParams<E>, UnivariateUniversalParams<E>)

Source§

type Polynomial = Arc<DenseMultilinearExtension<<E as Pairing>::ScalarField>>

Source§

type Point = Vec<<E as Pairing>::ScalarField>

Source§

type Evaluation = <E as Pairing>::ScalarField

Source§

type Commitment = Commitment<E>

Source§

type BatchCommitment = Commitment<E>

Source§

type Proof = MultilinearKzgProof<E>

Source§

type BatchProof = MultilinearKzgBatchProof<E>

Source§

impl<E: Pairing> PolynomialCommitmentScheme for UnivariateKzgPCS<E>

Source§

type SRS = UnivariateUniversalParams<E>

Source§

type Polynomial = DensePolynomial<<E as Pairing>::ScalarField>

Source§

type Point = <E as Pairing>::ScalarField

Source§

type Evaluation = <E as Pairing>::ScalarField

Source§

type Commitment = Commitment<E>

Source§

type BatchCommitment = Vec<<UnivariateKzgPCS<E> as PolynomialCommitmentScheme>::Commitment>

Source§

type Proof = UnivariateKzgProof<E>

Source§

type BatchProof = Vec<UnivariateKzgProof<E>>