Files
zk-kit/packages/protocols
cedoor dc44dff71c merge: branch 'main' of github.com:appliedzkp/zk-kit into main
Former-commit-id: 97fabee9735be6a8b9efbbfbea2184a8fff904a2 [formerly 1558ec3f527a3d57463ffc6fae6d2becd6f75556] [formerly a4ad917f472d588bc7e9693e179e1c1ae7b26f02 [formerly bdce251234]]
Former-commit-id: 755a137b400e24a84dae885032e68387eb16cc71 [formerly 3cc8fdc3d1f71c0a20613a04eda8bd3d463b57ea]
Former-commit-id: 482107411d7dd71878cec95db75e78a72ac22a06
2022-01-20 18:48:40 +01:00
..
2022-01-20 18:38:30 +01:00
2022-01-16 22:01:59 +01:00
2022-01-20 14:05:43 +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.