Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
41d177a
block-multiplier: bench WASI compatible.
xrvdg Jan 5, 2026
4be79b3
divan: codspeed only on CI, use regular to build with WASI
xrvdg Jan 5, 2026
11b0366
block-multiplier: widening mul optimised for WASM
xrvdg Jan 5, 2026
be45a09
wasi runners: enable relaxed simd
xrvdg Jan 6, 2026
2d42c76
wasm: bench portable_simd on wasm
xrvdg Jan 6, 2026
813b592
wasm: Add simd flags
xrvdg Jan 6, 2026
1a94a3e
wasm: Add test to portable_simd
xrvdg Jan 6, 2026
0143939
wasm: add portable_simd_wasm
xrvdg Jan 6, 2026
ceee4a2
wasm: optimising 52 bit - not final
xrvdg Jan 6, 2026
493367c
wasm: optimised 52/51-bit integer-to-float conversion
xrvdg Jan 7, 2026
74cc61c
b51: add constants
xrvdg Jan 12, 2026
9500a7b
Montgomery table: use correct prime and add 51bit
xrvdg Jan 20, 2026
f309c49
start 51 bit conversion
xrvdg Jan 20, 2026
3e82bff
kani: check conversion with kani
xrvdg Jan 20, 2026
55f0268
b51: generate RHO values
xrvdg Jan 20, 2026
1f09045
b51: reducer from i64 -> u64
xrvdg Jan 20, 2026
419c8e2
b51 checkpoint: conversion from b52 to b51 (NON WORKING)
xrvdg Jan 21, 2026
6f11480
i2f: safe conversion
xrvdg Jan 21, 2026
68d6487
b51 checkpoint: working b51 multipliers
xrvdg Jan 21, 2026
df3ad67
b51: working montgomery multiplier
xrvdg Jan 21, 2026
c0fdd6a
b51: optimise carry handling
xrvdg Jan 21, 2026
805894c
b51: further optimise redundant carry
xrvdg Jan 22, 2026
d45f87e
b51: optimise redundant carry for s
xrvdg Jan 22, 2026
55829ba
b51: optimise carry for addi
xrvdg Jan 22, 2026
0fb170a
b51: optimises carries on t and r
xrvdg Jan 22, 2026
08a055b
b51: aggregrate anchor subtractions
xrvdg Jan 22, 2026
d97fe87
b51: sqr reduce number of multiplications
xrvdg Jan 22, 2026
7a53b63
b51: sqr reduce additions
xrvdg Jan 23, 2026
6130724
kani: silence unexpected_cfg
xrvdg Jan 23, 2026
c1161ff
block multiplier: reorganizing
xrvdg Jan 23, 2026
fabda22
block-multiplier: rne organisation
xrvdg Jan 23, 2026
d1479f7
block-multiplier: rtz organisation
xrvdg Jan 23, 2026
ebc5d78
block-multiplier -> bn254-multiplier
xrvdg Jan 23, 2026
586d897
b51: inline multimul, fix kani paths, make i2f generic
xrvdg Jan 26, 2026
fee0d5e
b51: documentation
xrvdg Jan 26, 2026
70c18ff
b51: i2f kani
xrvdg Jan 26, 2026
62f391d
fixup! b51: i2f kani
xrvdg Jan 26, 2026
5ca67fa
feat: add verifier server
Bisht13 Sep 1, 2025
0a63901
feat(ffi): add provekit-ffi
Bisht13 Sep 22, 2025
8329b33
feat(skyscraper): add wasm32 architecture support
Bisht13 Dec 19, 2025
d3b6652
feat(wasm): add WASM bindings for prover and verifier
Bisht13 Dec 19, 2025
611b08f
feat(demo): add WASM browser and Node.js demo
Bisht13 Dec 19, 2025
271c522
refactor(demo): rename to wasm-demo and add build script
Bisht13 Dec 19, 2025
9a01800
style: apply cargo fmt
Bisht13 Dec 19, 2025
d38fe4d
rebase : main
ocdbytes Jan 30, 2026
fcd1f98
Merge xr/fmul into px/wasm for local testing
ocdbytes Jan 30, 2026
8c1a8f8
fix : ci doc test
ocdbytes Jan 30, 2026
eea0704
removed ffi
ocdbytes Jan 30, 2026
ffdb8b9
fix : workspace members
ocdbytes Jan 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# This enables KaTex in docs, but requires running `cargo doc --no-deps`.
[build]
rustdocflags = "--html-in-header .cargo/katex-header.html"

[target.wasm32-wasip2]
rustflags = ["-C", "target-feature=+simd128,+relaxed-simd"]

