Skip to content

Files

Latest commit

d57675a · Mar 14, 2025

History

History

proof

Semaphore proof with Noir

A library to generate and verify Semaphore proofs with Noir.

License

This library provides utility functions to generate and verify Semaphore proofs compatible with the Noir Semaphore circuits.

🛠 Install

npm or yarn

Install the @noir-semaphore/proof package and its peer dependencies with npm:

npm i @semaphore-protocol/identity @semaphore-protocol/group @noir-semaphore/proof

or yarn:

yarn add @semaphore-protocol/identity @semaphore-protocol/group @noir-semaphore/proof

📜 Usage

Generate Proof

import { Identity } from "@semaphore-protocol/identity"
import { Group } from "@semaphore-protocol/group"
import { generateProof } from "@noir-semaphore/proof"

const identity1 = new Identity()
const identity2 = new Identity()
const identity3 = new Identity()

const group = new Group([identity1.commitment, identity2.commitment, identity3.commitment])

const message = "Hello world"
const scope = "Semaphore"

const proof1 = await generateProof(identity1, group, message, scope)

// You can also specify the maximum tree depth supported by the proof.
const proof2 = await generateProof(identity2, group, message, scope, 20)

// You can also override our default zkey/wasm files.
const proof3 = await generateProof(identity3, group, message, scope, 20, {
    wasm: "./semaphore.wasm",
    zkey: "./semaphore.zkey"
})

Verify Proof

import { verifyProof } from "@noir-semaphore/proof"

await verifyProof(proof1)