Files
zk-kit/packages/protocols
cedoor c38602e6f3 fix: set correct secret type enum value
Former-commit-id: 065efd65685db4f9f1b39f726e08f60496fcb9a9 [formerly 4939807db8f50d5bf9cecc4bdba7f9ac0b9620d0] [formerly 966aef25b4bc017fe1858cebe3ba385238020d49 [formerly 2028051989]]
Former-commit-id: b776cf0762a5d737489c1ad59a9346f37f80e728 [formerly 3c0a2d1709d3b53527c8cf27f37d786fb92e4066]
Former-commit-id: 417f09f6bd8dbbd972fd5cd3d16bc1dbd59b882e
2022-01-21 14:06:44 +01:00
..
2022-01-21 13:56:04 +01:00
2022-01-21 13:56:04 +01:00
2022-01-21 11:38:21 +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.