Files
zk-kit/packages/protocols
cedoor af3b767119 docs: add project badge
Former-commit-id: 9f8854a25335e3ffbc37f41bea9205f156ec9381 [formerly c91f0375ec2e1d455fb2df2bb62731f6e982aafe] [formerly 37bf84ac7d530dc0a0eae86d99c75dbb3ce21c62 [formerly fb2c5cfd8b]]
Former-commit-id: 2003c9c67ba7ed0257759251775bddc63db9f0d4 [formerly 94a3e5920528332b34f74a96c558fdff971716fa]
Former-commit-id: 8a282158ef78aa85b84f1724d8e156ada09b8e8e
2022-01-16 22:01:59 +01:00
..
2022-01-16 21:09:44 +01:00
2022-01-16 21:09:44 +01:00
2022-01-14 23:14:52 +01:00
2022-01-14 23:14:52 +01:00
2022-01-16 22:01:59 +01:00
2022-01-14 23:14:52 +01:00
2022-01-14 23:13:40 +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.