Skip to content

lucasmenendez/groth16-sp1-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SP1 Groth16 Verifier

Basic Groth16 SnarkJS verifier compatible with SP1. It uses arkworks-rs/groth16.

This project has been developed with the SP1 template for creating an end-to-end project that can generate a proof of any RISC-V program.

Requirements

Running the Project

There are four main ways to run this project: build a program, execute a program, generate a core proof, and generate an EVM-compatible proof.

Build the Program

To build the program, run the following command:

cd program
cargo prove build

Execute the Program

To run the program without generating a proof:

cd script
cargo run --release -- --execute --vk <path_to_verify_key> --proof <path_to_proof> --inputs <path_to_public_inputs>

This will execute the program and display the output.

Generate a Core Proof

To generate a core proof for your program:

cd script
cargo run --release -- --prove --vk <path_to_verify_key> --proof <path_to_proof> --inputs <path_to_public_inputs>

Generate an EVM-Compatible Proof

Warning

You will need at least 128GB RAM to generate a Groth16 or PLONK proof.

To generate a proof that is small enough to be verified on-chain and verifiable by the EVM:

cd script
cargo run --release --bin evm -- --system groth16 --vk <verify_key_content> --proof <proof_content> --inputs <inputs_content>

this will generate a Groth16 proof. If you want to generate a PLONK proof, run the following command:

cargo run --release --bin evm -- --system plonk --vk <verify_key_content> --proof <proof_content> --inputs <inputs_content>

These commands will also generate fixtures that can be used to test the verification of SP1 zkVM proofs inside Solidity.

Retrieve the Verification Key

To retrieve your programVKey for your on-chain contract, run the following command:

cargo prove vkey --elf elf/riscv32im-succinct-zkvm-elf

Using the Prover Network

We highly recommend using the Succinct prover network for any non-trivial programs or benchmarking purposes. For more information, see the setup guide.

To get started, copy the example environment file:

cp .env.example .env

Then, set the SP1_PROVER environment variable to network and set the SP1_PRIVATE_KEY environment variable to your whitelisted private key.

For example, to generate an EVM-compatible proof using the prover network, run the following command:

SP1_PROVER=network SP1_PRIVATE_KEY=... cargo run --release --bin evm --vk <verify_key_content> --proof <proof_content> --inputs <inputs_content>

About

Basic Groth16 SnarkJS verifier compatible with SP1.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages