Skip to content

feat: add WASM support for browser-based proof generation#246

Open
Bisht13 wants to merge 21 commits intomainfrom
px/wasm
Open

feat: add WASM support for browser-based proof generation#246
Bisht13 wants to merge 21 commits intomainfrom
px/wasm

Conversation

@Bisht13
Copy link
Collaborator

@Bisht13 Bisht13 commented Dec 19, 2025

Summary

  • Add wasm32 architecture support to Skyscraper field arithmetic
  • Add WASM bindings for Prover and Verifier (provekit-wasm)
  • Add Node.js and browser demo with noir_js integration

Changes

  • skyscraper: wasm32 block multiplier, fp-rounding stubs, SIMD codegen
  • provekit-wasm: Prover and Verifier classes with proveBytes() API
  • playground/wasm-node-demo: Setup scripts, browser UI, Node.js CLI demo

Usage

cd playground/wasm-node-demo
pnpm install
pnpm run setup -- path/to/noir-circuit
pnpm run demo # Node.js
pnpm run demo:web # Browser (localhost:8080)

Blocked on #198

@Bisht13 Bisht13 force-pushed the px/wasm branch 2 times, most recently from f2837b7 to 7a6d54e Compare December 19, 2025 19:20
@xrvdg xrvdg mentioned this pull request Dec 25, 2025
Bisht13 added 2 commits March 6, 2026 17:11
Add provekit-wasm crate with wasm-bindgen bindings for browser-based
proof generation. Gate mavros/witness-generation deps behind
cfg(not(wasm32)). Fix binary parser HEADER_SIZE off-by-one (20→21).
Enable shared memory via linker flags for wasm-bindgen-rayon threading.

Includes wasm-demo playground with noir_js witness generation,
multi-threaded proof computation, and platform-adaptive fallbacks
for iOS/Android/desktop.

complete_age_check (712k constraints): ~7s with 14 threads vs ~32s
single-threaded (4.5x speedup).
… auto-loading WASM

- Add WasmProver (.wpkp) and WasmVerifier (.wpkv) lightweight artifact formats
- Add convert-wasm CLI command and --wasm flag on prepare
- Enable in-browser proof verification via dedicated Verify Proof button
- Auto-load WASM on page open, load .wpkp/.wpkv in parallel
- WASM crate now accepts only .wpkp for proving and .wpkv for verifying
Bisht13 added 15 commits March 6, 2026 20:14
Rewrite setup.mjs to build WASM+CLI once and prepare both SHA256 and
Poseidon circuits automatically (no arguments needed). Wire circuit
selector in index.html to switch between circuits, sync
window.activeCircuit for demo-web.mjs, and fix DOM cleanup bug that
destroyed hidden proof elements on re-run.
…flow, and dashboard polish

- Embed circuit artifact in .wpkp so browser needs only 3 files (prover.wpkp, verifier.wpkv, inputs.json)
- Add getCircuit(), getNumConstraints(), getNumWitnesses() WASM bindings
- Wire constraints and witnesses counts to dashboard metric cards
- Add circuit descriptions that update per selected circuit
- Unify custom upload steps to match standard 5-step pipeline
- Fix icon observer for Loading/Verifying/Ready states
- Fix serve.mjs directory import resolution for wasm-bindgen-rayon workers
- Update CLI convert-wasm to accept circuit path for embedding
Eliminate the separate .wpkp/.wpkv WASM artifact formats. The WASM
prover now deserializes the full Prover struct from .pkp (XZ) and
Verifier from .pkv (Zstd) directly, reconstructing the circuit JSON
for noir_js from the embedded program and ABI fields.

- Rewrite WASM lib.rs to use ProverCore/VerifierCore with auto-detect
  XZ vs Zstd decompression (ruzstd StreamingDecoder)
- Remove WasmNoirProver, WasmProver, WasmVerifier structs and all
  their Prove/Verify impls from common, prover, verifier crates
- Delete convert-wasm CLI command and --wasm flag from prepare
- Update demo to fetch .pkp/.pkv, accept .pkp/.pkv uploads
- provekit-wasm: extract prove_inner to deduplicate prove_bytes/prove_js,
  add version validation, shared header parser, proper error formatting,
  add getrandom03 dep and dependency comments
- provekit-prover: deduplicate prove/prove_with_witness (507→374 lines),
  replace all panics/unwraps with Result propagation, prove_mavros takes
  [Vec<FieldElement>; 3] instead of Phase1Result
- provekit-common: remove WASM dead-code stubs, cfg-gate mod json,
  add doc comment on NoirProver field duplication rationale
- skyscraper/core: re-export compress_many to eliminate duplicated cfg
  blocks in pow.rs
- skyscraper/hla: delete dead rust_simd_codegen.rs (428 lines, never
  declared in lib.rs)
- skyscraper/bn254-multiplier: add inline(never) justification comment
- wasm-demo JS: remove dead code, debug logs, redundant comments,
  extract shared artifact loading (587→455 lines)
- Revert accidental verifier-server whitespace change
- Remove /wasm-node-demo/ from .gitignore
… release debug info

- Extract shared binary format constants (magic bytes, format IDs, versions)
  into provekit_common::binary_format as single source of truth
- Fix ruzstd version mismatch (workspace 0.7 vs crate 0.8) by bumping
  workspace to 0.8 and using workspace = true
- Restore debug = true in [profile.release] to preserve profiling workflows
- Add correctness documentation to wasm32 fp-rounding stubs re: RTZ semantics
- Remove hardcoded nightly date from build-wasm.sh (use rust-toolchain.toml)
- Fix duplicated initialized = true in noir-init.mjs
- Document from_be_bytes_reduce safety in witness parsing
- Clarify Prover doc comment on consumption semantics
- Remove extra blank lines in prepare.rs
Remove getrandom04 (unused — mavros is cfg-gated out of wasm32 builds).
Revert unnecessary rtz/fp-rounding changes (rtz module is aarch64-only).
Move WASM RUSTFLAGS to .cargo/config.toml, delete build-wasm.sh and
redundant provekit-wasm/rust-toolchain.toml. Add rust-src component and
wasm32-unknown-unknown target to root toolchain file.
Revert all skyscraper/ changes and nightly toolchain bump back to
nightly-2025-10-20 so the WASM branch carries only WASM-specific changes.
Nightly compat fixes belong in a separate branch.

Split provekit-wasm/src/lib.rs into format, prover, verifier modules.
Refactor provekit-common: move binary_format into file/, extract mavros
types into mavros.rs, cfg-gate file I/O for wasm32.
@Bisht13 Bisht13 requested review from ashpect and ocdbytes March 9, 2026 14:15
Bisht13 added 4 commits March 9, 2026 19:51
…lti-line arrays

The simple parser failed on Noir circuits with struct inputs (e.g. PublicKey)
because inline tables like { x = "...", y = "..." } were kept as raw strings
instead of being parsed into objects. Also adds support for dotted keys (a.b.c)
and arrays of inline tables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant