Files
zk-kit/packages/protocols
cedoor 8fbfc5bc33 chore: add jest conf properties
Former-commit-id: 204271f66e753f5e524a2b7ef58e083ca0344a67 [formerly dd3f3c54cff5e86a7552431162b51aea0da2aedd] [formerly c252e9f6d6b2d2c645050e9f60f1a9ab595d0fda [formerly e64fdab8c8]]
Former-commit-id: 15a107f9521bb5ff40c797b39e4c48da9d3821dc [formerly 92a0379720a6f5de1da6495d87eaa77b7584d39b]
Former-commit-id: 3d2ecf94762edbdf056e4e141d06c21b67451fda
2022-01-14 20:42:22 +01:00
..
2022-01-14 20:16:18 +01:00
2022-01-14 20:07:29 +01:00
2021-10-25 19:35:07 +02: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.