arnaucube
arnaucube/ark-r1cs-stdPublic Self-hosted repository
ark-r1cs-std/crypto-primitives/src/nizk/constraints.rs
crypto-primitives/src/nizk/constraints.rsRaw
 1use algebra_core::Field;
 2use r1cs_core::{ConstraintSystem, SynthesisError};
 3use r1cs_std::prelude::*;
 4
 5use crate::nizk::NIZK;
 6
 7pub trait NIZKVerifierGadget<N: NIZK, ConstraintF: Field> {
 8    type PreparedVerificationKeyGadget;
 9    type VerificationKeyGadget: AllocGadget<N::VerificationParameters, ConstraintF>
10        + ToBytesGadget<ConstraintF>;
11    type ProofGadget: AllocGadget<N::Proof, ConstraintF>;
12
13    fn check_verify<'a, CS, I, T>(
14        cs: CS,
15        verification_key: &Self::VerificationKeyGadget,
16        input: I,
17        proof: &Self::ProofGadget,
18    ) -> Result<(), SynthesisError>
19    where
20        CS: ConstraintSystem<ConstraintF>,
21        I: Iterator<Item = &'a T>,
22        T: 'a + ToBitsGadget<ConstraintF> + ?Sized;
23
24    fn conditional_check_verify<'a, CS, I, T>(
25        cs: CS,
26        verification_key: &Self::VerificationKeyGadget,
27        input: I,
28        proof: &Self::ProofGadget,
29        condition: &Boolean,
30    ) -> Result<(), SynthesisError>
31    where
32        CS: ConstraintSystem<ConstraintF>,
33        I: Iterator<Item = &'a T>,
34        T: 'a + ToBitsGadget<ConstraintF> + ?Sized;
35
36    fn conditional_check_verify_prepared<'a, CS, I, T>(
37        cs: CS,
38        prepared_verification_key: &Self::PreparedVerificationKeyGadget,
39        input: I,
40        proof: &Self::ProofGadget,
41        condition: &Boolean,
42    ) -> Result<(), SynthesisError>
43    where
44        CS: ConstraintSystem<ConstraintF>,
45        I: Iterator<Item = &'a T>,
46        T: 'a + ToBitsGadget<ConstraintF> + ?Sized;
47}