ark_groth16

Struct Groth16

Source
pub struct Groth16<E: Pairing, QAP: R1CSToQAP = LibsnarkReduction> { /* private fields */ }
Expand description

The SNARK of [Groth16](https://eprint.iacr.org/2016/260.pdf).

Implementations§

Source§

impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>

Source

pub fn generate_random_parameters_with_reduction<C>( circuit: C, rng: &mut impl Rng, ) -> R1CSResult<ProvingKey<E>>

Generates a random common reference string for a circuit using the provided R1CS-to-QAP reduction.

Source

pub fn generate_parameters_with_qap<C>( circuit: C, alpha: E::ScalarField, beta: E::ScalarField, gamma: E::ScalarField, delta: E::ScalarField, g1_generator: E::G1, g2_generator: E::G2, rng: &mut impl Rng, ) -> R1CSResult<ProvingKey<E>>

Create parameters for a circuit, given some toxic waste, R1CS to QAP calculator and group generators

Source§

impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>

Source

pub fn create_proof_with_reduction_and_matrices( pk: &ProvingKey<E>, r: E::ScalarField, s: E::ScalarField, matrices: &ConstraintMatrices<E::ScalarField>, num_inputs: usize, num_constraints: usize, full_assignment: &[E::ScalarField], ) -> R1CSResult<Proof<E>>

Create a Groth16 proof using randomness r and s and the provided R1CS-to-QAP reduction, using the provided R1CS constraint matrices.

Source

pub fn create_random_proof_with_reduction<C>( circuit: C, pk: &ProvingKey<E>, rng: &mut impl Rng, ) -> R1CSResult<Proof<E>>

Create a Groth16 proof that is zero-knowledge using the provided R1CS-to-QAP reduction. This method samples randomness for zero knowledges via rng.

Source

pub fn create_proof_with_reduction_no_zk<C>( circuit: C, pk: &ProvingKey<E>, ) -> R1CSResult<Proof<E>>

Create a Groth16 proof that is not zero-knowledge with the provided R1CS-to-QAP reduction.

Source

pub fn create_proof_with_reduction<C>( circuit: C, pk: &ProvingKey<E>, r: E::ScalarField, s: E::ScalarField, ) -> R1CSResult<Proof<E>>

Create a Groth16 proof using randomness r and s and the provided R1CS-to-QAP reduction.

Source

pub fn rerandomize_proof( vk: &VerifyingKey<E>, proof: &Proof<E>, rng: &mut impl Rng, ) -> Proof<E>

Given a Groth16 proof, returns a fresh proof of the same statement. For a proof π of a statement S, the output of the non-deterministic procedure rerandomize_proof(π) is statistically indistinguishable from a fresh honest proof of S. For more info, see theorem 3 of [BKSV20]

Source§

impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>

Source

pub fn prepare_inputs( pvk: &PreparedVerifyingKey<E>, public_inputs: &[E::ScalarField], ) -> R1CSResult<E::G1>

Prepare proof inputs for use with [verify_proof_with_prepared_inputs], wrt the prepared verification key pvk and instance public inputs.

Source

pub fn verify_proof_with_prepared_inputs( pvk: &PreparedVerifyingKey<E>, proof: &Proof<E>, prepared_inputs: &E::G1, ) -> R1CSResult<bool>

Verify a Groth16 proof proof against the prepared verification key pvk and prepared public inputs. This should be preferred over [verify_proof] if the instance’s public inputs are known in advance.

Source

pub fn verify_proof( pvk: &PreparedVerifyingKey<E>, proof: &Proof<E>, public_inputs: &[E::ScalarField], ) -> R1CSResult<bool>

Verify a Groth16 proof proof against the prepared verification key pvk, with respect to the instance public_inputs.

Trait Implementations§

Source§

impl<E: Pairing, QAP: R1CSToQAP> CircuitSpecificSetupSNARK<<E as Pairing>::ScalarField> for Groth16<E, QAP>

Source§

fn setup<C, R>( circuit: C, rng: &mut R, ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>

The setup algorithm for circuit-specific SNARKs. By default, this just invokes <Self as SNARK<F>>::circuit_specific_setup(...).
Source§

impl<E: Pairing, QAP: R1CSToQAP> SNARK<<E as Pairing>::ScalarField> for Groth16<E, QAP>

Source§

type ProvingKey = ProvingKey<E>

The information required by the prover to produce a proof for a specific circuit C.
Source§

type VerifyingKey = VerifyingKey<E>

The information required by the verifier to check a proof for a specific circuit C.
Source§

type Proof = Proof<E>

The proof output by the prover.
Source§

type ProcessedVerifyingKey = PreparedVerifyingKey<E>

This contains the verification key, but preprocessed to enable faster verification.
Source§

type Error = SynthesisError

Errors encountered during setup, proving, or verification.
Source§

fn circuit_specific_setup<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>( 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.
Source§

fn prove<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>( 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).
Source§

fn process_vk( circuit_vk: &Self::VerifyingKey, ) -> Result<Self::ProcessedVerifyingKey, Self::Error>

Preprocesses circuit_vk to enable faster verification.
Source§

fn verify_with_processed_vk( circuit_pvk: &Self::ProcessedVerifyingKey, x: &[E::ScalarField], 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.
Source§

fn verify( circuit_vk: &Self::VerifyingKey, 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_vk, with respect to the public input public_input, specified as R1CS constraints.

Auto Trait Implementations§

§

impl<E, QAP> Freeze for Groth16<E, QAP>

§

impl<E, QAP> RefUnwindSafe for Groth16<E, QAP>

§

impl<E, QAP> Send for Groth16<E, QAP>
where QAP: Send,

§

impl<E, QAP> Sync for Groth16<E, QAP>
where QAP: Sync,

§

impl<E, QAP> Unpin for Groth16<E, QAP>
where E: Unpin, QAP: Unpin,

§

impl<E, QAP> UnwindSafe for Groth16<E, QAP>
where E: UnwindSafe, QAP: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more