Files
zk-kit/packages/protocols
cedoor 209eddae9f fix: update @zk-kit/types imports
Former-commit-id: fa528d7f4716ae89caf42094a6881d759fbe12c8 [formerly 32bae89c9ef02158b0db05561aec42da639d106c] [formerly dae06e161b404c8c1eee19a1f6f3a418c571f343 [formerly 55b87223dd]]
Former-commit-id: 4864d1c452a47f79c118c0fa8dbbe108a79c4244 [formerly ba7aeb72520cc6ed58ea976d1d6e7f93d0065a0b]
Former-commit-id: 05d8c4623951fb95c17b3193b36d8b729b763fd0
2022-01-14 20:16:18 +01:00
..
2022-01-14 20:16:18 +01:00
2021-10-25 19:35:07 +02:00
2022-01-14 20:07:29 +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.