Skip to content

Commit

Permalink
progress on SNARK impls
Browse files Browse the repository at this point in the history
  • Loading branch information
npwardberkeley committed Nov 6, 2020
1 parent 701c207 commit 086920a
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/constraints/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -44,6 +44,10 @@ impl Debug for MarlinBound {
}
}

impl PartialOrd for MarlinBound {
fn
}

pub struct MarlinSNARK<
F: PrimeField,
FSF: PrimeField,
Expand Down Expand Up @@ -94,7 +98,7 @@ where

fn verify(
vk: &Self::VerifyingKey,
x: &Vec<F>,
x: &[F],
proof: &Self::Proof,
) -> Result<bool, Self::Error> {
match Marlin::<F, FSF, PC, FS, MC>::verify(vk, x, proof) {
Expand All @@ -110,7 +114,7 @@ where

fn verify_with_processed_vk(
pvk: &Self::ProcessedVerifyingKey,
x: &Vec<F>,
x: &[F],
proof: &Self::Proof,
) -> Result<bool, Self::Error> {
match Marlin::<F, FSF, PC, FS, MC>::prepared_verify(pvk, x, proof) {
Expand Down Expand Up @@ -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<Self::ComputationBound, Self::Error>,
> {
let index_res = Marlin::<F, FSF, PC, FS, MC>::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))),
),
},
}
}
Expand Down Expand Up @@ -205,8 +211,17 @@ where
type InputVar = NonNativeFieldInputVar<F, FSF>;
type ProofVar = ProofVar<F, FSF, PC, PCG>;

type VerifierSize = MarlinBound;

fn verifier_size(
circuit_vk: &<MarlinSNARK<F, FSF, PC, FS, MC> as SNARK<F>>::VerifyingKey,
) -> Self::VerifierSize {
Self::VerifierSize {
max_degree: circuit_vk.index_info.max_degree(),
}
}

fn verify_with_processed_vk(
cs: ConstraintSystemRef<FSF>,
circuit_pvk: &Self::ProcessedVerifyingKeyVar,
x: &Self::InputVar,
proof: &Self::ProofVar,
Expand Down

0 comments on commit 086920a

Please sign in to comment.