Trait snarkvm_algorithms::traits::snark::SNARK
source · 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 UniversalSetupConfig: Clone;
type UniversalSetupParameters: FromBytes + ToBytes + Clone;
type VerifierInput: ?Sized;
type VerifyingKey: Clone + Send + Sync + ToBytes + FromBytes + PrepareOrd + for<'a> From<&'a Self::ProvingKey> + From<Self::ProvingKey> + ToConstraintField<Self::BaseField> + ToMinimalBits + Ord;
type FiatShamirRng: AlgebraicSponge<Self::BaseField, 2, Parameters = Self::FSParameters>;
type FSParameters;
// Required methods
fn universal_setup(
config: &Self::UniversalSetupConfig
) -> Result<Self::UniversalSetupParameters, SNARKError>;
fn setup<C: ConstraintSynthesizer<Self::ScalarField>>(
circuit: &C,
srs: &mut SRS<'_, 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 prove_batch_with_terminator<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
keys_to_constraints: &BTreeMap<&Self::ProvingKey, &[&C]>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<Self::Proof, 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 verify_batch_prepared<B: Borrow<Self::VerifierInput>>(
fs_parameters: &Self::FSParameters,
keys_to_inputs: &BTreeMap<<Self::VerifyingKey as PrepareOrd>::Prepared, &[B]>,
proof: &Self::Proof
) -> Result<bool, SNARKError>;
// Provided methods
fn prove_batch<C: ConstraintSynthesizer<Self::ScalarField>, R: Rng + CryptoRng>(
fs_parameters: &Self::FSParameters,
keys_to_constraints: &BTreeMap<&Self::ProvingKey, &[&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,
constraints: &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,
constraints: &C,
terminator: &AtomicBool,
rng: &mut R
) -> Result<Self::Proof, SNARKError> { ... }
fn verify_batch<B: Borrow<Self::VerifierInput>>(
fs_parameters: &Self::FSParameters,
keys_to_inputs: &BTreeMap<&Self::VerifyingKey, &[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> { ... }
}
Required Associated Types§
type ScalarField: Clone + PrimeField
type BaseField: Clone + PrimeField
sourcetype Certificate: CanonicalSerialize + CanonicalDeserialize + Clone + Debug + ToBytes + FromBytes + PartialEq + Eq + Send + Sync
type Certificate: CanonicalSerialize + CanonicalDeserialize + Clone + Debug + ToBytes + FromBytes + PartialEq + Eq + Send + Sync
A certificate that the indexing was performed correctly.