mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
fix: identity multipart secret updates & nrln tests
Former-commit-id: 5f048bc3bc0101f8502e4a6400ea6e31f391d204 [formerly f0a497122e9f38fb39cbedf608d0e47c41343fdc] [formerly e69985781526c91cf043eaf62e78abc9225c92ff [formerly 7b7280c12e]]
Former-commit-id: e84bf85741fd5289cd309da47cabaa3075d78c9f [formerly be6fc7e9f457419b2336fefa1dca7a105685aec9]
Former-commit-id: 06c1e532152f477de0cba77ec56c6884590ed470
ZK protocols
Client library for generating and verifying Semaphore & RLN ZK proofs.
🛠 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.