mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
Former-commit-id: 4470df6ff258e21411bfcc74d3388a0398f3f46a [formerly 378f35fd4813b389ae7c6b90b248c5154e704868] [formerly f79a8fe36217321f8b02b7b6786bb5413a9b1a50 [formerly 7213b343ffb281c8e81d447a179009bdb04b3c54]] [formerly 695155b5c1e4758f36af45097f2cf521c3f1c854 [formerly 2b70d23f1ffd70ff28ba9ac214c113534c92e77e] [formerly 1b46c2fd8ba488de78eaa68abdf125021ad3e6d1 [formerly f5411edad3]]]
Former-commit-id: d968886745f403b5415d0738310e56b9e0cf38c9 [formerly 02f33b46e896683807cebe621a429c8b244a7a0d] [formerly 7d3098a31babe73e1206219582b759e79beb4989 [formerly bf80a5fe52804b657594a35b34b0eb3d17fe5cee]]
Former-commit-id: 6084776c23b2e0f82d3d49613bed6334674339f3 [formerly 2b0a41a2d5792ec35d7248ada6a0e175025f9584]
Former-commit-id: b052d15edbcbe7d2dc5dec46ac2153ff73ae3af3
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 = 2
const identity = new ZkIdentity()
const identityCommitment = identity.genIdentityCommitment()
const identityCommitments = [BigInt(1), identityCommitment, BigInt(2)]
const merkleProof = generateMerkleProof(depth, zeroValue, arity, 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 fullProof = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")
const solidityProof = Semaphore.packToSolidityProof(fullProof)