snarkjs-groth16-multi-verifier

0.0.3 • Public • Published

snarkjs-groth16-multi-verifier

Combine multiple similar groth16 Solidity verifier contracts into one contract

Inspired by Semaphore v4

Installation for development

[!NOTE] Requires pnpm package manager! The tests will fail using yarn.

$ git clone https://github.com/circuitscan/snarkjs-groth16-multi-verifier
$ cd snarkjs-groth16-multi-verifier
$ pnpm i
$ pnpm test

Usage

A single mergeVerifiers function is exposed

import { readFileSync } from 'node:fs';

import { mergeVerifiers } from 'snarkjs-groth16-multi-verifier';

const mergedSol = mergeVerifiers(
    // First argument is an array of Groth16 verifier contracts output by SnarkJS
    [
        readFileSync('./test/contracts/semaphorev4-1.sol', 'utf8'),
        readFileSync('./test/contracts/semaphorev4-2.sol', 'utf8'),
    ],
    // Second argument is the offset for the verifyProof() function
    // A value of one means the first verifier in the array is index 1.
    1
);

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i snarkjs-groth16-multi-verifier

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

194 kB

Total Files

15

Last publish

Collaborators

  • numtel