Files
zk-kit/packages/protocols
cedoor 575839ce13 docs: remove general links
Former-commit-id: 012c8e61fab893ca0ad6ad2afdd4648f99fe832c [formerly 084121b523c49c4832339014798a32de187fb5c2] [formerly 2d4ed7b1872801cf83a59c96fbdd85159eb23086 [formerly 19334431cb]]
Former-commit-id: 5474dd8144ca7df8c14788c1abb4c12202467300 [formerly d985e1bb4c7d266d0fd42380708d6bc64be85232]
Former-commit-id: be97c9ea825b0feb62ad7b708f7097b2aa9f6d03
2022-01-21 22:43:14 +01:00
..
2022-01-21 13:56:04 +01:00
2022-01-21 13:56:04 +01:00
2022-01-21 22:43:14 +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.