jf_plonk::proof_system

Trait UniversalSNARK

Source
pub trait UniversalSNARK<E: Pairing> {
    type Proof: Clone;
    type ProvingKey: Clone;
    type VerifyingKey: Clone;
    type UniversalSRS: Clone + Debug;
    type Error: 'static + Error;

    // Required methods
    fn preprocess<C: Arithmetization<E::ScalarField>>(
        srs: &Self::UniversalSRS,
        circuit: &C,
    ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>;
    fn prove<C, R, T>(
        rng: &mut R,
        circuit: &C,
        prove_key: &Self::ProvingKey,
        extra_transcript_init_msg: Option<Vec<u8>>,
    ) -> Result<Self::Proof, Self::Error>
       where C: Arithmetization<E::ScalarField>,
             R: CryptoRng + RngCore,
             T: PlonkTranscript<E::BaseField>;
    fn verify<T: PlonkTranscript<E::BaseField>>(
        verify_key: &Self::VerifyingKey,
        public_input: &[E::ScalarField],
        proof: &Self::Proof,
        extra_transcript_init_msg: Option<Vec<u8>>,
    ) -> Result<(), Self::Error>;

    // Provided method
    fn universal_setup<R: RngCore + CryptoRng>(
        _max_degree: usize,
        _rng: &mut R,
    ) -> Result<Self::UniversalSRS, Self::Error> { ... }
}
Expand description

An interface for SNARKs with universal setup.

Required Associated Types§

Source

type Proof: Clone

The SNARK proof computed by the prover.

Source

type ProvingKey: Clone

The parameters required by the prover to compute a proof for a specific circuit.

Source

type VerifyingKey: Clone

The parameters required by the verifier to validate a proof for a specific circuit.

Source

type UniversalSRS: Clone + Debug

Universal Structured Reference String from universal_setup, used for all subsequent circuit-specific preprocessing

Source

type Error: 'static + Error

SNARK related error

Required Methods§

Source

fn preprocess<C: Arithmetization<E::ScalarField>>( srs: &Self::UniversalSRS, circuit: &C, ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>

Circuit-specific preprocessing to compute the proving/verifying keys.

Source

fn prove<C, R, T>( rng: &mut R, circuit: &C, prove_key: &Self::ProvingKey, extra_transcript_init_msg: Option<Vec<u8>>, ) -> Result<Self::Proof, Self::Error>
where C: Arithmetization<E::ScalarField>, R: CryptoRng + RngCore, T: PlonkTranscript<E::BaseField>,

Compute a SNARK proof of a circuit circuit, using the corresponding proving key prove_key. The witness used to generate the proof can be obtained from circuit.

extra_transcript_init_msg is the optional message to be appended to the transcript during its initialization before obtaining any challenges. This field allows application-specific data bound to the resulting proof without any check on the data. It does not incur any additional cost in proof size or prove time.

Source

fn verify<T: PlonkTranscript<E::BaseField>>( verify_key: &Self::VerifyingKey, public_input: &[E::ScalarField], proof: &Self::Proof, extra_transcript_init_msg: Option<Vec<u8>>, ) -> Result<(), Self::Error>

Verify a SNARK proof proof of the circuit circuit, with respect to the public input pub_input.

extra_transcript_init_msg: refer to documentation of prove

Provided Methods§

Source

fn universal_setup<R: RngCore + CryptoRng>( _max_degree: usize, _rng: &mut R, ) -> Result<Self::UniversalSRS, Self::Error>

Generate the universal SRS for the argument system. This setup is for trusted party to run, and mostly only used for testing purpose. In practice, a MPC flavor of the setup will be carried out to have higher assurance on the “toxic waste”/trapdoor being thrown away to ensure soundness of the argument system.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E, F, P> UniversalSNARK<E> for PlonkKzgSnark<E>
where E: Pairing<BaseField = F, G1Affine = Affine<P>>, F: RescueParameter + SWToTEConParam, P: SWCurveConfig<BaseField = F>,