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>
impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>
Sourcepub fn generate_random_parameters_with_reduction<C>(
circuit: C,
rng: &mut impl Rng,
) -> R1CSResult<ProvingKey<E>>where
C: ConstraintSynthesizer<E::ScalarField>,
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.
Sourcepub 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>,
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>
impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>
Sourcepub 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>>
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.
Sourcepub fn create_random_proof_with_reduction<C>(
circuit: C,
pk: &ProvingKey<E>,
rng: &mut impl Rng,
) -> R1CSResult<Proof<E>>where
C: ConstraintSynthesizer<E::ScalarField>,
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
.
Sourcepub fn create_proof_with_reduction_no_zk<C>(
circuit: C,
pk: &ProvingKey<E>,
) -> R1CSResult<Proof<E>>where
C: ConstraintSynthesizer<E::ScalarField>,
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.
Sourcepub fn create_proof_with_reduction<C>(
circuit: C,
pk: &ProvingKey<E>,
r: E::ScalarField,
s: E::ScalarField,
) -> R1CSResult<Proof<E>>
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.
Sourcepub fn rerandomize_proof(
vk: &VerifyingKey<E>,
proof: &Proof<E>,
rng: &mut impl Rng,
) -> Proof<E>
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>
impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP>
Sourcepub fn prepare_inputs(
pvk: &PreparedVerifyingKey<E>,
public_inputs: &[E::ScalarField],
) -> R1CSResult<E::G1>
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.
Sourcepub fn verify_proof_with_prepared_inputs(
pvk: &PreparedVerifyingKey<E>,
proof: &Proof<E>,
prepared_inputs: &E::G1,
) -> R1CSResult<bool>
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.
Sourcepub fn verify_proof(
pvk: &PreparedVerifyingKey<E>,
proof: &Proof<E>,
public_inputs: &[E::ScalarField],
) -> R1CSResult<bool>
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>
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>
fn setup<C, R>( circuit: C, rng: &mut R, ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
<Self as SNARK<F>>::circuit_specific_setup(...)
.Source§impl<E: Pairing, QAP: R1CSToQAP> SNARK<<E as Pairing>::ScalarField> for Groth16<E, QAP>
impl<E: Pairing, QAP: R1CSToQAP> SNARK<<E as Pairing>::ScalarField> for Groth16<E, QAP>
Source§type ProvingKey = ProvingKey<E>
type ProvingKey = ProvingKey<E>
Source§type VerifyingKey = VerifyingKey<E>
type VerifyingKey = VerifyingKey<E>
Source§type ProcessedVerifyingKey = PreparedVerifyingKey<E>
type ProcessedVerifyingKey = PreparedVerifyingKey<E>
Source§type Error = SynthesisError
type Error = SynthesisError
Source§fn circuit_specific_setup<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>(
circuit: C,
rng: &mut R,
) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
fn circuit_specific_setup<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>( circuit: C, rng: &mut R, ) -> Result<(Self::ProvingKey, Self::VerifyingKey), Self::Error>
Source§fn prove<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>(
pk: &Self::ProvingKey,
circuit: C,
rng: &mut R,
) -> Result<Self::Proof, Self::Error>
fn prove<C: ConstraintSynthesizer<E::ScalarField>, R: RngCore>( pk: &Self::ProvingKey, circuit: C, rng: &mut R, ) -> Result<Self::Proof, Self::Error>
Source§fn process_vk(
circuit_vk: &Self::VerifyingKey,
) -> Result<Self::ProcessedVerifyingKey, Self::Error>
fn process_vk( circuit_vk: &Self::VerifyingKey, ) -> Result<Self::ProcessedVerifyingKey, Self::Error>
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>
fn verify_with_processed_vk( circuit_pvk: &Self::ProcessedVerifyingKey, x: &[E::ScalarField], proof: &Self::Proof, ) -> Result<bool, Self::Error>
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.Auto Trait Implementations§
impl<E, QAP> Freeze for Groth16<E, QAP>
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>
impl<E, QAP> UnwindSafe for Groth16<E, QAP>where
E: UnwindSafe,
QAP: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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