//! This module defines a collection of traits that define the behavior of a zkSNARK for RelaxedR1CS use crate::{ errors::NovaError, r1cs::{R1CSGens, R1CSShape, RelaxedR1CSInstance, RelaxedR1CSWitness}, traits::Group, }; use serde::{Deserialize, Serialize}; /// A trait that defines the behavior of a zkSNARK's prover key pub trait ProverKeyTrait: Send + Sync { /// Produces a new prover's key fn new(gens: &R1CSGens, S: &R1CSShape) -> Self; } /// A trait that defines the behavior of a zkSNARK's verifier key pub trait VerifierKeyTrait: Send + Sync { /// Produces a new verifier's key fn new(gens: &R1CSGens, S: &R1CSShape) -> Self; } /// A trait that defines the behavior of a zkSNARK pub trait RelaxedR1CSSNARKTrait: Sized + Send + Sync + Serialize + for<'de> Deserialize<'de> { /// A type that represents the prover's key type ProverKey: ProverKeyTrait + Serialize + for<'de> Deserialize<'de>; /// A type that represents the verifier's key type VerifierKey: VerifierKeyTrait + Serialize + for<'de> Deserialize<'de>; /// Produces a prover key fn prover_key(gens: &R1CSGens, S: &R1CSShape) -> Self::ProverKey { Self::ProverKey::new(gens, S) } /// Produces a verifier key fn verifier_key(gens: &R1CSGens, S: &R1CSShape) -> Self::VerifierKey { Self::VerifierKey::new(gens, S) } /// Produces a new SNARK for a relaxed R1CS fn prove( pk: &Self::ProverKey, U: &RelaxedR1CSInstance, W: &RelaxedR1CSWitness, ) -> Result; /// Verifies a SNARK for a relaxed R1CS fn verify(&self, vk: &Self::VerifierKey, U: &RelaxedR1CSInstance) -> Result<(), NovaError>; }