lambdaworks_crypto/commitments/
traits.rs

1use lambdaworks_math::{
2    field::{element::FieldElement, traits::IsField},
3    polynomial::Polynomial,
4};
5
6pub trait IsCommitmentScheme<F: IsField> {
7    type Commitment;
8
9    /// Create a commitment to a polynomial
10    fn commit(&self, p: &Polynomial<FieldElement<F>>) -> Self::Commitment;
11
12    /// Create an evaluation proof for a polynomial at x equal to y
13    /// p(x) = y
14    fn open(
15        &self,
16        x: &FieldElement<F>,
17        y: &FieldElement<F>,
18        p: &Polynomial<FieldElement<F>>,
19    ) -> Self::Commitment;
20
21    /// Create an evaluation proof for a slice of polynomials at x equal to y_i
22    /// that is, we show that we evaluated correctly p_i (x) = y_i
23    fn open_batch(
24        &self,
25        x: &FieldElement<F>,
26        y: &[FieldElement<F>],
27        p: &[Polynomial<FieldElement<F>>],
28        upsilon: &FieldElement<F>,
29    ) -> Self::Commitment;
30
31    /// Verify an evaluation proof given the commitment to p, the point x and the evaluation y
32    fn verify(
33        &self,
34        x: &FieldElement<F>,
35        y: &FieldElement<F>,
36        p_commitment: &Self::Commitment,
37        proof: &Self::Commitment,
38    ) -> bool;
39
40    /// Verify an evaluation proof given the commitments to p, the point x and the evaluations ys
41    fn verify_batch(
42        &self,
43        x: &FieldElement<F>,
44        ys: &[FieldElement<F>],
45        p_commitments: &[Self::Commitment],
46        proof: &Self::Commitment,
47        upsilon: &FieldElement<F>,
48    ) -> bool;
49}