WebAssembly bindings for the OpenVM v2 STARK verifier.
This module builds the verify_vm_stark_proof_decoded function from the OpenVM v2 openvm-verify-stark-host library into WebAssembly, enabling STARK proof verification to run directly in both web browsers and Node.js environments.
This is the v2 counterpart of openvm-wasm-stark-verifier, updated to work with the OpenVM v2 proof format from openvm-eth/bin/reth-verify.
We build from the same commits as openvm-eth develop-v2.1.0, pinned in the committed Cargo.lock:
| Crate source | Reference | Revision |
|---|---|---|
| openvm-org/openvm | tag v2.x.0-preview.2 |
16c26a32 |
| openvm-org/stark-backend | branch main |
362c7ad8 |
To update, read openvm-eth's own Cargo.lock and match both pins.
patches/ holds two vendored crates, applied via [patch] in Cargo.toml. OpenVM's rv64 migration made openvm-circuit assume a 64-bit host, which does not compile for wasm32-unknown-unknown. reth-verify is a native binary, so it never hits this. Both patches touch only code the verifier never executes:
openvm-platform—MEM_SIZE = 1 << MEM_BITSoverflows a 32-bitusizenow thatMEM_BITSis 32. Saturates on 32-bit targets; 64-bit builds are unchanged.rvr-state— thePreflightTranscriptStateFFI layout assertions hard-code 8-byte pointers. Gated ontarget_pointer_width = "64"rather than weakened.
Delete patches/ and the [patch] section once upstream builds for 32-bit targets.
npm install @ethproofs/openvm2-wasm-stark-verifierimport init, {
main,
verify_stark,
} from '@ethproofs/openvm2-wasm-stark-verifier';
await init(); // Initialize WASM (if needed)
main(); // Initialize panic hook
// Verify a proof (supports both raw and zstd-compressed proofs)
const isValid = verify_stark(proofBytes, vkBytes);const { main, verify_stark } = require('@ethproofs/openvm2-wasm-stark-verifier');
// The Node.js version initializes automatically
main(); // Initialize panic hook
const result = verify_stark(proofBytes, vkBytes);-
Proof bytes: A
VmStarkProofencoded with the OpenVM stark-backend codec (VmStarkProof::decode_from_bytes), optionally zstd-compressed -
VK bytes: Serialized
VmStarkVerifyingKey, in either encoding:- bincode 1.x — written by axiom-edge's
generate_edge_vm_vk, and the format of every VK generated since that switch. Note 1.x, not 2.x; the wire formats are not interchangeable. - bitcode — written by openvm's
write_vk_to_file, and the format of older VKs.
Neither encoding is self-describing, so
verify_starktries bincode first and falls back to bitcode. This mirrorsload_vm_vkinreth-verify. - bincode 1.x — written by axiom-edge's
This matches the proof format produced by the openvm-eth reth-benchmark tooling.
Proofs and verifying keys are circuit-specific: a proof only verifies against the VK for the exact circuit that produced it. The current reth.vm.vk is a different shape from earlier v2 VKs, so regenerate proofs and VKs as a pair when upstream updates.
npm install# Build for all targets
npm run build:allnpm run test:nodeThis runs the Node.js example that loads proof and verification key files from the filesystem and verifies them.
npm run testThis starts a local HTTP server at http://localhost:8080 with a browser example that demonstrates:
- Loading the WASM module in a browser environment
- File upload interface for proof and verification key files
- Interactive STARK proof verification
- Performance metrics and detailed logging
- Error handling and user feedback
Note: The browser example requires files to be served over HTTP due to WASM CORS restrictions. The included server script handles this automatically.