TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

Poseidon proof

A library to generate and verify Poseidon proofs.

NPM license NPM version Downloads npm bundle size (scoped) Linter eslint Code style prettier

This zero-knowledge library facilitates the demonstration of having a Poseidon hash pre-image while keeping the pre-image value confidential. Additionally, it offers a mechanism to prevent the same proof from being reused. The circuit that forms the foundation of this library is accessible via this link.

Originally developed for integration with Semaphore V4, this library also functions effectively as a standalone tool. Notable use cases in connection with Semaphore can be:

  • allowing a Semaphore user to prove that they possess the secret value associated with the identity commitment of their Semaphore identity,
  • unmasking the identity of zero-knowledge proofs earlier created using Semaphore.

The Snark artifacts (.wasm and .zkey files) can be specified or not in the generate function parameters and can possibly be downloaded using the following URLs:


The Snark artifacts currently used to generate zero-knowledge proofs are the result of an unsecure trusted setup, and the library has not yet been audited. Therefore, it is advised not to use it in production.

🛠 Install

npm or yarn

Install the @zk-kit/poseidon-proof package:

npm i @zk-kit/poseidon-proof

or yarn:

yarn add @zk-kit/poseidon-proof

📜 Usage

# generate( message: BigNumberish, scope: BigNumberish, snarkArtifacts?: SnarkArtifacts ): Promise<PoseidonProof>

import { generate } from "@zk-kit/poseidon-proof"

const scope = 1
const message = 2

const fullProof = await generate(message, scope)

// If not specified, the Snark artifacts are downloaded automatically.
// You can also specify them.
const fullProof = await generate(message, scope, {
    zkeyFilePath: "./poseidon-proof.zkey",
    wasmFilePath: "./poseidon-proof.wasm"

    scope: '1',
    hash: '8645981980787649023086883978738420856660271013038108762834452721572614684349',
    nullifier: '7853200120776062878684798364095072458815029376092732009249414926327459813530',
    proof: [

# verify(poseidonProof: PoseidonProof): Promise<boolean>

import { verify } from "@zk-key/poseidon-proof"

const response = await verifyProof(fullProof)

console.log(response) // true or false

// Eventually you may want to check the nullifier.

📈 Benchmarks

Benchmarks were run on an Intel Core i7-1165G7, 16 GB RAM machine, after initializing the BN128 curve with @zk-kit/groth16-buildBn128 (~230ms).

Generate proof Verify proof Constraints
80ms 10ms 141
import { generate, verify } from "@zk-kit/poseidon-proof"
import { buildBn128 } from "@zk-kit/groth16"

await buildBn128()


const proof = await generate(1, 2)



console.log(await verify(proof))





Package Sidebar


npm i @zk-kit/poseidon-proof

Weekly Downloads






Unpacked Size

60.1 kB

Total Files


Last publish


  • sripwoud
  • njofce
  • akinovak
  • cedoor