pub struct Groth16Setup<E: Pairing> {
pub proving_key: ProvingKey<E>,
pub verifying_key: VerifyingKey<E>,
pub prepared_verifying_key: PreparedVerifyingKey<E>,
}Expand description
Contains all necessary parameters for the Groth16 proving system.
This structure holds the proving key, verifying key, and prepared verifying key needed for generating and verifying zero-knowledge proofs.
Fields§
§proving_key: ProvingKey<E>The proving key used to generate proofs. This contains the secret parameters and should be kept private in some applications.
verifying_key: VerifyingKey<E>The verification key used to verify proofs. This can be made public and distributed to verifiers.
prepared_verifying_key: PreparedVerifyingKey<E>A preprocessed version of the verification key that allows for more efficient proof verification.
Implementations§
Source§impl Groth16Setup<Bn254>
impl Groth16Setup<Bn254>
Sourcepub fn new(
num_constraints: usize,
num_variables: usize,
) -> Result<Self, Groth16Error>
pub fn new( num_constraints: usize, num_variables: usize, ) -> Result<Self, Groth16Error>
Creates a new Groth16 setup for a circuit with the specified parameters.
This function generates the proving and verification keys necessary for creating and verifying zero-knowledge proofs.
§Arguments
num_constraints- Number of constraints in the arithmetic circuitnum_variables- Number of variables used in the circuit
§Returns
Result<Self, Groth16Error>- The setup parameters or an error
§Example
let setup = Groth16Setup::new(3, 2)?;Sourcepub fn prove(
&self,
inputs: &[Fr],
witness: &[Fr],
) -> Result<ArkProof<Bn254>, Groth16Error>
pub fn prove( &self, inputs: &[Fr], witness: &[Fr], ) -> Result<ArkProof<Bn254>, Groth16Error>
Sourcepub fn verify(
&self,
proof: &ArkProof<Bn254>,
public_inputs: &[Fr],
) -> Result<bool, Groth16Error>
pub fn verify( &self, proof: &ArkProof<Bn254>, public_inputs: &[Fr], ) -> Result<bool, Groth16Error>
Verifies a zero-knowledge proof against the provided public inputs.
§Arguments
proof- The proof to verifypublic_inputs- Public inputs used in the proof
§Returns
Result<bool, Groth16Error>- Whether the proof is valid
§Example
let is_valid = setup.verify(&proof, &public_inputs)?;
assert!(is_valid);Sourcepub fn proof_to_evm_format(
proof: &ArkProof<Bn254>,
) -> Result<Vec<u8>, Groth16Error>
pub fn proof_to_evm_format( proof: &ArkProof<Bn254>, ) -> Result<Vec<u8>, Groth16Error>
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for Groth16Setup<E>
impl<E> RefUnwindSafe for Groth16Setup<E>where
<E as Pairing>::G1Affine: RefUnwindSafe,
<E as Pairing>::G2Affine: RefUnwindSafe,
<E as Pairing>::TargetField: RefUnwindSafe,
<E as Pairing>::G2Prepared: RefUnwindSafe,
impl<E> Send for Groth16Setup<E>
impl<E> Sync for Groth16Setup<E>
impl<E> Unpin for Groth16Setup<E>
impl<E> UnwindSafe for Groth16Setup<E>where
<E as Pairing>::G1Affine: UnwindSafe,
<E as Pairing>::G2Affine: UnwindSafe,
<E as Pairing>::TargetField: UnwindSafe,
<E as Pairing>::G2Prepared: 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