diff --git a/src/constraints/snark.rs b/src/constraints/snark.rs index c8595c1..eba5722 100644 --- a/src/constraints/snark.rs +++ b/src/constraints/snark.rs @@ -10,7 +10,7 @@ use crate::{ }; use ark_crypto_primitives::snark::{ constraints::{SNARKGadget, UniversalSetupSNARKGadget}, - NonNativeFieldInputVar, SNARK, + NonNativeFieldInputVar, SNARK, UniversalSetupIndexError, }; use ark_ff::{test_rng, PrimeField, ToConstraintField}; use ark_poly_commit::{PCCheckVar, PolynomialCommitment}; @@ -44,6 +44,10 @@ impl Debug for MarlinBound { } } +impl PartialOrd for MarlinBound { + fn +} + pub struct MarlinSNARK< F: PrimeField, FSF: PrimeField, @@ -94,7 +98,7 @@ where fn verify( vk: &Self::VerifyingKey, - x: &Vec, + x: &[F], proof: &Self::Proof, ) -> Result { match Marlin::::verify(vk, x, proof) { @@ -110,7 +114,7 @@ where fn verify_with_processed_vk( pvk: &Self::ProcessedVerifyingKey, - x: &Vec, + x: &[F], proof: &Self::Proof, ) -> Result { match Marlin::::prepared_verify(pvk, x, proof) { @@ -150,17 +154,19 @@ where circuit: C, _rng: &mut R, ) -> Result< - UniversalSetupIndexResult<(Self::ProvingKey, Self::VerifyingKey), Self::ComputationBound>, - Self::Error, + (Self::ProvingKey, Self::VerifyingKey), + UniversalSetupIndexError, > { let index_res = Marlin::::index(&crs.1, circuit); match index_res { - Ok(res) => Ok(UniversalSetupIndexResult::Successful(res)), + Ok(res) => Ok(res), Err(err) => match err { - IndexTooLarge(v) => Ok(UniversalSetupIndexResult::NeedLargerBound(MarlinBound { + IndexTooLarge(v) => Err(UniversalSetupIndexError::NeedLargerBound(MarlinBound { max_degree: v, })), - _ => Err(Box::new(MarlinError::from(err))), + _ => Err(UniversalSetupIndexError::Other( + Box::new(MarlinError::from(err))), + ), }, } } @@ -205,8 +211,17 @@ where type InputVar = NonNativeFieldInputVar; type ProofVar = ProofVar; + type VerifierSize = MarlinBound; + + fn verifier_size( + circuit_vk: & as SNARK>::VerifyingKey, + ) -> Self::VerifierSize { + Self::VerifierSize { + max_degree: circuit_vk.index_info.max_degree(), + } + } + fn verify_with_processed_vk( - cs: ConstraintSystemRef, circuit_pvk: &Self::ProcessedVerifyingKeyVar, x: &Self::InputVar, proof: &Self::ProofVar,