Skip to content

Commit

Permalink
book
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwen01 committed Nov 12, 2024
1 parent 63ff7a4 commit 98ad2df
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions book/verification/off-chain-verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ Here, the proof, public inputs, and vkey hash are read from stdin. See the follo

> Note that the SP1 SDK itself is *not* `no_std` compatible.
### Advanced: `verify_bytes`

`sp1-verifier` also exposes [`Groth16Verifier::verify_bytes`](https://docs.rs/sp1-verifier/latest/sp1_verifier/struct.Groth16Verifier.html#method.verify_bytes) and [`PlonkVerifier::verify_bytes`](https://docs.rs/sp1-verifier/latest/sp1_verifier/struct.PlonkVerifier.html#method.verify_bytes),
which verifies any Groth16 or Plonk proof from gnark. This is especially useful for verifying custom Groth16 and Plonk proofs
efficiently in the SP1 ZKVM.

The following snippet demonstrates how you might serialize a gnark proof in a way that `sp1-verifier` can use.

```go
// Write the verifier key.
vkFile, err := os.Create("vk.bin")
if err != nil {
panic(err)
}
defer vkFile.Close()

// Here, `vk` is a `groth16_bn254.VerifyingKey` or `plonk_bn254.VerifyingKey`.
_, err = vk.WriteTo(vkFile)
if err != nil {
panic(err)
}

// Write the proof.
proofFile, err := os.Create("proof.bin")
if err != nil {
panic(err)
}
defer proofFile.Close()

// Here, `proof` is a `groth16_bn254.Proof` or `plonk_bn254.Proof`.
_, err = proof.WriteTo(proofFile)
if err != nil {
panic(err)
}
```

Public values are serialized as big-endian `Fr` values. The default gnark serialization will work
out of the box.

## Wasm Verification

The [`example-sp1-wasm-verifier`](https://github.com/succinctlabs/example-sp1-wasm-verifier) demonstrates how to
Expand Down

0 comments on commit 98ad2df

Please sign in to comment.