https://github.com/berzanorg/o1js-merkle-double-witness
Merkle Double Witness for O1js
https://github.com/berzanorg/o1js-merkle-double-witness
merkle-tree mina mina-protocol o1js zk
Last synced: about 2 months ago
JSON representation
Merkle Double Witness for O1js
- Host: GitHub
- URL: https://github.com/berzanorg/o1js-merkle-double-witness
- Owner: berzanorg
- License: mit
- Created: 2024-02-10T13:42:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-10T17:50:23.000Z (over 1 year ago)
- Last Synced: 2025-03-12T23:33:19.241Z (2 months ago)
- Topics: merkle-tree, mina, mina-protocol, o1js, zk
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Merkle Double Witness for O1js
This repository contains the source code of an [o1js](https://docs.minaprotocol.com/zkapps/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](https://docs.minaprotocol.com/zkapps/o1js) is a TypeScript library for writing general-purpose zk programs and zk smart contracts for [Mina Protocol](https://minaprotocol.com/).
## Usage
```ts
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
```shell
$ npm install
```## Run Tests
```shell
$ npm test
```## Note
The project is developed by [Berzan](https://berzan.org) with his love, sweat, and tears.