Groth16Verifier

Struct Groth16Verifier 

Source
pub struct Groth16Verifier;
Expand description

A verifier for Groth16 zero-knowledge proofs.

Implementations§

Source§

impl Groth16Verifier

Source

pub fn verify( proof: &[u8], sp1_public_inputs: &[u8], sp1_vkey_hash: &str, groth16_vk: &[u8], ) -> Result<(), Groth16Error>

Verifies an SP1 Groth16 proof, as generated by the SP1 SDK.

§Arguments
  • proof - The proof bytes.
  • public_inputs - The SP1 public inputs.
  • sp1_vkey_hash - The SP1 vkey hash. This is generated in the following manner:
use sp1_sdk::ProverClient;
let client = ProverClient::new();
let (pk, vk) = client.setup(ELF);
let sp1_vkey_hash = vk.bytes32();
  • groth16_vk - The Groth16 verifying key bytes. Usually this will be the [static@crate::GROTH16_VK_BYTES] constant, which is the Groth16 verifying key for the current SP1 version.
§Returns

A success Result if verification succeeds, or a Groth16Error if verification fails.

Source

pub fn verify_gnark_proof( proof: &[u8], public_inputs: &[[u8; 32]], groth16_vk: &[u8], ) -> Result<(), Groth16Error>

Verifies a Gnark Groth16 proof using raw byte inputs.

WARNING: if you’re verifying an SP1 proof, you should use [verify] instead. This is a lower-level verification method that works directly with raw bytes rather than the SP1 SDK’s data structures.

§Arguments
  • proof - The raw Groth16 proof bytes (without the 4-byte vkey hash prefix)
  • public_inputs - The public inputs to the circuit
  • groth16_vk - The compressed Groth16 verifying key bytes
§Returns

A Result containing unit () if the proof is valid, or a Groth16Error if verification fails.

§Note

This method expects the raw proof bytes without the 4-byte vkey hash prefix that [verify] checks. If you have a complete proof with the prefix, use [verify] instead.

Source

pub fn verify_compressed( proof: &[u8], sp1_public_inputs: &[u8], sp1_vkey_hash: &str, groth16_vk: &[u8], ) -> Result<(), Groth16Error>

Verifies an SP1 compressed Groth16 proof, as generated by the SP1 SDK.

§Arguments
  • proof - The proof bytes.
  • public_inputs - The SP1 public inputs.
  • sp1_vkey_hash - The SP1 vkey hash. This is generated in the following manner:
use sp1_sdk::ProverClient;
let client = ProverClient::new();
let (pk, vk) = client.setup(ELF);
let sp1_vkey_hash = vk.bytes32();
  • groth16_vk - The Groth16 verifying key bytes. Usually this will be the [static@crate::GROTH16_VK_BYTES] constant, which is the Groth16 verifying key for the current SP1 version.
§Returns

A success Result if verification succeeds, or a Groth16Error if verification fails.

Source

pub fn verify_compressed_gnark_proof( proof: &[u8], public_inputs: &[[u8; 32]], groth16_vk: &[u8], ) -> Result<(), Groth16Error>

Verifies a compressed Gnark Groth16 proof using raw byte inputs.

WARNING: if you’re verifying an SP1 proof, you should use [verify] instead. This is a lower-level verification method that works directly with raw bytes rather than the SP1 SDK’s data structures.

§Arguments
  • proof - The raw compressed Groth16 proof bytes (without the 4-byte vkey hash prefix)
  • public_inputs - The public inputs to the circuit
  • groth16_vk - The compressed Groth16 verifying key bytes
§Returns

A Result containing unit () if the proof is valid, or a Groth16Error if verification fails.

§Note

This method expects the raw proof bytes without the 4-byte vkey hash prefix that [verify] checks. If you have a complete proof with the prefix, use [verify] instead.

Trait Implementations§

Source§

impl Debug for Groth16Verifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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