-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement differential and unit tests for complete merkle
- Loading branch information
Showing
9 changed files
with
1,258 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { StandardMerkleTree } from "@openzeppelin/merkle-tree"; | ||
import { ethers } from 'ethers'; | ||
|
||
const fs = require('fs'); | ||
const input_file = process.argv[2]; | ||
const input = JSON.parse(fs.readFileSync(input_file, 'utf8')); | ||
const one_word = "0x0000000000000000000000000000000000000000000000000000000000000001" | ||
const leafs = input['leafs'].map((bytes32) => [bytes32, one_word]); | ||
const indexToProve = input['index']; | ||
const tree = StandardMerkleTree.of(leafs, ["bytes32", "bytes32"], { sortLeaves: false }); // NO DEFAULT SORTING LEAVES | ||
const proof = tree.getProof(indexToProve); | ||
process.stdout.write(ethers.utils.defaultAbiCoder.encode(['bytes32[]'], [proof])); | ||
// // const root = tree.root; | ||
// // console.log(tree.entries()); | ||
// for (const [i, v] of tree.entries()) { | ||
// if (i == indexToProve) { | ||
// const proof = tree.getProof(i); | ||
// console.log('Value:', v); | ||
// console.log('Proof:', proof); | ||
// } | ||
// } | ||
// console.log(tree.root) | ||
// console.log(tree.render()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { StandardMerkleTree } from "@openzeppelin/merkle-tree"; | ||
const fs = require('fs'); | ||
const input_file = process.argv[2]; | ||
const input = JSON.parse(fs.readFileSync(input_file, 'utf8')); | ||
const one_word = "0x0000000000000000000000000000000000000000000000000000000000000001" | ||
const leafs = input['leafs'].map((bytes32) => [bytes32, one_word]); | ||
const tree = StandardMerkleTree.of(leafs, ["bytes32", "bytes32"], { sortLeaves: false }); // NO DEFAULT SORTING LEAVES | ||
process.stdout.write(tree.root); | ||
|
Oops, something went wrong.