Skip to content

Combine multiple similar groth16 Solidity verifier contracts into one contract

Notifications You must be signed in to change notification settings

circuitscan/snarkjs-groth16-multi-verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Combine multiple similar groth16 Solidity verifier contracts into one contract

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published