arnaucube
arnaucube/hyperplonkPublic Self-hosted repository
hyperplonk/pcs/src/lib.rs
pcs/src/lib.rsRaw
 1mod commit;
 2mod errors;
 3mod param;
 4
 5use ark_ec::PairingEngine;
 6use ark_poly::MultilinearExtension;
 7use ark_std::rand::RngCore;
 8use std::marker::PhantomData;
 9
10pub use errors::PCSErrors;
11pub use param::{ProverParam, UniversalParams, VerifierParam};
12
13/// KZG Polynomial Commitment Scheme on multilinear extensions.
14pub struct KZGMultilinearPC<E: PairingEngine> {
15    phantom: PhantomData<E>,
16}
17
18pub trait MultilinearCommitmentScheme<E: PairingEngine> {
19    type ProverParam;
20    type VerifierParam;
21    type SRS;
22    type Commitment;
23    type Proof;
24
25    /// Generate SRS from RNG.
26    /// WARNING: THIS FUNCTION IS FOR TESTING PURPOSE ONLY.
27    /// THE OUTPUT SRS SHOULD NOT BE USED IN PRODUCTION.
28    fn setup<R: RngCore>(rng: &mut R, num_vars: usize) -> Result<Self::SRS, PCSErrors>;
29
30    /// Generate a commitment for a polynomial
31    fn commit(
32        prover_param: &Self::ProverParam,
33        poly: &impl MultilinearExtension<E::Fr>,
34    ) -> Result<Self::Commitment, PCSErrors>;
35
36    /// On input a polynomial `p` and a point `point`, outputs a proof for the
37    /// same.
38    fn open(
39        prover_param: &Self::ProverParam,
40        polynomial: &impl MultilinearExtension<E::Fr>,
41        point: &[E::Fr],
42    ) -> Result<Self::Proof, PCSErrors>;
43
44    /// Verifies that `value` is the evaluation at `x` of the polynomial
45    /// committed inside `comm`.
46    fn verify(
47        verifier_param: &Self::VerifierParam,
48        commitment: &Self::Commitment,
49        point: &[E::Fr],
50        value: E::Fr,
51        proof: &Self::Proof,
52    ) -> Result<bool, PCSErrors>;
53}