Files
zk-kit/packages/protocols
cedoor 63131b8685 chore: fix typo
Former-commit-id: 2d1381007355b41f4b48032266a5d61d87c9359d [formerly 9fc594c3f0640bba2110ef05e4d70c7745ef6399] [formerly 2dc9ca7296434f2b8adb5afbf15265a46bf3c725 [formerly 90ada17841e5c9fd8d3872dfa313d4cf99a7d93b]] [formerly b52925a9706035c29d19e5aed18f6db608f44bf6 [formerly c19af43e2edad84c73d53dbabcb975f4765f301d] [formerly 991421c4386e7bf8506357336b8ac7812f62d506 [formerly 1345dd6a111db15c36814f89a9e8f3b61a4b9fda]]]
Former-commit-id: c0911c17d5dcd9ada575493371f38bca36456974 [formerly 863b16a8b3932e325e0fa191ea49845e46cc5a2a] [formerly 843f5dd13067262bed45a1107cd4345d58a4d0d2 [formerly 68d755520feddcfbb87d6656fff4a3c7397c9480]]
Former-commit-id: 888c1f489511771dae6e045693b18976ec6ec9b0 [formerly ab833c711639606740d754aee5bba200c7f6ec0e]
Former-commit-id: 1a41dd2dcce60655a310445a87c7a5bc98929a3c
2022-04-17 18:28:26 +02:00
..
2022-04-17 18:28:26 +02:00
2022-03-04 12:24:47 +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 { proof, publicSignals } = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")
const solidityProof = Semaphore.packToSolidityProof(proof)