Skip to content

Repository files navigation

OpenVM v2 Wasm Stark Verifier

WebAssembly bindings for the OpenVM v2 STARK verifier.

Overview

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.

Upstream revisions

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_BITS overflows a 32-bit usize now that MEM_BITS is 32. Saturates on 32-bit targets; 64-bit builds are unchanged.
  • rvr-state — the PreflightTranscriptState FFI layout assertions hard-code 8-byte pointers. Gated on target_pointer_width = "64" rather than weakened.

Delete patches/ and the [patch] section once upstream builds for 32-bit targets.

Usage

Installation

npm install @ethproofs/openvm2-wasm-stark-verifier

React Integration

import 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);

Node.js Usage

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 Format

  • Proof bytes: A VmStarkProof encoded 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_stark tries bincode first and falls back to bitcode. This mirrors load_vm_vk in reth-verify.

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.

Testing

Installation

npm install

Prerequisites

Building

# Build for all targets
npm run build:all

Node.js Example

npm run test:node

This runs the Node.js example that loads proof and verification key files from the filesystem and verifies them.

Browser Example

npm run test

This 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages