Files
zk-kit/packages/protocols
Andrija eeac8008ca nary incrementaly merkle tree
Former-commit-id: 812614c0cc1f79817b314a46491d6b61710e4942 [formerly 522c3bd30389b7ce4175c2830c79ccf22a4404d9] [formerly cc13abf762f896a1959190f8767eeba8a4c8028c [formerly 312e3ef206]]
Former-commit-id: 0a9e445f0ec532bc892a540c4027de886ab6f188 [formerly e0fa3503670f7130116a766f4af21996450d715f]
Former-commit-id: ea5a71189761e75320b173d25664d3f72ae0d74d
2022-01-17 19:24:40 +01:00
..
2022-01-17 15:27:27 +01:00
2022-01-16 22:01:59 +01:00
2022-01-14 23:14:52 +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.