Files
zk-kit/packages/protocols
Andrija 83ff880873 revert versions
Former-commit-id: e596f59578e9897b3050f4786910a3634dabd2aa [formerly 05bae9441c]
Former-commit-id: 928fb2fb8f559173053e893a285cb44a1a452eb9
2021-12-03 00:54:50 +01:00
..
2021-11-25 15:51:56 +01:00
2021-10-25 19:35:07 +02:00
2021-12-03 00:54:50 +01:00
2021-10-22 22:13:48 +02:00
2021-10-25 19:35:07 +02:00

Semaphore 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 @libsem/protocols package with npm:

npm i @libsem/protocols

or yarn:

yarn add @libsem/protocols

📜 Usage

Import

import { ZkIdentity, Identity } from "@libsem/identity"
import {
  Semaphore,
  MerkleProof,
  IProof,
  generateMerkleProof,
  genExternalNullifier,
  genSignalHash
} from "@libsem/protocols"
const { ZkIdentity } = require("@libsem/identity")
const { Semaphore, Rln, NRln, generateMerkleProof, genExternalNullifier, genSignalHash } = require("@libsem/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.