pub trait SNARK<F: PrimeField> {
type ProvingKey: Clone + CanonicalSerialize + CanonicalDeserialize;
type VerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize;
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize;
type ProcessedVerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize;
type Error: 'static + Error;
fn circuit_specific_setup<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit: C,
rng: &mut R
) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>;
fn prove<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit_pk: &Self::ProvingKey,
circuit: C,
rng: &mut R
) -> Result<Self::Proof, Self::Error>;
fn process_vk(
circuit_vk: &Self::VerifyingKey
) -> Result<Self::ProcessedVerifyingKey, Self::Error>;
fn verify_with_processed_vk(
circuit_pvk: &Self::ProcessedVerifyingKey,
public_input: &[F],
proof: &Self::Proof
) -> Result<bool, Self::Error>;
fn verify(
circuit_vk: &Self::VerifyingKey,
public_input: &[F],
proof: &Self::Proof
) -> Result<bool, Self::Error> { ... }
}
Expand description
The basic functionality for a SNARK.
Required Associated Types§
sourcetype ProvingKey: Clone + CanonicalSerialize + CanonicalDeserialize
type ProvingKey: Clone + CanonicalSerialize + CanonicalDeserialize
The information required by the prover to produce a proof for a specific circuit C.
sourcetype VerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize
type VerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize
The information required by the verifier to check a proof for a specific circuit C.
sourcetype Proof: Clone + CanonicalSerialize + CanonicalDeserialize
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize
The proof output by the prover.
sourcetype ProcessedVerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize
type ProcessedVerifyingKey: Clone + CanonicalSerialize + CanonicalDeserialize
This contains the verification key, but preprocessed to enable faster verification.
Required Methods§
sourcefn circuit_specific_setup<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit: C,
rng: &mut R
) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
fn circuit_specific_setup<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit: C,
rng: &mut R
) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
Takes in a description of a computation (specified in R1CS constraints), and samples proving and verification keys for that circuit.
sourcefn prove<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit_pk: &Self::ProvingKey,
circuit: C,
rng: &mut R
) -> Result<Self::Proof, Self::Error>
fn prove<C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng>(
circuit_pk: &Self::ProvingKey,
circuit: C,
rng: &mut R
) -> Result<Self::Proof, Self::Error>
Generates a proof of satisfaction of the arithmetic circuit C (specified as R1CS constraints).
sourcefn process_vk(
circuit_vk: &Self::VerifyingKey
) -> Result<Self::ProcessedVerifyingKey, Self::Error>
fn process_vk(
circuit_vk: &Self::VerifyingKey
) -> Result<Self::ProcessedVerifyingKey, Self::Error>
Preprocesses circuit_vk
to enable faster verification.
sourcefn verify_with_processed_vk(
circuit_pvk: &Self::ProcessedVerifyingKey,
public_input: &[F],
proof: &Self::Proof
) -> Result<bool, Self::Error>
fn verify_with_processed_vk(
circuit_pvk: &Self::ProcessedVerifyingKey,
public_input: &[F],
proof: &Self::Proof
) -> Result<bool, Self::Error>
Checks that proof
is a valid proof of the satisfaction of circuit
encoded in circuit_pvk
, with respect to the public input public_input
,
specified as R1CS constraints.