Struct snarkvm_algorithms::snark::marlin::MarlinSNARK
source · pub struct MarlinSNARK<E: PairingEngine, FS: AlgebraicSponge<E::Fq, 2>, MM: MarlinMode, Input: ToConstraintField<E::Fr> + ?Sized>(_);
Expand description
The Marlin proof system.
Implementations
sourceimpl<E: PairingEngine, FS: AlgebraicSponge<E::Fq, 2>, MM: MarlinMode, Input: ToConstraintField<E::Fr> + ?Sized> MarlinSNARK<E, FS, MM, Input>
impl<E: PairingEngine, FS: AlgebraicSponge<E::Fq, 2>, MM: MarlinMode, Input: ToConstraintField<E::Fr> + ?Sized> MarlinSNARK<E, FS, MM, Input>
sourcepub const PROTOCOL_NAME: &'static [u8] = b"MARLIN-2019"
pub const PROTOCOL_NAME: &'static [u8] = b"MARLIN-2019"
The personalization string for this protocol. Used to personalize the Fiat-Shamir RNG.
sourcepub fn circuit_specific_setup<C: ConstraintSynthesizer<E::Fr>, R: RngCore + CryptoRng>(
c: &C,
rng: &mut R
) -> Result<(CircuitProvingKey<E, MM>, CircuitVerifyingKey<E, MM>), SNARKError>
pub fn circuit_specific_setup<C: ConstraintSynthesizer<E::Fr>, R: RngCore + CryptoRng>(
c: &C,
rng: &mut R
) -> Result<(CircuitProvingKey<E, MM>, CircuitVerifyingKey<E, MM>), SNARKError>
Generate the index-specific (i.e., circuit-specific) prover and verifier keys. This is a trusted setup.
Warning
This method should be used only for testing purposes, and not in production.
In production, one should instead perform a universal setup via Self::universal_setup
,
and then deterministically specialize the resulting universal SRS via Self::circuit_setup
.
sourcepub fn circuit_setup<C: ConstraintSynthesizer<E::Fr>>(
universal_srs: &UniversalSRS<E>,
circuit: &C
) -> Result<(CircuitProvingKey<E, MM>, CircuitVerifyingKey<E, MM>), SNARKError>
pub fn circuit_setup<C: ConstraintSynthesizer<E::Fr>>(
universal_srs: &UniversalSRS<E>,
circuit: &C
) -> Result<(CircuitProvingKey<E, MM>, CircuitVerifyingKey<E, MM>), SNARKError>
Generates the circuit proving and verifying keys. This is a deterministic algorithm that anyone can rerun.
Trait Implementations
sourceimpl<E: Clone + PairingEngine, FS: Clone + AlgebraicSponge<E::Fq, 2>, MM: Clone + MarlinMode, Input: Clone + ToConstraintField<E::Fr> + ?Sized> Clone for MarlinSNARK<E, FS, MM, Input>
impl<E: Clone + PairingEngine, FS: Clone + AlgebraicSponge<E::Fq, 2>, MM: Clone + MarlinMode, Input: Clone + ToConstraintField<E::Fr> + ?Sized> Clone for MarlinSNARK<E, FS, MM, Input>
sourcefn clone(&self) -> MarlinSNARK<E, FS, MM, Input>
fn clone(&self) -> MarlinSNARK<E, FS, MM, Input>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<E: Debug + PairingEngine, FS: Debug + AlgebraicSponge<E::Fq, 2>, MM: Debug + MarlinMode, Input: Debug + ToConstraintField<E::Fr> + ?Sized> Debug for MarlinSNARK<E, FS, MM, Input>
impl<E: Debug + PairingEngine, FS: Debug + AlgebraicSponge<E::Fq, 2>, MM: Debug + MarlinMode, Input: Debug + ToConstraintField<E::Fr> + ?Sized> Debug for MarlinSNARK<E, FS, MM, Input>
sourceimpl<E: PairingEngine, FS, MM, Input> SNARK for MarlinSNARK<E, FS, MM, Input>where
E::Fr: PrimeField,
E::Fq: PrimeField,
FS: AlgebraicSponge<E::Fq, 2>,
MM: MarlinMode,
Input: ToConstraintField<E::Fr> + ?Sized,
impl<E: PairingEngine, FS, MM, Input> SNARK for MarlinSNARK<E, FS, MM, Input>where
E::Fr: PrimeField,
E::Fq: PrimeField,
FS: AlgebraicSponge<E::Fq, 2>,
MM: MarlinMode,
Input: ToConstraintField<E::Fr> + ?Sized,
type BaseField = <E as PairingEngine>::Fq
type Certificate = Certificate<E>
type Certificate = Certificate<E>
A certificate that the indexing was performed correctly.
type FSParameters = <FS as AlgebraicSponge<<E as PairingEngine>::Fq, 2>>::Parameters
type FiatShamirRng = FS
type Proof = Proof<E>
type ProvingKey = CircuitProvingKey<E, MM>
type ScalarField = <E as PairingEngine>::Fr
type UniversalSetupConfig = usize
type UniversalSetupParameters = UniversalParams<E>
type VerifierInput = Input
type VerifyingKey = CircuitVerifyingKey<E, MM>
fn universal_setup<R: Rng + CryptoRng>(
max_degree: &Self::UniversalSetupConfig,
rng: &mut R
) -> Result<Self::UniversalSetupParameters, SNARKError>
fn setup<C: ConstraintSynthesizer<E::Fr>, R: Rng + CryptoRng>(
circuit: &C,
srs: &mut SRS<'_, R, Self::UniversalSetupParameters>
) -> Result<(Self::ProvingKey, Self::VerifyingKey), SNARKError>
fn prove_vk(
fs_parameters: &Self::FSParameters,
verifying_key: &Self::VerifyingKey,
proving_key: &Self::ProvingKey
) -> Result<Self::Certificate, SNARKError>
fn verify_vk<C: ConstraintSynthesizer<Self::ScalarField>>(
fs_parameters: &Self::FSParameters,
circuit: &C,
verifying_key: &Self::VerifyingKey,
certificate: &Self::Certificate
) -> Result<bool, SNARKError>
fn prove_batch_with_terminator<C: ConstraintSynthesizer<E::Fr>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
circuit_proving_key: &CircuitProvingKey<E, MM>,
circuits: &[C],
terminator: &AtomicBool,
zk_rng: &mut R
) -> Result<Self::Proof, SNARKError>
fn verify_batch_prepared<B: Borrow<Self::VerifierInput>>(
fs_parameters: &Self::FSParameters,
prepared_verifying_key: &<Self::VerifyingKey as Prepare>::Prepared,
public_inputs: &[B],
proof: &Self::Proof
) -> Result<bool, SNARKError>
fn prove_batch<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
proving_key: &Self::ProvingKey,
input_and_witness: &[C],
rng: &mut R
) -> Result<Self::Proof, SNARKError>
fn prove<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
proving_key: &Self::ProvingKey,
input_and_witness: &C,
rng: &mut R
) -> Result<Self::Proof, SNARKError>
fn prove_with_terminator<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
proving_key: &Self::ProvingKey,
input_and_witness: &C,
terminator: &AtomicBool,
rng: &mut R
) -> Result<Self::Proof, SNARKError>
fn verify_batch<B: Borrow<Self::VerifierInput>>(
fs_parameters: &Self::FSParameters,
verifying_key: &Self::VerifyingKey,
input: &[B],
proof: &Self::Proof
) -> Result<bool, SNARKError>
fn verify<B: Borrow<Self::VerifierInput>>(
fs_parameters: &Self::FSParameters,
verifying_key: &Self::VerifyingKey,
input: B,
proof: &Self::Proof
) -> Result<bool, SNARKError>
Auto Trait Implementations
impl<E, FS, MM, Input: ?Sized> RefUnwindSafe for MarlinSNARK<E, FS, MM, Input>where
E: RefUnwindSafe,
FS: RefUnwindSafe,
Input: RefUnwindSafe,
MM: RefUnwindSafe,
impl<E, FS, MM, Input: ?Sized> Send for MarlinSNARK<E, FS, MM, Input>where
FS: Send,
Input: Send,
impl<E, FS, MM, Input: ?Sized> Sync for MarlinSNARK<E, FS, MM, Input>where
FS: Sync,
Input: Sync,
impl<E, FS, MM, Input: ?Sized> Unpin for MarlinSNARK<E, FS, MM, Input>where
E: Unpin,
FS: Unpin,
Input: Unpin,
MM: Unpin,
impl<E, FS, MM, Input: ?Sized> UnwindSafe for MarlinSNARK<E, FS, MM, Input>where
E: UnwindSafe,
FS: UnwindSafe,
Input: UnwindSafe,
MM: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more