[target.wasm32-wasip1]
runner = "wasmtime run --dir . "
rustflags = ["-C", "target-feature=+simd128,+relaxed-simd"]
4 changes: 4 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Replace divan with codspeed-divan-compat
run: |
sed -i 's/^divan = .*/divan = { package = "codspeed-divan-compat", version = "3.0.1" }/' Cargo.toml

- name: Setup Rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v1
with:
Expand Down
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*.json
# Allow JSON files in csca_registry
!**/csca_registry/**/*.json
# Allow package.json files
!**/package.json
*.gz
*.bin
*.nps
Expand Down Expand Up @@ -43,4 +45,12 @@ Cargo.lock
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
circuit_stats_examples/
circuit_stats_examples/
# Node.js
node_modules/

# Old test directories (root level only)
/wasm-node-demo/

# wasm packages
tooling/provekit-wasm/pkg/*
33 changes: 25 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ resolver = "2"
members = [
"skyscraper/fp-rounding",
"skyscraper/hla",
"skyscraper/block-multiplier",
"skyscraper/block-multiplier-codegen",
"skyscraper/bn254-multiplier",
"skyscraper/bn254-multiplier-codegen",
"skyscraper/core",
"provekit/common",
"provekit/r1cs-compiler",
Expand All @@ -13,6 +13,7 @@ members = [
"tooling/cli",
"tooling/provekit-bench",
"tooling/provekit-gnark",
"tooling/provekit-wasm",
"tooling/verifier-server",
"ntt",
]
Expand Down Expand Up @@ -40,6 +41,9 @@ license = "MIT"
homepage = "https://github.com/worldfnd/ProveKit"
repository = "https://github.com/worldfnd/ProveKit"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }

[workspace.lints.clippy]
cargo = "warn"
perf = "warn"
Expand All @@ -55,7 +59,6 @@ missing_docs_in_private_items = { level = "allow", priority = 1 }
missing_safety_doc = { level = "deny", priority = 1 }

[profile.release]
debug = true # Generate symbol info for profiling
opt-level = 3
codegen-units = 1
lto = "fat"
Expand All @@ -70,8 +73,8 @@ opt-level = 3

[workspace.dependencies]
# Workspace members - Skyscraper
block-multiplier = { path = "skyscraper/block-multiplier" }
block-multiplier-codegen = { path = "skyscraper/block-multiplier-codegen" }
bn254-multiplier = { path = "skyscraper/bn254-multiplier" }
bn254-multiplier-codegen = { path = "skyscraper/bn254-multiplier-codegen" }
fp-rounding = { path = "skyscraper/fp-rounding" }
hla = { path = "skyscraper/hla" }
skyscraper = { path = "skyscraper/core" }
Expand All @@ -80,12 +83,14 @@ ntt = { path = "ntt" }
# Workspace members - ProveKit
provekit-bench = { path = "tooling/provekit-bench" }
provekit-cli = { path = "tooling/cli" }
provekit-common = { path = "provekit/common" }
provekit-common = { path = "provekit/common", default-features = true }
provekit-ffi = { path = "tooling/provekit-ffi" }
provekit-gnark = { path = "tooling/provekit-gnark" }
provekit-prover = { path = "provekit/prover" }
provekit-prover = { path = "provekit/prover", default-features = true }
provekit-r1cs-compiler = { path = "provekit/r1cs-compiler" }
provekit-verifier = { path = "provekit/verifier" }
provekit-verifier-server = { path = "tooling/verifier-server" }
provekit-wasm = { path = "tooling/provekit-wasm" }

# 3rd party
anyhow = "1.0.93"
Expand All @@ -94,7 +99,9 @@ axum = "0.8.4"
base64 = "0.22.1"
bytes = "1.10.1"
chrono = "0.4.41"
divan = { package = "codspeed-divan-compat", version = "3.0.1" }
# On CI divan get replaced by divan = { package = "codspeed-divan-compat", version = "3.0.1" } for benchmark tracking.
# This is a workaround because different package selection based on target does not mix well with workspace dependencies.
divan = "0.1.21"
hex = "0.4.3"
itertools = "0.14.0"
paste = "1.0.15"
Expand Down Expand Up @@ -126,6 +133,14 @@ tracy-client-sys = "=0.24.3"
zerocopy = "0.8.25"
zeroize = "1.8.1"
zstd = "0.13.3"
ruzstd = "0.7" # Pure Rust zstd decoder for WASM compatibility

# WASM-specific dependencies
wasm-bindgen = "0.2"
serde-wasm-bindgen = "0.6"
console_error_panic_hook = "0.1"
getrandom = { version = "0.2", features = ["js"] }
getrandom03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }

# Noir language dependencies
acir = { git = "https://github.com/noir-lang/noir", rev = "v1.0.0-beta.11" }
Expand All @@ -150,5 +165,7 @@ ark-std = { version = "0.5", features = ["std"] }
spongefish = { git = "https://github.com/arkworks-rs/spongefish", features = [
"arkworks-algebra",
], rev = "ecb4f08373ed930175585c856517efdb1851fb47" }
# spongefish-pow with parallel feature for wasm-bindgen-rayon support
spongefish-pow = { git = "https://github.com/arkworks-rs/spongefish", rev = "ecb4f08373ed930175585c856517efdb1851fb47" }
# WHIR proof system - using main's revision
whir = { git = "https://github.com/WizardOfMenlo/whir/", features = ["tracing"], rev = "cf1599b56ff50e09142ebe6d2e2fbd86875c9986" }
13 changes: 13 additions & 0 deletions playground/wasm-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dependencies
node_modules/

# Generated artifacts (created by setup script)
artifacts/
pkg/
pkg-web/

# Build outputs
*.wasm
!src/**/*.wasm

