mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
ZK protocols
Client library for generating and verifying Semaphore & RLN ZK proofs.
🛠 Install
npm or yarn
Install the @zk-kit/protocols package with npm:
npm i @zk-kit/protocols
or yarn:
yarn add @zk-kit/protocols
📜 Usage
Generating Merkle proofs
import { ZkIdentity } from "@zk-kit/identity"
import { generateMerkleProof } from "@zk-kit/protocols"
const depth = 20
const zeroValue= BigInt(0)
const arity = 5
const identityCommitments = [...];
const identity = new ZkIdentity();
const identityCommitment = identity.genIdentityCommitment();
const merkleProof = generateMerkleProof(depth, zeroValue, arity, identityCommitments, identityCommitment);
Creating Semaphore proofs
import { Semaphore, genExternalNullifier } from "@zk-kit/protocols"
const signal = "0x111"
const externalNullifier = genExternalNullifier("voting_1")
const witness = Semaphore.genWitness(identity, merkleProof, externalNullifier, signal)
const fullProof = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")