diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 72c9d6c..e31b03e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -28,6 +28,15 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + + - name: "Install sp1up" + run: | + curl -L https://sp1.succinct.xyz | bash + echo "$HOME/.sp1/bin" >> $GITHUB_PATH + + - name: "Install SP1 toolchain" + run: | + sp1up - name: Run solana program tests run: | diff --git a/README.md b/README.md index 7cb6717..49e0557 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # `sp1-solana` -A Groth16 verifier implementation for Solana using BN254 precompiles. This crate verifies Groth16 proofs generated with SP1, leveraging Solana's BN254 precompiles for efficient cryptographic operations. +This crate verifies Groth16 proofs generated with SP1, leveraging Solana's BN254 precompiles for efficient cryptographic operations. > [!CAUTION] > > This repository is under active development and is not yet ready for production use. +## Repository Overview + +The `sp1-solana` library itself is in the [`verifier`](verifier) directory. `example/program` contains an example Solana program that uses this library to verify SP1 proofs, and `example/script` contains an example Solana script that invokes this program. See the [example README](example/README.md) for more information. + ## Features - **Groth16 Proof Verification**: Implements the Groth16 protocol for zero-knowledge proof verification. @@ -23,4 +27,4 @@ sp1-solana = { git = "https://github.com/succinctlabs/groth16-solana" } ``` ## Acknowledgements -This crate uses the [`groth16-solana`](https://github.com/Lightprotocol/groth16-solana/) crate from Light Protocol Labs for the actual Groth16 proof verification, and the [`ark-bn254`](https://github.com/arkworks-rs/algebra) crate for the elliptic curve operations. \ No newline at end of file +This crate uses the [`groth16-solana`](https://github.com/Lightprotocol/groth16-solana/) crate from Light Protocol Labs for the Groth16 proof verification, and the [`ark-bn254`](https://github.com/arkworks-rs/algebra) crate for the elliptic curve operations. \ No newline at end of file diff --git a/example/README.md b/example/README.md index 49fffae..b9a10a8 100644 --- a/example/README.md +++ b/example/README.md @@ -4,17 +4,22 @@ This example demonstrates how to use the `sp1-solana` crate to verify a proof ge ## Overview: Script -This script will load an SP1 [`SP1ProofWithPublicValues`](https://docs.rs/sp1-sdk/2.0.0/sp1_sdk/proof/struct.SP1ProofWithPublicValues.html) -from the pre-generated proof [`fibonacci_proof.bin`](./proofs/fibonacci_proof.bin). This is a SP1 Groth16 proof that -proves that the 20th fibonacci number is 6765. +1. Load an SP1 [`SP1ProofWithPublicValues`](https://docs.rs/sp1-sdk/2.0.0/sp1_sdk/proof/struct.SP1ProofWithPublicValues.html) +from the pre-generated proof [`fibonacci_proof.bin`](../proofs/fibonacci_proof.bin). This is a SP1 Groth16 proof that +proves that the 20th fibonacci number is 6765. Optionally, this proof can be freshly generated from +the [`sp1-program`](../sp1-program). + +2. Serialize the `SP1ProofWithPublicValues` into a `SP1ProofFixture`, which is then written to +[`proof-fixtures/fibonacci_fixture.bin`](../proof-fixtures/fibonacci_fixture.bin). + +3. Using the [`solana-program-test`](https://docs.rs/solana-program-test/latest/solana_program_test/) crate, send the `SP1ProofFixture` to the +[`fibonacci-verifier-contract`](./program). This example smart contract will verify the proof using the `sp1-solana` crate, +verify that the provided program vkey is correct, and print out the public inputs. -The loaded `SP1ProofWithPublicValues` will be serialized into a `SP1ProofFixture`, and written to -[`proof-fixtures/fibonacci_fixture.bin`](./proof-fixtures/fibonacci_fixture.bin). The `SP1ProofFixture` -can easily be borsh serialized and deserialized, and can be verified on chain. ### Running the script -To load the pregenerated proof and verify it, run the following commands. +To load the pregenerated proof, serialize it to a fixture, and verify it on chain, run the following commands. ```shell cd script @@ -27,28 +32,3 @@ To generate a fresh proof from the program in `sp1-program`, run the following c cd script RUST_LOG=info cargo run --release -- --prove ``` - -## Overview: Solana Program - -The code in [`program`](./program) is a simple Solana contract that verifies a -`SP1ProofFixture` using the `sp1-solana` crate. It costs roughly 280,000 compute units. It also -demonstrates how to verify the sp1 program vkey and the public inputs. - -### Running the Solana program - -Running the Solana program and tests requires the following - -* [PNPM](https://pnpm.io/installation) -* [yarn](https://yarnpkg.com/getting-started/install) -* [Solana CLI](https://docs.solana.com/cli/install-solana-cli) - * Make sure to install the edge version. Run the following: - ```shell - sh -c "$(curl -sSfL https://release.anza.xyz/edge/install)" - ``` -* [Rust](https://www.rust-lang.org/tools/install) - -```shell -cd solana -pnpm install -yarn build-and-test -``` diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 861c27b..5b90099 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -3,10 +3,10 @@ name = "sp1-solana" version = "0.1.0" edition = "2021" authors = ["Bhargav Annem, Yuwen Zhang"] -description = "Verifier for SP1 Groth16proofs on Solana" +description = "Verifier for SP1 Groth16 proofs on Solana" license = "MIT OR Apache-2.0" repository = "https://github.com/succinctlabs/groth16-solana" -readme = "README.md" +readme = "../README.md" keywords = ["cryptography", "zero-knowledge", "groth16", "verifier"] categories = ["cryptography"]