Files
zk-kit/packages/protocols
cedoor 8fe6cfda7e chore(protocols): v1.2.1
Former-commit-id: f5961e46b56f3826e58b4333a35cf8a5c50cc563 [formerly 6368f35e4962afdaf7500bf662a62aecc9b3dc14] [formerly 75bb535f255dc8117a834d37176a97b7663b4bdc [formerly 2c0f841d977512495c7567f148b66cc513d057fb]] [formerly 4301a9fc3605694b60864f23799438383e8bbab5 [formerly a9e20611375f862ea1c6d0f9061167d69652ba76] [formerly c2d1096d3ee5d3b24adc9915d0c15ef192a66504 [formerly c0fff86692]]]
Former-commit-id: 6e41d976a499eda647f8d896861c0a0e72789241 [formerly 92eab3be2da55530c365d86ff81bed00b989ae7e] [formerly eeb7c467a74aca68009060482de22ceb83169bc1 [formerly 987ce106e902a88a5ca4ecb651dd5d780afb1999]]
Former-commit-id: 72cd97029925fb86a259c576cdb558c8e0c09ace [formerly 27b411dcb42f1dd330a0b5733204a19606482845]
Former-commit-id: 5356f909d6e416560f6d9b2a57c69ed483aa8032
2022-01-24 17:36:28 +01:00
..
2022-01-24 17:36:28 +01:00
2022-01-21 22:43:14 +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

Import

import { ZkIdentity, Identity } from "@zk-kit/identity"
import {
  Semaphore,
  MerkleProof,
  IProof,
  generateMerkleProof,
  genExternalNullifier,
  genSignalHash
} from "@zk-kit/protocols"
const { ZkIdentity } = require("@zk-kit/identity")
const { Semaphore, Rln, NRln, generateMerkleProof, genExternalNullifier, genSignalHash } = require("@zk-kit/protocols")

Merkle Proofs Generate merkle proof for your identity given the array of registered identity commitments

const identityCommitments: Array<bigint> = [...];
const identity: ZkIdentity = new ZkIdentity();
const identityCommitment: bigint = identity.genIdentityCommitment();

const merkleProof: MerkleProof = generateMerkleProof(TREE_DEPTH, ZERO_VALUE, NUMBER_OF_LEAVES_PER_NODE, identityCommitments, identityCommitment);

Semaphore

In order to create semaphore proof, make sure to

const witness = Semaphore.genWitness(identity, merkleProof, externalNullifier, signal)
const fullProof = await Semaphore.genProof(witness, wasmFilePath, finalZkeyPath)

📜 Final Note

For full examples of how to integrate with contracts check https://github.com/appliedzkp/semaphore repository.

For additional info check tests directory.