askill
noir-js

noir-jsSafety 95Repository

JavaScript/TypeScript integration with Noir circuits. Covers compilation, witness generation, proving, and verification using noir_js and bb.js.

0 stars
1.2k downloads
Updated 2/10/2026

Package Files

Loading files...
SKILL.md

Noir JavaScript/TypeScript Integration

Use @noir-lang/noir_js and @aztec/bb.js to compile, prove, and verify Noir circuits from JavaScript or TypeScript.

Pipeline Overview

  1. Compile circuit with nargo compile -- produces a JSON artifact in target/
  2. Load the artifact in JavaScript
  3. Generate witness with noir_js (Noir class)
  4. Create proof with bb.js (UltraHonkBackend)
  5. Verify proof on the client or on-chain

Key Packages

PackagePurpose
@noir-lang/noir_jsWitness generation, oracle callbacks, CompiledCircuit type
@aztec/bb.jsProof generation and verification (UltraHonkBackend, Barretenberg)

The @noir-lang/noir_js package version must match the version of nargo used to compile the circuit.

Quick Start

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);

Input Encoding Rules

All inputs are passed as values matching their Noir types:

Noir TypeJS EncodingExample
FieldNumber or hex string3 or "0x1a"
u32, i8, etc.Number or string255
boolBoolean or "0"/"1"true
[Field; N]JS array of encoded values[1, 2, 3]
structJS object with matching field names{ x: 1, y: 2 }

Oracle Callbacks

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.

Detailed Guides

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

82/100Analyzed 2/23/2026

Comprehensive skill covering Noir JavaScript/TypeScript integration with working code examples, input encoding tables, oracle callbacks, and clear pipeline steps. Well-structured in a dedicated skills folder with tags for discoverability. References detailed guides for deeper coverage. Scores high on actionability and clarity."

95
85
75
75
85

Metadata

Licenseunknown
Version-
Updated2/10/2026
Publishercritesjosh

Tags

apici-cdsecurity