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>
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>>where
E: Pairing,
C: ConstraintSynthesizer<E::ScalarField>,
QAP: R1CSToQAP,
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.
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§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>
§type ProvingKey = ProvingKey<E>
type ProvingKey = ProvingKey<E>
§type VerifyingKey = VerifyingKey<E>
type VerifyingKey = VerifyingKey<E>
§type ProcessedVerifyingKey = PreparedVerifyingKey<E>
type ProcessedVerifyingKey = PreparedVerifyingKey<E>
§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.