Files
zk-kit/packages/protocols
cedoor 08eb249bd3 chore: move zkey files on protocols package
Former-commit-id: 7c5ea48785d23ebbda8e1426f7f7d12b7c36da65 [formerly 3df39b237515c43cad6743c1fb070e7f09976214] [formerly d78e915cf6d10cc92d0601098678e759ca415f09 [formerly 7fe52f0d537ccfd49b0fa180efe173fab4b483b0]] [formerly 206df2d27f5838c9e85e6615b272ecd802045de8 [formerly 89ac77a571bc1e70224cb0691bdbc384afad6174] [formerly 96c3a2c62eecf54e09f45611e49a6eefc9443873 [formerly dd3a071817]]]
Former-commit-id: 0152413454d3423c1bc1d601ed06c270503430d2 [formerly fb605ded9e6d4716a3e8f38a887f65f02f48da90] [formerly a5dd1039cd26f287ef36cd927845b014260a81fa [formerly be7bcc79c73ccee4639c90b2bf58cecc39c67d3c]]
Former-commit-id: b0b3dd64d62d5af8867e63da0db23f6b9bf86a85 [formerly a1fe5cfe389a8884e56c8850418f81cd88592081]
Former-commit-id: 35f04a1295466b840edb38c186d5f95805842c9d
2022-02-09 19:59:05 +01:00
..
2022-02-01 16:33: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 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")