Files
zk-kit/packages/protocols
cedoor 60e248ebe2 feat: add command to docs websites
Former-commit-id: b54a76719bb16ccfb51ad10496733431a72f7037 [formerly 78e8332e56849b02e8eed07c478f68d76f880d48] [formerly d568507108c7b094c1b6fd21f7f1a8b69fbf3ad4 [formerly 323d298f46]]
Former-commit-id: e38b83edacb070e8fb26e05f91de52379b81eacb [formerly 61581eb1ba65fc86efd2fdd776ab27229cef5aea]
Former-commit-id: 2f4a50e97b07be1c78c80ed1f560f126044b7c2d
2022-01-20 14:05:43 +01:00
..
2022-01-20 01:45:24 +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.