This crate verifies Groth16 proofs generated by SP1 zkVM in Sui Move smart contract leveraging the Groth16 Move verifier over BN254.
Caution
This repository is not audited for production use.
- The
sp1-suilibrary is located in theverifierdirectory. - The
proofsdirectory includes the Fibonacci proof used in the test suite for the Sui Groth16 verifier and the JWT Email Domain proof from the example directory.
We also provide three examples of how to use the SP1 Groth16 verifier:
- The
examples/move/groth16-verifierdirectory contains a sample Sui Move smart contract for verifying SP1 proofs. - The
examples/sp1-sui-sdkdirectory contains a sample example using the Sui Rust SDK for verifying SP1 proofs with PTB (Programmable Transaction Blocks). - The
examples/sp1-jwt-verify-email-domaindirectory contains a fully-fledged example that verifies whether someone has access to a domain name without revealing their identity. This can be used as a complement to zkLogin. You can integrate it on Sui today. Follow the blog post explaining the code.
- Rust
- Sui Client CLI
To be able to use SP1 Groth16 proofs on Sui, you need to:
- Deploy the SP1 Groth16 verifier smart contract to Sui with your own logic. See the SP1 Groth16 verifier smart contract for a vanilla example.
- Generate a Groth16 proof using the SP1 zkVM. See the SP1 zkVM repository.
- Add the
sp1-sdkandsp1-suicrates to yourCargo.tomlin your Sui Rust SDK project.
[dependencies]
sp1-sui = { git = "https://github.com/SoundnessLabs/sp1-sui" }
sp1-sdk = { version = "4.1.0" }- Read the SP1 proof in your program and convert it to the
ark-bn254format.
let sp1_proof_with_public_values = SP1ProofWithPublicValues::load("../../proofs/fibonacci_proof.bin").unwrap();
let (pvk, public_inputs, proof_points) =
convert_sp1_gnark_to_ark(sp1_proof_with_public_values);- Call the
verify_groth16_bn254_prooffunction of the SP1 Groth16 verifier smart contract with the verification key, public inputs and proof points.
// Add the proof components as inputs to the transaction
ptb.input(serialize_input(&pvk))?; // Input 0: Verification key
ptb.input(serialize_input(&public_inputs))?; // Input 1: Public inputs
ptb.input(serialize_input(&proof_points))?; // Input 2: Proof points
let package = ObjectID::from_hex_literal(&PKG_ID).map_err(|e| anyhow!(e))?;
let module = Identifier::new("groth16_verifier").map_err(|e| anyhow!(e))?;
ptb.command(Command::move_call(
package,
module.clone(),
Identifier::new("verify_groth16_bn254_proof").map_err(|e| anyhow!(e))?,
vec![],
vec![Argument::Input(0), Argument::Input(1), Argument::Input(2)],
));This crate leverages the sp1 library by Succinct Labs for the gnark-to-ark converter and ark-bn254 for working with the BN254 elliptic curve. The repository structure was inspired by the sp1-solana verifier.
