Offchain Verification
Rust no_std Verification
You can verify SP1 Groth16 and Plonk proofs in no_std environments with sp1-verifier.
sp1-verifier is also patched to verify Groth16 and Plonk proofs within the SP1 zkVM, using
bn254 precompiles. For an example of this, see
the Groth16 Example.
Installation
Import the following dependency in your Cargo.toml:
sp1-verifier = {version = "6.10.0", default-features = false}
Usage
sp1-verifier's interface is very similar to the solidity verifier's. It exposes two public functions:
Groth16Verifier::verify
and PlonkVerifier::verify.
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 or PLONK proof with the SP1 SDK. See here
for more information -- sp1-verifier and the solidity verifier expect inputs in the same format.
Next, verify the proof with sp1-verifier.
Here, the proof, public inputs, and vkey hash are read from stdin. See the following snippet to see how these values are generated.
Note that the SP1 SDK itself is not
no_stdcompatible.
Exit-Code Policy
Groth16Verifier::verify and PlonkVerifier::verify require a successful guest exit, including when experimental is enabled.
To verify a specific nonzero exit code, enable the sp1-verifier/experimental feature and call verify_with_exit_code.
The expected exit code is a 32-byte big-endian value.
Keep success verification as the default unless your application explicitly handles nonzero exits.
See the 6.10.0 upgrade guide for SDK and Docker configuration.
Wasm Verification
The example-sp1-wasm-verifier demonstrates how to
verify SP1 proofs in wasm. For a more detailed explanation of the process, please see the README.