mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
Former-commit-id: d5651f6ff033ef2d978f37a46897c557ebe66ccc [formerly 5d77cc74505bd50c55b437bdd1de3d6cb2c7f1cf] [formerly 52539bea3b6623c79feffd469bd389c66ed9c8e4 [formerly d6ddb36d96dbc09693efe5306f8ebdf8b0e1a56d]] [formerly 280312dc53efc7d7383817767e7045a1aba5384f [formerly 85bcfce16471e2f02d4c5baf569c36c1744b975a] [formerly 50fb0aa12149755f2eb4f82a1a2ff50bd024903b [formerly cc21bb125f]]]
Former-commit-id: 1ec451efb69057ec72757422c48203c6a3682ca8 [formerly 8a248e7dcb3a15df1281bff04407eff37b8efa29] [formerly 1a6a61a51ed59bb1da18d04942d19ae2f081f0ed [formerly 147dbd82dcf399fef54c7a2263c6aa5347b027e0]]
Former-commit-id: b989c405f1eddaa2757729fb35dc2e17de1a6236 [formerly 1d63635f8cf462fed1a18bc850a6e11874c6834b]
Former-commit-id: 0c8caccb411ea4cdf595e57168255a226e0ab1e6
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 identity = new ZkIdentity()
const identityCommitment = identity.genIdentityCommitment()
const identityCommitments = [BigInt(1), identityCommitment, BigInt(2)]
const merkleProof = generateMerkleProof(depth, zeroValue, identityCommitments, 1)
Creating Semaphore proofs
import { Semaphore } from "@zk-kit/protocols"
const signal = "Hello world"
const externalNullifier = BigInt(1)
const witness = Semaphore.genWitness(identity, merkleProof, externalNullifier, signal)
const { proof, publicSignals } = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")
const solidityProof = Semaphore.packToSolidityProof(proof)