This repository demonstrates that plonky2 proof verification works in wasm.
wasm-pack build --target web
npx http-server . -o
You can see how proof_with_public_inputs.bin
and verifier_data.bin
are composed in src/bin
Launch this command to trigger circuit end-to-end; output the needed data in files:
cargo run --bin fibonacci
Launch this command to see how verification only happens using deserialized info.
cargo run --bin verify
After trying to run end-to-end circuit execution, including building and proving, in wasm, it was discovered that failure happens on this step:
let data = builder.build::<C>();
So, even though verification part works in wasm, plonky2 in its completion may not be supported.
You can compare performance of the factorial circuit verification in WASM and native rust.
Environment: MacBook Pro M2 Max 32 GB 1 TB Storage
Rust:
cargo bench
WASM:
Same steps for executing, you will see timings in browser console.
Rust: 1.13 ms WASM: 13 ms