Files
zk-kit/packages/protocols
cedoor fdce35a661 chore(protocols): v1.11.1
Former-commit-id: 94772dde7b371aa6ef56123caea9a151247db0dd [formerly 617495d32f1b72d7e11e4a9d9ee8b1afd1c2dfcc] [formerly 24ccef3741da792219ca68c76bcc0591ec7eea9a [formerly 1155a5802972f59317f74b1eaa98cc2624d6e2f5]] [formerly bf22d9c4d55c97cd100f7c31d9a27d813ebac48c [formerly 85e57114c98480431db85cd69557a84a79c2077a] [formerly e6263d0273a7cf0af3dd4d2b80eba0367a83b430 [formerly c88caa5c10572a6a9b3b0478c9f99d606d01904d]]]
Former-commit-id: 11f37757d2d946a3d9548765b4778e143a5040b2 [formerly 8472c4eb179f8329892bce58057b46a1418064d3] [formerly b026dffb03bc865d7a58777173b671d2e9acf5eb [formerly 01f76e0cb2276fdb47b1d68922398c9dad192776]]
Former-commit-id: 2c0884357955e5e58d8edfd7e8b6bd49136ecb5c [formerly bc89efc0f0dc0fd0df5b4c7561cbb066ebb13873]
Former-commit-id: 44a301d222e8f970b921a727508db00446382c00
2022-04-17 18:30:16 +02:00
..
2022-04-17 18:28:26 +02:00
2022-04-17 18:30:16 +02: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 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)