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 the prover key
18  type ProverKey: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
19
20  /// A type that holds the verifier key
21  type VerifierKey: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
22
23  /// A type that holds the evaluation argument
24  type EvaluationArgument: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>;
25
26  /// A method to perform any additional setup needed to produce proofs of evaluations
27  fn setup(
28    ck: &<Self::CE as CommitmentEngineTrait<G>>::CommitmentKey,
29  ) -> (Self::ProverKey, Self::VerifierKey);
30
31  /// A method to prove the evaluation of a multilinear polynomial
32  fn prove(
33    ck: &<Self::CE as CommitmentEngineTrait<G>>::CommitmentKey,
34    pk: &Self::ProverKey,
35    transcript: &mut G::TE,
36    comm: &<Self::CE as CommitmentEngineTrait<G>>::Commitment,
37    poly: &[G::Scalar],
38    point: &[G::Scalar],
39    eval: &G::Scalar,
40  ) -> Result<Self::EvaluationArgument, NovaError>;
41
42  /// A method to verify the purported evaluation of a multilinear polynomials
43  fn verify(
44    vk: &Self::VerifierKey,
45    transcript: &mut G::TE,
46    comm: &<Self::CE as CommitmentEngineTrait<G>>::Commitment,
47    point: &[G::Scalar],
48    eval: &G::Scalar,
49    arg: &Self::EvaluationArgument,
50  ) -> Result<(), NovaError>;
51}