Struct ark_groth16::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>>where C: ConstraintSynthesizer<E::ScalarField>,

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>>where C: ConstraintSynthesizer<E::ScalarField>,

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>>where C: ConstraintSynthesizer<E::ScalarField>,

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>>where C: ConstraintSynthesizer<E::ScalarField>,

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>>where E: Pairing, C: ConstraintSynthesizer<E::ScalarField>, QAP: R1CSToQAP,

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>

§

fn setup<C, R>( circuit: C, rng: &mut R ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>where C: ConstraintSynthesizer<F>, R: RngCore + CryptoRng,

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>

§

type ProvingKey = ProvingKey<E>

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

type VerifyingKey = VerifyingKey<E>

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

type Proof = Proof<E>

The proof output by the prover.
§

type ProcessedVerifyingKey = PreparedVerifyingKey<E>

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

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.
§

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> RefUnwindSafe for Groth16<E, QAP>where E: RefUnwindSafe, QAP: RefUnwindSafe,

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

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