snark_verifier/
verifier.rs

1//! Verifiers for (S)NARK.
2
3use crate::{
4    loader::Loader,
5    util::{arithmetic::CurveAffine, transcript::TranscriptRead},
6    Error,
7};
8use std::fmt::Debug;
9
10pub mod plonk;
11
12/// (S)NARK verifier for verifying a (S)NARK.
13pub trait SnarkVerifier<C, L>
14where
15    C: CurveAffine,
16    L: Loader<C>,
17{
18    /// Verifying key for subroutines if any.
19    type VerifyingKey: Clone + Debug;
20    /// Protocol specifying configuration of a (S)NARK.
21    type Protocol: Clone + Debug;
22    /// Structured proof read from transcript.
23    type Proof: Clone + Debug;
24    /// Output of verification.
25    type Output: Clone + Debug;
26
27    /// Read [`SnarkVerifier::Proof`] from transcript.
28    fn read_proof<T>(
29        vk: &Self::VerifyingKey,
30        protocol: &Self::Protocol,
31        instances: &[Vec<L::LoadedScalar>],
32        transcript: &mut T,
33    ) -> Result<Self::Proof, Error>
34    where
35        T: TranscriptRead<C, L>;
36
37    /// Verify [`SnarkVerifier::Proof`] and output [`SnarkVerifier::Output`].
38    fn verify(
39        vk: &Self::VerifyingKey,
40        protocol: &Self::Protocol,
41        instances: &[Vec<L::LoadedScalar>],
42        proof: &Self::Proof,
43    ) -> Result<Self::Output, Error>;
44}