A library to generate and verify Semaphore proofs with Noir.
This library provides utility functions to generate and verify Semaphore proofs compatible with the Noir Semaphore circuits. |
---|
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
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"
})
import { verifyProof } from "@noir-semaphore/proof"
await verifyProof(proof1)