arnaucube
arnaucube/NovaPublic Self-hosted repository
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 serde::{Deserialize, Serialize};
 9
10/// A trait that ties different pieces of the commitment evaluation together
11pub trait EvaluationEngineTrait<G: Group>:
12  Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>
13{
14  /// A type that holds the associated commitment engine
15  type CE: CommitmentEngineTrait<G>;
16
17  /// A type that holds generators
18  type EvaluationGens: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
19
20  /// A type that holds the evaluation argument
21  type EvaluationArgument: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
22
23  /// A method to perform any additional setup needed to produce proofs of evaluations
24  fn setup(gens: &<Self::CE as CommitmentEngineTrait<G>>::CommitmentGens) -> Self::EvaluationGens;
25
26  /// A method to prove the evaluation of a multilinear polynomial
27  fn prove(
28    gens: &Self::EvaluationGens,
29    transcript: &mut G::TE,
30    comm: &<Self::CE as CommitmentEngineTrait<G>>::Commitment,
31    poly: &[G::Scalar],
32    point: &[G::Scalar],
33    eval: &G::Scalar,
34  ) -> Result<Self::EvaluationArgument, NovaError>;
35
36  /// A method to verify the purported evaluation of a multilinear polynomials
37  fn verify(
38    gens: &Self::EvaluationGens,
39    transcript: &mut G::TE,
40    comm: &<Self::CE as CommitmentEngineTrait<G>>::Commitment,
41    point: &[G::Scalar],
42    eval: &G::Scalar,
43    arg: &Self::EvaluationArgument,
44  ) -> Result<(), NovaError>;
45}