-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Offchain Verification | ||
|
||
## Rust `no_std` Verification | ||
|
||
You can verify SP1 Groth16 and Plonk proofs in `no_std` environments with [`sp1-verifier`](https://docs.rs/sp1-verifier/latest/sp1_verifier/). | ||
|
||
`sp1-verifier` is also patched to verify Groth16 and Plonk proofs within the SP1 ZKVM, using | ||
[bn254](https://blog.succinct.xyz/succinctshipsprecompiles/) precompiles. For an example of this, see | ||
the [Groth16 Example](https://github.com/succinctlabs/sp1/tree/main/examples/groth16/). | ||
|
||
### Installation | ||
|
||
Import the following dependency in your `Cargo.toml`: | ||
|
||
```toml | ||
sp1-verifier = {version = "3.0.0", default-features = false} | ||
``` | ||
|
||
### Usage | ||
|
||
`sp1-verifier`'s interface is very similar to the solidity verifier's. It exposes two public functions: | ||
[`Groth16Verifier::verify_proof`](https://docs.rs/sp1-verifier/latest/src/sp1_verifier/groth16.rs.html) | ||
and [`PlonkVerifier::verify_proof`](https://docs.rs/sp1-verifier/latest/src/sp1_verifier/plonk.rs.html). | ||
|
||
`sp1-verifier` also exposes the Groth16 and Plonk verifying keys as constants, `GROTH16_VK_BYTES` and `PLONK_VK_BYTES`. These | ||
keys correspond to the current SP1 version's official Groth16 and Plonk verifying keys, which are used for verifying proofs generated | ||
using docker or the prover network. | ||
|
||
First, generate your groth16/plonk proof with the SP1 SDK. See [here](./onchain/getting-started.md#generating-sp1-proofs-for-onchain-verification) | ||
for more information -- `sp1-verifier` and the solidity verifier expect inputs in the same format. | ||
|
||
Next, verify the proof with `sp1-verifier`. The following snippet is from the [Groth16 example program](https://github.com/succinctlabs/sp1/tree/dev/examples/groth16/), which verifies a Groth16 proof within SP1 using `sp1-verifier`. | ||
|
||
```rust,noplayground | ||
{{#include ../../examples/groth16/program/src/main.rs}} | ||
``` | ||
|
||
Here, the proof, public inputs, and vkey hash are read from stdin. See the following snippet to see how these values are generated. | ||
|
||
```rust,noplayground | ||
{{#include ../../examples/groth16/script/src/main.rs:12:34}} | ||
``` | ||
|
||
> Note that the SP1 SDK itself is *not* `no_std` compatible. | ||
## Wasm Verification | ||
|
||
The [`example-sp1-wasm-verifier`](https://github.com/succinctlabs/example-sp1-wasm-verifier) demonstrates how to | ||
verify SP1 proofs in wasm. For a more detailed explanation of the process, please see the [README](https://github.com/succinctlabs/example-sp1-wasm-verifier/blob/main/README.md). |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters