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§
Sourcetype ProvingKey: Clone
type ProvingKey: Clone
The parameters required by the prover to compute a proof for a specific circuit.
Sourcetype VerifyingKey: Clone
type VerifyingKey: Clone
The parameters required by the verifier to validate a proof for a specific circuit.
Sourcetype UniversalSRS: Clone + Debug
type UniversalSRS: Clone + Debug
Universal Structured Reference String from universal_setup, used for
all subsequent circuit-specific preprocessing
Required Methods§
Sourcefn preprocess<C: Arithmetization<E::ScalarField>>(
srs: &Self::UniversalSRS,
circuit: &C,
) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
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.
Sourcefn 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>
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>
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.
Sourcefn 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>
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§
Sourcefn universal_setup<R: RngCore + CryptoRng>(
_max_degree: usize,
_rng: &mut R,
) -> Result<Self::UniversalSRS, Self::Error>
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".