Module @zk-kit/groth16

SnarkJS Groth16

A snippet of SnarkJS code for verifying and generating Groth16 proofs only.

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

🗣️ Chat & Support   |   📘 Docs

This package is no longer maintained as SnarkJS has integrated most of the above optimizations. Please, consider installing it instead.

This package contains SnarkJS functions for generating and verifying zero knowledge proofs with Groth16 specifically. In addition to the original code it also uses the cached bn128 curve if it already exists, making verification and generation of consecutive proofs faster.

Some advantages of using this package instead of snarkjs directly are:

  • It only includes code to verify and generate Groth16 proofs, making your final bundle lighter.
  • It doesn't call the ffjavascript buildBn128 function if a bn128 cached curve already exists, making verification and generation of consecutive proofs much faster (e.g. verification seems to be ~9 times faster after the first one).
  • It includes TS types.
  • It provides an ESM bundle that is compatible with browsers. So there is no need to add any polyfill or additional configuration.


  1. Jens Groth. On the Size of Pairing-Based Non-interactive Arguments. 2016-04-28.

🛠 Install

npm or yarn

Install the @zk-kit/groth16 package and its peer dependencies with npm:

npm i @zk-kit/groth16

or yarn:

yarn add @zk-kit/groth16

📜 Usage

You will need to provide your own circuits here in your specified path. Remember to define your circuit input and rename the files accordingly.

import { prove, verify, buildBn128 } from "@zk-kit/groth16"

// Build the BN128 curve for Groth16.
await buildBn128() // WasmField1

// Define your circuit input.
// const input = {
// input1: 1,
// input2: 2,
// inputN: "N"
// }

// Compute the proof.
const proof = await prove(input, "<YOUR-PATH>/circuit.zkey", "<YOUR-PATH>/circuit.wasm")

proof: {
pi_a: [
pi_b: [ [Array], [Array], [Array] ],
pi_c: [
protocol: 'groth16',
curve: 'bn128'
publicSignals: [

// Verify the proof.
const response = await verify("<YOUR-PATH>/circuit_verification_key.json", proof)

// true or false.



Type Aliases


Generated using TypeDoc