Nova/src/traits/evaluation.rs
src/traits/evaluation.rsRaw
1//! This module defines a collection of traits that define the behavior of a polynomial evaluation engine
2//! A vector of size N is treated as a multilinear polynomial in \log{N} variables,
3//! and a commitment provided by the commitment engine is treated as a multilinear polynomial commitment
4use crate::{
5 errors::NovaError,
6 traits::{commitment::CommitmentEngineTrait, Group},
7};
8use merlin::Transcript;
9use serde::{Deserialize, Serialize};
10
11/// A trait that ties different pieces of the commitment evaluation together
12pub trait EvaluationEngineTrait<G: Group>:
13 Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>
14{
15 /// A type that holds the associated commitment engine
16 type CE: CommitmentEngineTrait<G>;
17
18 /// A type that holds generators
19 type EvaluationGens: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
20
21 /// A type that holds the evaluation argument
22 type EvaluationArgument: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
23
24 /// A method to perform any additional setup needed to produce proofs of evaluations
25 fn setup(gens: &<Self::CE as CommitmentEngineTrait<G>>::CommitmentGens) -> Self::EvaluationGens;
26
27 /// A method to prove evaluations of a batch of polynomials
28 fn prove_batch(
29 gens: &Self::EvaluationGens,
30 transcript: &mut Transcript,
31 comm: &[<Self::CE as CommitmentEngineTrait<G>>::Commitment],
32 polys: &[Vec<G::Scalar>],
33 points: &[Vec<G::Scalar>],
34 evals: &[G::Scalar],
35 ) -> Result<Self::EvaluationArgument, NovaError>;
36
37 /// A method to verify purported evaluations of a batch of polynomials
38 fn verify_batch(
39 gens: &Self::EvaluationGens,
40 transcript: &mut Transcript,
41 comm: &[<Self::CE as CommitmentEngineTrait<G>>::Commitment],
42 points: &[Vec<G::Scalar>],
43 evals: &[G::Scalar],
44 arg: &Self::EvaluationArgument,
45 ) -> Result<(), NovaError>;
46}