noir-js
JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
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.
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.
Web integration for Noir circuits. Covers React integration, Web Worker proving, WASM setup, and UX patterns for browser-based ZK applications.
| name | noir-js |
| description | JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js. |
| allowed-tools | Read, Grep, Glob, Edit, Write, Bash |
Use @noir-lang/noir_js and @aztec/bb.js to compile, prove, and verify Noir circuits from JavaScript or TypeScript.
nargo compile -- produces a JSON artifact in target/noir_js (Noir class)bb.js (UltraHonkBackend)| Package | Purpose |
|---|---|
@noir-lang/noir_js | Witness generation, oracle callbacks, CompiledCircuit type |
@aztec/bb.js | Proof generation and verification (UltraHonkBackend, Barretenberg) |
The @noir-lang/noir_js package version must match the version of nargo used to compile the circuit.
import { Noir } from "@noir-lang/noir_js";
import { Barretenberg, UltraHonkBackend } from "@aztec/bb.js";
import circuit from "../target/my_circuit.json" with { type: "json" };
// 1. Initialize backend
const api = await Barretenberg.new({ threads: 8 });
const noir = new Noir(circuit as any);
const backend = new UltraHonkBackend(circuit.bytecode, api);
// 2. Generate witness
const inputs = { x: 3, y: 4 };
const { witness } = await noir.execute(inputs);
// 3. Generate proof
const { proof, publicInputs } = await backend.generateProof(witness);
// 4. Verify proof
const isValid = await backend.verifyProof({ proof, publicInputs });
console.log("Proof valid:", isValid);
All inputs are passed as values matching their Noir types:
| Noir Type | JS Encoding | Example |
|---|---|---|
Field | Number or hex string | 3 or "0x1a" |
u32, i8, etc. | Number or string | 255 |
bool | Boolean or "0"/"1" | true |
[Field; N] | JS array of encoded values | [1, 2, 3] |
struct | JS object with matching field names | { x: 1, y: 2 } |
Oracles let the circuit call JavaScript functions during witness generation. Define callbacks matching #[oracle(name)] declarations in Noir:
const oracleCallbacks = {
async get_secret(key: string[]): Promise<string[]> {
const secret = await fetchSecretFromDB(key[0]);
return [secret];
},
};
const { witness } = await noir.execute(inputs, oracleCallbacks);
Oracle callbacks receive and return string arrays where each string is a field element.