pnpm-lock.yaml
123 changes: 123 additions & 0 deletions playground/wasm-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# ProveKit WASM Node.js Demo

A Node.js demonstration of ProveKit's WASM bindings for zero-knowledge proof generation using the **OPRF Nullifier** circuit.

## Prerequisites

1. **Noir toolchain** (v1.0.0-beta.11):
```bash
noirup --version v1.0.0-beta.11
```

2. **Rust** with wasm32 target:
```bash
rustup target add wasm32-unknown-unknown
```

3. **wasm-pack**:
```bash
cargo install wasm-pack
```

4. **wasm-opt**:
```bash
npm install -g binaryen
```

## Setup

Run the setup script to build all required artifacts:

```bash
npm install
npm run setup
```

This will:
1. Build the WASM package (`wasm-pack build`)
2. Compile the OPRF Noir circuit (`nargo compile`)
3. Prepare prover/verifier JSON artifacts (`provekit-cli prepare`)
4. Build the native CLI for verification

## Run the Demo

```bash
npm run demo
```

The demo will:
1. Load the compiled OPRF circuit and prover artifact
2. Generate a witness using `@noir-lang/noir_js`
3. Generate a zero-knowledge proof using ProveKit WASM
4. Verify the proof using the native ProveKit CLI

## Architecture

```
┌─────────────────────────────────────────────────────────────┐
│ Node.js Demo │
├─────────────────────────────────────────────────────────────┤
│ │
│ Circuit: OPRF Nullifier │
│ ├─ Merkle tree membership proof (depth 10) │
│ ├─ ECDSA signature verification │
│ ├─ DLOG equality proof │
│ └─ Poseidon2 hashing │
│ │
│ 1. Witness Generation │
│ ├─ Input: Noir circuit + OPRF inputs │
│ └─ Tool: @noir-lang/noir_js │
│ │
│ 2. Proof Generation │
│ ├─ Input: Witness + Prover.json │
│ └─ Tool: ProveKit WASM │
│ │
│ 3. Verification │
│ ├─ Input: Proof + Verifier.pkv │
│ └─ Tool: ProveKit native CLI* │
│ │
└─────────────────────────────────────────────────────────────┘

* WASM Verifier is WIP due to tokio/mio dependency resolution
```

## Files

- `scripts/setup.mjs` - Setup script that builds all artifacts
- `src/demo.mjs` - Main demo showing WASM proof generation
- `src/wasm-loader.mjs` - Helper to load WASM module in Node.js
- `artifacts/` - Generated artifacts (circuit, prover, verifier, proofs)

## Notes

- **WASM Verifier**: Currently disabled in ProveKit WASM due to tokio/mio dependencies.
Verification uses the native CLI as a workaround.
- **JSON Format**: WASM bindings use JSON artifacts (not binary `.pkp`/`.pkv`) to avoid
compression dependencies in the browser.
- **Witness Format**: The witness map uses hex-encoded field elements as strings.
- **Circuit Complexity**: The OPRF circuit is moderately complex (~100k constraints).
Proof generation may take 30-60 seconds on modern hardware.

## Troubleshooting

### "command not found: nargo"
Install the Noir toolchain:
```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash
noirup --version v1.0.0-beta.11
```

### "wasm-pack: command not found"
```bash
cargo install wasm-pack
```

### WASM memory errors
The OPRF circuit requires significant memory for proof generation. Increase Node.js memory limit:
```bash
NODE_OPTIONS="--max-old-space-size=8192" npm run demo
```

### Slow proof generation
The OPRF circuit is complex. On Apple Silicon (M1/M2/M3), expect ~30-60s for proof generation.
On x86_64, it may take longer. This is normal for WASM execution.
Loading
Loading