pub trait SNARK {
    type ScalarField: Clone + PrimeField;
    type BaseField: Clone + PrimeField;
    type Certificate: CanonicalSerialize + CanonicalDeserialize + Clone + Debug + ToBytes + FromBytes + PartialEq + Eq + Send + Sync;
    type Proof: Clone + Debug + ToBytes + FromBytes + PartialEq + Eq + Send + Sync;
    type ProvingKey: Clone + ToBytes + FromBytes + Send + Sync + Ord;
    type UniversalSRS: Clone;
    type UniversalProver;
    type UniversalVerifier;
    type VerifierInput: ?Sized;
    type VerifyingKey: Clone + Send + Sync + ToBytes + FromBytes + Ord;
    type FiatShamirRng: AlgebraicSponge<Self::BaseField, 2, Parameters = Self::FSParameters>;
    type FSParameters;

    // Required methods
    fn universal_setup(config: usize) -> Result<Self::UniversalSRS>;
    fn circuit_setup<C: ConstraintSynthesizer<Self::ScalarField>>(
        srs: &Self::UniversalSRS,
        circuit: &C
    ) -> Result<(Self::ProvingKey, Self::VerifyingKey)>;
    fn prove_vk(
        universal_prover: &Self::UniversalProver,
        fs_parameters: &Self::FSParameters,
        verifying_key: &Self::VerifyingKey,
        proving_key: &Self::ProvingKey
    ) -> Result<Self::Certificate>;
    fn prove_batch<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
        universal_prover: &Self::UniversalProver,
        fs_parameters: &Self::FSParameters,
        keys_to_constraints: &BTreeMap<&Self::ProvingKey, &[C]>,
        rng: &mut R
    ) -> Result<Self::Proof>;
    fn verify_vk<C: ConstraintSynthesizer<Self::ScalarField>>(
        universal_verifier: &Self::UniversalVerifier,
        fs_parameters: &Self::FSParameters,
        circuit: &C,
        verifying_key: &Self::VerifyingKey,
        certificate: &Self::Certificate
    ) -> Result<bool>;
    fn verify_batch<B: Borrow<Self::VerifierInput>>(
        universal_verifier: &Self::UniversalVerifier,
        fs_parameters: &Self::FSParameters,
        keys_to_inputs: &BTreeMap<&Self::VerifyingKey, &[B]>,
        proof: &Self::Proof
    ) -> Result<bool>;

    // Provided methods
    fn prove<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
        universal_prover: &Self::UniversalProver,
        fs_parameters: &Self::FSParameters,
        proving_key: &Self::ProvingKey,
        constraints: &C,
        rng: &mut R
    ) -> Result<Self::Proof> { ... }
    fn verify<B: Borrow<Self::VerifierInput>>(
        universal_verifier: &Self::UniversalVerifier,
        fs_parameters: &Self::FSParameters,
        verifying_key: &Self::VerifyingKey,
        input: B,
        proof: &Self::Proof
    ) -> Result<bool> { ... }
}

Required Associated Types§

Required Methods§

source

fn universal_setup(config: usize) -> Result<Self::UniversalSRS>

source

fn circuit_setup<C: ConstraintSynthesizer<Self::ScalarField>>( srs: &Self::UniversalSRS, circuit: &C ) -> Result<(Self::ProvingKey, Self::VerifyingKey)>

source

fn prove_vk( universal_prover: &Self::UniversalProver, fs_parameters: &Self::FSParameters, verifying_key: &Self::VerifyingKey, proving_key: &Self::ProvingKey ) -> Result<Self::Certificate>

source

fn prove_batch<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>( universal_prover: &Self::UniversalProver, fs_parameters: &Self::FSParameters, keys_to_constraints: &BTreeMap<&Self::ProvingKey, &[C]>, rng: &mut R ) -> Result<Self::Proof>

source

fn verify_vk<C: ConstraintSynthesizer<Self::ScalarField>>( universal_verifier: &Self::UniversalVerifier, fs_parameters: &Self::FSParameters, circuit: &C, verifying_key: &Self::VerifyingKey, certificate: &Self::Certificate ) -> Result<bool>

source

fn verify_batch<B: Borrow<Self::VerifierInput>>( universal_verifier: &Self::UniversalVerifier, fs_parameters: &Self::FSParameters, keys_to_inputs: &BTreeMap<&Self::VerifyingKey, &[B]>, proof: &Self::Proof ) -> Result<bool>

Provided Methods§

source

fn prove<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>( universal_prover: &Self::UniversalProver, fs_parameters: &Self::FSParameters, proving_key: &Self::ProvingKey, constraints: &C, rng: &mut R ) -> Result<Self::Proof>

source

fn verify<B: Borrow<Self::VerifierInput>>( universal_verifier: &Self::UniversalVerifier, fs_parameters: &Self::FSParameters, verifying_key: &Self::VerifyingKey, input: B, proof: &Self::Proof ) -> Result<bool>

Object Safety§

This trait is not object safe.

Implementors§