Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 1.14 KB

README.md

File metadata and controls

40 lines (25 loc) · 1.14 KB

Merkle Double Witness for O1js

This repository contains the source code of an o1js compatible Merkle Double Witness implementation.

It contains a provable MerkleDoubleWitness equivalent for MerkleWitness to use with two different leaves' witnesses, which enables updating two different leaves' values at the same time and having a new updated Merkle root.

o1js is a TypeScript library for writing general-purpose zk programs and zk smart contracts for Mina Protocol.

Usage

class MyMerkleDoubleWitness extends MerkleDoubleWitness(8) {}

const merkleTree = new MerkleTree(8);

const doubleWitness = new MyMerkleDoubleWitness(
  merkleTree.getWitness(11n),
  merkleTree.getWitness(22n)
);

const root = doubleWitness.calculateRoot(Field.from(0), Field.from(0));

const [firstIndex, secondIndex] = doubleWitness.calculateIndexes();

Install Dependencies

$ npm install

Run Tests

$ npm test

Note

The project is developed by Berzan with his love, sweat, and tears.