An optimized port of the SP1 verifier (Plonk proof) targeting ckb-vm, based on SP1 6.0.2.
The original SP1 verifier lacks `no_std` support and has high cycle counts (~6000M cycles), making it unusable for on-chain scripts on ckb-vm. This fork addresses both limitations.
## Changes
The code lives on this [branch]( GitHub - XuJiandong/sp1: SP1 is a zero‑knowledge virtual machine that proves the correct execution of programs compiled for the RISC-V architecture. · GitHub ), primarily in the `crates/verifier` folder.
Key modifications from the original:
1. Replaced the bn254 (alt\_bn128) elliptic curve implementation with the highly optimized [ckb-alt-bn128]( crates.io: Rust Package Registry )
2. Ported to `no_std` Rust
3. Only the Plonk verifier has been updated; Groth16 is not optimized
As a result, cycle count for a single verification is reduced from ~6000M to ~63M, with a binary size of 246 KB — viable for on-chain use on ckb-vm.
## Usage
Add the dependency to your `Cargo.toml`:
sp1-verifier = { git = “https://github.com/XuJiandong/sp1.git”, default-features = false, rev = “0cc2b42” }
Example:
use sp1_verifier::PlonkVerifier;
pub fn main() → Result<(), Error> {
let vk_hash = “0x00e5c18e0c045a455db8eb2bee09cb2db3c87129e0972cc1562ce3c13d6c9c10”;
let proof = \[\]; // fill proof here
let public_values = \[\]; // fill public values here
PlonkVerifier::verify(&proof, &public_values, &vk_hash, sp1_verifier::PLONK_VK_BYTES).expect("plonk verify failed");
}
For more usage examples, see the [official SP1 documentation]( Offchain Verification | Succinct Docs ).
A full benchmark is available [here](ckb-rust-algorithm-benchmarks/contracts/sp1-test at master · XuJiandong/ckb-rust-algorithm-benchmarks · GitHub).