Files
zk-kit/packages/protocols
cedoor d20128a67c chore(protocols): v1.4.0
Former-commit-id: 07630433b6479648781460b6ee25e6031fdbad17 [formerly 3016b1dac5a4bb7a7670b301eb944f642d0a550b] [formerly b0af76151502688f4e60477938bc4bf8edc92e14 [formerly d5845113bad4d69af6482ad9d8ede90387f2042b]] [formerly a4818a2b72a17874b4278cc041e97b975ae98cec [formerly 5a388ff92629f13ba04e10f5a448dc7d6f3be565] [formerly 24f568ca7c22b7a61dda14c470c70d61dbffc9fe [formerly af95ad731c]]]
Former-commit-id: 937aba57e653ba8e6f107cdb83cf9fcded0c511b [formerly 214c7b36b54967b44db623897186c99298cf0378] [formerly 6426c128ab8db7b372b0b2a0945b47a6b209e698 [formerly 012592bb65c11f98d22046ccbe63d4a6da0c4d2c]]
Former-commit-id: 9e87303da619b11c7a181b3573469ab21d64a14f [formerly 49abb64e84efba152566446e08d988bf6435d28a]
Former-commit-id: 508fb0fbad0a1f42ce1116cb18902cf912072a9b
2022-02-07 12:03:34 +01:00
..
2022-02-02 22:27:58 +01:00
2022-02-07 12:03:34 +01:00
2022-02-01 16:33:03 +01:00
2022-01-24 15:38:45 +01:00

ZK protocols

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

Github license NPM version Downloads npm bundle size (scoped) 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 = 5
const identityCommitments = [...];
const identity = new ZkIdentity();
const identityCommitment = identity.genIdentityCommitment();

const merkleProof = generateMerkleProof(depth, zeroValue, arity, identityCommitments, identityCommitment);

Creating Semaphore proofs

import { Semaphore, genExternalNullifier } from "@zk-kit/protocols"

const signal = "0x111"
const externalNullifier = genExternalNullifier("voting_1")
const witness = Semaphore.genWitness(identity, merkleProof, externalNullifier, signal)

const fullProof = await Semaphore.genProof(witness, "./semaphore.wasm", "./semaphore.zkey")