0.0.7 • Published 4 months ago

@soulwallet/incremental-merkle-tree-lib v0.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

incremental-merkle-tree-lib

The js library for incremental merkle tree: https://github.com/ethereum/consensus-specs/blob/dev/solidity_deposit_contract/deposit_contract.sol

Install:

npm i @soulwallet/incremental-merkle-tree-lib

Usage:

// create new tree
const tree = new IncMerkleTree(32);

// insert leaf
for (let i = 0; i < 100; i ++) {
    tree.insertLeaf(i, sha256(randomBytes(20)), `${i}`);
}

const proveLeafIndex = 20;
const targetLeafIndex = 40;

// generate leaf proof
const proof = tree.getProof(proveLeafIndex, targetLeafIndex);

// verify leaf proof
console.log(tree.isValidProof(proveLeafIndex, targetLeafIndex, proof));
0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago