MCPcopy Index your code
hub / github.com/SoundnessLabs/sp1-sui

github.com/SoundnessLabs/sp1-sui @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
48 symbols 83 edges 17 files 7 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

sp1-sui - SP1 Verifier on Sui

SP1 Sui Banner

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.

Repository Overview

We also provide three examples of how to use the SP1 Groth16 verifier:

  • The examples/move/groth16-verifier directory contains a sample Sui Move smart contract for verifying SP1 proofs.
  • The examples/sp1-sui-sdk directory contains a sample example using the Sui Rust SDK for verifying SP1 proofs with PTB (Programmable Transaction Blocks).
  • The examples/sp1-jwt-verify-email-domain directory 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.

Requirements

Example usage

To be able to use SP1 Groth16 proofs on Sui, you need to:

  1. Deploy the SP1 Groth16 verifier smart contract to Sui with your own logic. See the SP1 Groth16 verifier smart contract for a vanilla example.
  2. Generate a Groth16 proof using the SP1 zkVM. See the SP1 zkVM repository.
  3. Add the sp1-sdk and sp1-sui crates to your Cargo.toml in your Sui Rust SDK project.
[dependencies]
sp1-sui = { git = "https://github.com/SoundnessLabs/sp1-sui" }
sp1-sdk = { version = "4.1.0" }
  1. Read the SP1 proof in your program and convert it to the ark-bn254 format.
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);
  1. Call the verify_groth16_bn254_proof function 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)],
));

Acknowledgements

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.

Core symbols most depended-on inside this repo

serialize_input
called by 3
examples/sp1-sui-sdk/src/utils.rs
fetch_coin
called by 3
examples/sp1-sui-sdk/src/utils.rs
decompress_g2
called by 3
verifier/src/ark_converter.rs
fibonacci
called by 2
examples/fibonacci/lib/src/lib.rs
setup_for_write
called by 2
examples/sp1-sui-sdk/src/utils.rs
request_tokens_from_faucet
called by 2
examples/sp1-sui-sdk/src/utils.rs
retrieve_wallet
called by 2
examples/sp1-sui-sdk/src/utils.rs
convert_sp1_gnark_to_ark
called by 2
verifier/src/lib.rs

Shape

Function 35
Class 8
Enum 3
Method 2

Languages

Rust100%

Modules by API surface

verifier/src/ark_converter.rs11 symbols
examples/sp1-sui-sdk/src/utils.rs9 symbols
examples/sp1-jwt-verify-email-domain/lib/src/lib.rs9 symbols
examples/fibonacci/script/src/bin/evm.rs5 symbols
verifier/src/main.rs2 symbols
examples/fibonacci/script/src/bin/main.rs2 symbols
verifier/src/test.rs1 symbols
verifier/src/lib.rs1 symbols
examples/sp1-sui-sdk/src/main.rs1 symbols
examples/sp1-jwt-verify-email-domain/script/src/main.rs1 symbols
examples/sp1-jwt-verify-email-domain/script/build.rs1 symbols
examples/sp1-jwt-verify-email-domain/program/src/main.rs1 symbols

For agents

$ claude mcp add sp1-sui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact