Skip to content

Commit

Permalink
readme fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwen01 committed Oct 11, 2024
1 parent 027f4f6 commit 0a20301
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
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.
44 changes: 12 additions & 32 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
4 changes: 2 additions & 2 deletions verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit 0a20301

Please sign in to comment.