Files
zk-kit/packages/protocols
cedoor 5b514c080e feat: set binary tree for semaphore protocol
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
2022-02-14 18:17:14 +01:00
..
2022-02-14 13:52:03 +01:00
2022-02-09 19:01:38 +01:00

ZK protocols

Client library for generating and verifying Semaphore & RLN ZK proofs.

Github license NPM version Downloads Linter eslint Code style prettier


🛠 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)