noir-web
Web integration for Noir circuits. Covers React integration, Web Worker proving, WASM setup, and UX patterns for browser-based ZK applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Web integration for Noir circuits. Covers React integration, Web Worker proving, WASM setup, and UX patterns for browser-based ZK applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | noir-web |
| description | Web integration for Noir circuits. Covers React integration, Web Worker proving, WASM setup, and UX patterns for browser-based ZK applications. |
| allowed-tools | Read, Grep, Glob, Edit, Write, Bash |
Build browser-based ZK applications with Noir circuits using React, Web Workers, and WASM.
React Component (main thread)
|
| postMessage({ type: 'prove', circuit, inputs })
v
Web Worker (background thread)
|
| noir.execute(inputs) --> backend.generateProof(witness)
v
WASM (barretenberg, running inside worker)
|
| postMessage({ type: 'proof-generated', proof })
v
React Component (updates UI with proof)
Proving is CPU-intensive and will freeze the browser if run on the main thread. A medium-sized circuit can block the UI for 5-30 seconds. Large circuits can take minutes.
Never do this:
// BAD: blocks the main thread
const { proof, publicInputs } = await backend.generateProof(witness);
Always delegate to a Web Worker:
// GOOD: runs in background thread
worker.postMessage({ type: 'prove', circuit, inputs });
SharedArrayBuffer is required by barretenberg and needs Cross-Origin-Isolation HTTP headers:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Without these headers, SharedArrayBuffer is undefined and WASM initialization will fail. See WASM Setup for framework-specific configuration.
// App.tsx
import { useState, useRef, useEffect } from "react";
import circuit from "../target/my_circuit.json";
function ProveButton() {
const [status, setStatus] = useState<"idle" | "proving" | "done" | "error">("idle");
const workerRef = useRef<Worker | null>(null);
useEffect(() => {
const worker = new Worker(new URL("./proof-worker.ts", import.meta.url));
worker.onmessage = (e) => {
if (e.data.type === "proof-generated") setStatus("done");
if (e.data.type === "error") setStatus("error");
};
workerRef.current = worker;
return () => worker.terminate();
}, []);
const prove = () => {
setStatus("proving");
workerRef.current?.postMessage({
type: "prove",
circuit,
inputs: { x: "3", y: "4" },
});
};
return (
<div>
<button onClick={prove} disabled={status === "proving"}>
{status === "proving" ? "Proving..." : "Generate Proof"}
</button>
{status === "done" && <p>Proof generated successfully.</p>}
{status === "error" && <p>Proving failed. Try refreshing the page.</p>}
</div>
);
}
Patterns for Noir circuit development: data types, stdlib, workspace setup. Use when working with Noir circuits in any capacity unless otherwise specified
Guidelines for writing idiomatic, efficient Noir programs. Use when writing or reviewing Noir code.
JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js.
Workflow for measuring and optimizing the ACIR circuit size of a constrained Noir program. Use when asked to optimize a Noir program's gate count or circuit size.
Test Noir circuits using nargo test. Covers test attributes, assertions, and organization patterns.
Review Noir circuits for correctness, constraint efficiency, and proof soundness. Use proactively after writing or modifying Noir circuits.