Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 17 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ ark-ff = { version = "0.5", features = ["asm", "std"] }
ark-poly = "0.5"
ark-serialize = "0.5"
ark-std = { version = "0.5", features = ["std"] }
mavros-vm = { git = "https://github.com/reilabs/mavros", rev = "3e47fd58001a0109a0314bc080b5246fd807ba04" }
mavros-artifacts = { git = "https://github.com/reilabs/mavros", rev = "3e47fd58001a0109a0314bc080b5246fd807ba04" }
mavros-vm = { git = "https://github.com/reilabs/mavros", rev = "7550b42e03d35b44781ff37f15b50773eb2a6fa0" }
mavros-artifacts = { git = "https://github.com/reilabs/mavros", rev = "7550b42e03d35b44781ff37f15b50773eb2a6fa0" }
spongefish = { git = "https://github.com/arkworks-rs/spongefish", features = [
"ark-ff",
"sha2",
Expand Down
1 change: 1 addition & 0 deletions playground/wasm-demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vendor/
artifacts/
pkg/
pkg-web/
pkg-local/

# Build outputs
*.wasm
Expand Down
23 changes: 19 additions & 4 deletions playground/wasm-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
<script type="importmap">
{
"imports": {
"@atheonxyz/verity": "./node_modules/@atheonxyz/verity/dist/browser/index.js",
"@noir-lang/noir_js": "./node_modules/@noir-lang/noir_js/lib/index.mjs",
"@noir-lang/acvm_js": "./node_modules/@noir-lang/acvm_js/web/acvm_js.js",
"@noir-lang/noirc_abi": "./node_modules/@noir-lang/noirc_abi/web/noirc_abi_wasm.js",
"@noir-lang/types": "./node_modules/@noir-lang/types/lib/esm/types.js",
"pako": "./node_modules/pako/dist/pako.esm.mjs",
"provekit-inspector": "./node_modules/@atheonxyz/verity/dist/wasm/provekit_wasm.js"
"provekit-inspector": "./pkg-local/provekit_wasm.js"
}
}
</script>
Expand Down Expand Up @@ -730,9 +729,9 @@ <h3 class="config-header">
<div class="dropzone" id="dropzone">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
<h3>Drag & drop circuit files</h3>
<p>Required: prover.pkp, verifier.pkv, inputs.json</p>
<p>Required: prover.pkp, verifier.pkv, inputs.json; add witgen.wasm + ad.wasm for Mavros</p>
<button class="btn-select" id="btnSelectFiles">Select Files</button>
<input type="file" id="fileInput" multiple accept=".json,.pkp,.pkv,.toml" style="display:none">
<input type="file" id="fileInput" multiple accept=".json,.pkp,.pkv,.toml,.wasm" style="display:none">
</div>
</div>

Expand Down Expand Up @@ -762,6 +761,22 @@ <h4 class="checklist-title">REQUIREMENT CHECKLIST</h4>
</div>
<div class="item-right" style="font-style: italic;">Waiting...</div>
</div>

<div class="checklist-item pending" id="check-witgenWasm">
<div class="item-left">
<div class="item-icon">-</div>
<span class="item-name">witgen.wasm (Mavros)</span>
</div>
<div class="item-right" style="font-style: italic;">Optional</div>
</div>

<div class="checklist-item pending" id="check-adWasm">
<div class="item-left">
<div class="item-icon">-</div>
<span class="item-name">ad.wasm (Mavros)</span>
</div>
<div class="item-right" style="font-style: italic;">Optional</div>
</div>
</div>
</div>

Expand Down
8 changes: 4 additions & 4 deletions playground/wasm-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"type": "module",
"scripts": {
"setup": "node scripts/setup.mjs",
"wasm:build": "node scripts/build-provekit-wasm.mjs",
"build": "tsc -p tsconfig.build.json",
"typecheck": "tsc --noEmit -p tsconfig.json",
"lint": "eslint src tests vitest.config.ts",
"test": "vitest run",
"demo:web": "npm run build && node scripts/serve.mjs",
"serve": "npm run build && node scripts/serve.mjs",
"clean": "rm -rf dist artifacts vendor pkg pkg-web"
"demo:web": "npm run wasm:build && npm run build && node scripts/serve.mjs",
"serve": "npm run wasm:build && npm run build && node scripts/serve.mjs",
"clean": "rm -rf dist artifacts vendor pkg pkg-web pkg-local"
},
"dependencies": {
"@atheonxyz/verity": "0.3.2-beta",
"@noir-lang/acvm_js": "1.0.0-beta.19",
"@noir-lang/noir_js": "1.0.0-beta.19",
"@noir-lang/noirc_abi": "1.0.0-beta.19",
Expand Down
96 changes: 96 additions & 0 deletions playground/wasm-demo/scripts/build-provekit-wasm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env node

import { execSync, spawnSync } from "child_process";
import {
existsSync,
mkdirSync,
readdirSync,
readFileSync,
rmSync,
writeFileSync,
} from "fs";
import { dirname, join, resolve } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = resolve(__dirname, "../../..");
const DEMO_DIR = resolve(__dirname, "..");
const OUT_DIR = join(DEMO_DIR, "pkg-local");
const WASM_PATH = join(
ROOT_DIR,
"target/wasm32-unknown-unknown/release/provekit_wasm.wasm"
);
const BG_WASM_PATH = join(OUT_DIR, "provekit_wasm_bg.wasm");

function run(cmd, opts = {}) {
console.log(` $ ${cmd}`);
execSync(cmd, { stdio: "inherit", ...opts });
}

function commandExists(cmd) {
return spawnSync("which", [cmd], { stdio: "ignore" }).status === 0;
}

function patchRayonWorkerImport() {
const snippetsDir = join(OUT_DIR, "snippets");
if (!existsSync(snippetsDir)) {
return;
}

for (const name of readdirSync(snippetsDir)) {
if (!name.startsWith("wasm-bindgen-rayon-")) {
continue;
}

const workerPath = join(snippetsDir, name, "src/workerHelpers.js");
if (!existsSync(workerPath)) {
continue;
}

const source = readFileSync(workerPath, "utf8");
const patched = source
.replace("await import('../../..')", "await import('../../../provekit_wasm.js')")
.replace('await import("../../..")', 'await import("../../../provekit_wasm.js")');

if (patched !== source) {
writeFileSync(workerPath, patched);
}
}
}

function main() {
if (!commandExists("wasm-bindgen")) {
throw new Error(
"wasm-bindgen not found. Install it with: cargo install wasm-bindgen-cli --version 0.2.100"
);
}

rmSync(OUT_DIR, { recursive: true, force: true });
mkdirSync(OUT_DIR, { recursive: true });

run(
"cargo +nightly-2026-03-04 build -p provekit-wasm --release --target wasm32-unknown-unknown -Z build-std=panic_abort,std",
{ cwd: ROOT_DIR }
);
run(`wasm-bindgen --target web --out-dir ${OUT_DIR} ${WASM_PATH}`, {
cwd: ROOT_DIR,
});

patchRayonWorkerImport();

if (commandExists("wasm-opt")) {
run(
`wasm-opt -O3 --enable-simd --enable-threads --enable-bulk-memory --enable-mutable-globals --enable-nontrapping-float-to-int --enable-sign-ext --fast-math --low-memory-unused -o ${BG_WASM_PATH} ${BG_WASM_PATH}`,
{ cwd: ROOT_DIR }
);
} else {
console.warn("wasm-opt not found; leaving provekit_wasm_bg.wasm unoptimized");
}
}

try {
main();
} catch (error) {
console.error(error.message);
process.exit(1);
}
24 changes: 15 additions & 9 deletions playground/wasm-demo/scripts/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Usage:
* node scripts/setup.mjs
*
* Installs browser dependencies, builds the native CLI once, then prepares
* both SHA256 and Poseidon circuits
* into artifacts/sha256/ and artifacts/poseidon/ respectively.
* Installs browser dependencies, builds the browser WASM package and native
* CLI once, then prepares both SHA256 and Poseidon circuits into
* artifacts/sha256/ and artifacts/poseidon/ respectively.
*/

import { execSync, spawnSync } from "child_process";
Expand Down Expand Up @@ -101,7 +101,7 @@ async function buildShared() {
log("\n🔧 ProveKit Browser Demo Setup\n", colors.bright);

// Check prerequisites
logStep("1/4", "Checking prerequisites...");
logStep("1/5", "Checking prerequisites...");

if (!checkCommand("nargo", "Noir (nargo)")) {
log(
Expand All @@ -118,13 +118,13 @@ async function buildShared() {
}
logSuccess("cargo found");

logStep("2/4", "Installing browser dependencies...");
logStep("2/5", "Installing browser dependencies...");
if (!run("npm install --legacy-peer-deps", { cwd: DEMO_DIR })) {
process.exit(1);
}

// Verity loads @noir-lang/* from node_modules directly; the old demo-local
// vendor/pkg staging directories are no longer needed.
// The browser demo loads @noir-lang/* from node_modules directly; the old
// demo-local vendor/pkg staging directories are no longer needed.
for (const dir of ["vendor", "pkg", "pkg-web"]) {
const fullPath = join(DEMO_DIR, dir);
if (existsSync(fullPath)) {
Expand All @@ -133,8 +133,14 @@ async function buildShared() {
}
logSuccess("Removed stale demo-local runtime asset directories");

logStep("3/5", "Building browser WASM package...");
if (!run("node scripts/build-provekit-wasm.mjs", { cwd: DEMO_DIR })) {
process.exit(1);
}
logSuccess("Browser WASM package built");

// Build native CLI
logStep("3/4", "Building native CLI...");
logStep("4/5", "Building native CLI...");
if (!run("cargo build --profile release-fast --bin provekit-cli", { cwd: ROOT_DIR })) {
process.exit(1);
}
Expand Down Expand Up @@ -224,7 +230,7 @@ async function prepareCircuit({ name, path: circuitDir }) {
async function main() {
await buildShared();

logStep("4/4", `Preparing ${CIRCUITS.length} circuits...`);
logStep("5/5", `Preparing ${CIRCUITS.length} circuits...`);
for (const circuit of CIRCUITS) {
await prepareCircuit(circuit);
}
Expand Down
6 changes: 5 additions & 1 deletion playground/wasm-demo/src/app/artifact-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { CircuitMetadata, CircuitName, CustomFiles, DiagnosticsWriter } fro
export interface ArtifactBundle {
proverBytes: Uint8Array;
verifierBytes: Uint8Array;
witgenWasmBytes?: Uint8Array;
adWasmBytes?: Uint8Array;
metadata: CircuitMetadata | null;
}

Expand Down Expand Up @@ -111,7 +113,7 @@ export class ArtifactLoader {
}

private async loadCustomArtifacts(customFiles: CustomFiles): Promise<ArtifactBundle> {
const { prover, verifier } = customFiles;
const { prover, verifier, witgenWasm, adWasm } = customFiles;
if (!prover || !verifier) {
throw new Error("Upload prover and verifier artifacts before running the custom circuit.");
}
Expand All @@ -122,6 +124,8 @@ export class ArtifactLoader {
return {
proverBytes: new Uint8Array(await prover.arrayBuffer()),
verifierBytes: new Uint8Array(await verifier.arrayBuffer()),
witgenWasmBytes: witgenWasm ? new Uint8Array(await witgenWasm.arrayBuffer()) : undefined,
adWasmBytes: adWasm ? new Uint8Array(await adWasm.arrayBuffer()) : undefined,
metadata: null,
};
}
Expand Down
2 changes: 2 additions & 0 deletions playground/wasm-demo/src/app/checklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const DEFAULT_CHECKLIST_LABELS: Record<UploadKey, string> = {
prover: "prover.pkp",
verifier: "verifier.pkv",
inputs: "inputs.json / Prover.toml",
witgenWasm: "witgen.wasm (Mavros)",
adWasm: "ad.wasm (Mavros)",
};

const CHECK_ICON = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg>`;
Expand Down
Loading
Loading