diff --git a/src/supernova/snark.rs b/src/supernova/snark.rs index fc73ca0a7..4336645f7 100644 --- a/src/supernova/snark.rs +++ b/src/supernova/snark.rs @@ -12,10 +12,25 @@ use crate::{ }; use crate::{errors::NovaError, scalar_as_base, RelaxedR1CSInstance, NIFS}; +use abomonation::Abomonation; +use abomonation_derive::Abomonation; use ff::PrimeField; +use serde::{Deserialize, Serialize}; use std::marker::PhantomData; /// A type that holds the prover key for `CompressedSNARK` +#[derive(Clone, Serialize, Deserialize, Abomonation)] +#[serde(bound = "")] +#[abomonation_bounds( + where + E1: Engine::Scalar>, + E2: Engine::Scalar>, + C1: StepCircuit, + C2: StepCircuit, + S1: BatchedRelaxedR1CSSNARKTrait, + S2: RelaxedR1CSSNARKTrait, + ::Repr: Abomonation, + )] pub struct ProverKey where E1: Engine::Scalar>, @@ -31,6 +46,18 @@ where } /// A type that holds the verifier key for `CompressedSNARK` +#[derive(Clone, Serialize, Deserialize, Abomonation)] +#[serde(bound = "")] +#[abomonation_bounds( + where + E1: Engine::Scalar>, + E2: Engine::Scalar>, + C1: StepCircuit, + C2: StepCircuit, + S1: BatchedRelaxedR1CSSNARKTrait, + S2: RelaxedR1CSSNARKTrait, + ::Repr: Abomonation, + )] pub struct VerifierKey where E1: Engine::Scalar>, @@ -46,7 +73,8 @@ where } /// A SNARK that proves the knowledge of a valid `RecursiveSNARK` -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "")] pub struct CompressedSNARK where E1: Engine::Scalar>, @@ -204,8 +232,8 @@ where &self, pp: &PublicParams, vk: &VerifierKey, - z0_primary: Vec, - z0_secondary: Vec, + z0_primary: &[E1::Scalar], + z0_secondary: &[E2::Scalar], ) -> Result<(Vec, Vec), SuperNovaError> { let last_circuit_idx = field_as_usize(self.program_counter); @@ -229,7 +257,7 @@ where hasher.absorb(self.program_counter); for e in z0_primary { - hasher.absorb(e); + hasher.absorb(*e); } for e in &self.zn_primary { @@ -245,7 +273,7 @@ where hasher2.absorb(E2::Scalar::from(self.num_steps as u64)); for e in z0_secondary { - hasher2.absorb(e); + hasher2.absorb(*e); } for e in &self.zn_secondary { @@ -534,7 +562,7 @@ mod test { let compressed_snark = compressed_prove_res.unwrap(); let compressed_verify_res = - compressed_snark.verify(&pp, &verifier_key, z0_primary, z0_secondary); + compressed_snark.verify(&pp, &verifier_key, &z0_primary, &z0_secondary); assert!(compressed_verify_res.is_ok()); } @@ -724,7 +752,7 @@ mod test { let compressed_snark = compressed_prove_res.unwrap(); let compressed_verify_res = - compressed_snark.verify(&pp, &verifier_key, z0_primary, z0_secondary); + compressed_snark.verify(&pp, &verifier_key, &z0_primary, &z0_secondary); assert!(compressed_verify_res.is_ok()); }