This repo demonstrates how to verify Groth16 and Plonk proofs in browser. We wrap the sp1-verifier
crate in wasm bindings, and invoke it from javascript.
verifier
: The rust sp1 verifier crate with wasm bindings.example/fibonacci-program
: A simple fibonacci SP1 program to verify.example/fibonacci-script
: A simple script to generate proofs in a json format.example/wasm_example
: A short javascript example that verifies proofs in wasm.
First, generate the wasm library for the verifier. From the verifier
directory, run
wasm-pack build --target nodejs --dev
Next, run the script to generate fibonacci_groth16_proof.json
and fibonacci_plonk_proof.json
. From the example/script
directory, run:
cargo run --release -- --mode groth16
cargo run --release -- --mode plonk
By default, this will not generate fresh proofs from the program in example/fibonacci-program
. To generate fresh proofs, run:
cargo run --release -- --mode groth16 --prove
cargo run --release -- --mode plonk --prove
To verify proofs in wasm, run the following command from the example/wasm_example
directory:
pnpm install
pnpm run test