Help us improve
Share bugs, ideas, or general feedback.
From noir
JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js.
npx claudepluginhub critesjosh/noir-claude-plugin --plugin noirHow this skill is triggered — by the user, by Claude, or both
Slash command
/noir:noir-jsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use `@noir-lang/noir_js` and `@aztec/bb.js` to compile, prove, and verify Noir circuits from JavaScript or TypeScript.
This skill should be used when the user asks about implementing Compact witness functions in TypeScript, the WitnessContext pattern, private state management, Compact-to-TypeScript type mappings (Field to bigint, Bytes to Uint8Array, Uint to bigint), compiler-generated .d.ts files (Witnesses interface, Circuits type, Contract class), the Compact JavaScript runtime, how contract.circuits works, pure circuits in TypeScript, reading ledger state from TypeScript, the witness return tuple pattern [PrivateState, ReturnValue], or how to connect a Compact contract to its TypeScript implementation.
Cross-domain witness verification pipeline. Compiles the Compact contract, type-checks the TypeScript witness against the compiled contract's generated Witnesses type, runs structural checklist analysis (name matching, return tuple shape, WitnessContext usage, private state immutability, side effects), executes the circuit with the witness via JS runtime, and recommends devnet E2E to the orchestrator if needed. Loaded by @"midnight-verify:witness-verifier (agent)".
This skill should be used when the user asks about zero-knowledge proofs, ZK SNARKs, witness data, prover/verifier roles, constraint systems, proof generation, proof verification, privacy boundaries, or how Midnight uses ZK cryptography for transaction privacy and data protection.
Share bugs, ideas, or general feedback.
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.