Files
zk-kit/packages/protocols
cedoor 7fd496c515 refactor: remove arity parameter from mt functions
Former-commit-id: be4dc8a721b2859276a8f820b4261fa0e9817714 [formerly 9e29c730f8333e1d7f905706b3646b4986f5ac17] [formerly ba28450065e767a3ba0a9126009d63444460af70 [formerly 604ae430f3c97a3a74fae613a43c4ce20ee68f2c]] [formerly d7f8ec4f7f8d252aa1d3d4de71942575fcaeaf99 [formerly b777595daf418d6bfe886f90c3ba8623a6ed89df] [formerly 8e3f37319640acda556c80f7603c120eb98ac60e [formerly 8bc23d43ac]]]
Former-commit-id: d3672ba986685174d7b56bd0691e26f31ee90068 [formerly 505f9d6c7bb5f61c35d1a6951a1dec75591633a7] [formerly 846ff76039920c91c9cf5924468058b73843e422 [formerly 45b05069d210b18e5ed6d5940074781725e14bdc]]
Former-commit-id: c07ca2f8095f41993ca4726d58e4d1ab55402143 [formerly 37d28b5ba3597d38b6deb64b054f801e4922ea37]
Former-commit-id: 24400d0825b6086db394e8a3b6fe5242c5b8b805
2022-02-25 18:50:36 +01:00
..
2022-02-21 18:39:13 +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 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 fullProof = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")
const solidityProof = Semaphore.packToSolidityProof(fullProof)