@mixerx/fixed-merkle-tree
v0.0.1
Published
Fixed depth merkle tree implementation with sequential inserts
Downloads
51
Readme
@mixerx/fixed-merkle-tree
Fixed-depth Merkle tree implementation with sequential inserts.
This package is API-compatible with fixed-merkle-tree and can be used as a drop-in replacement in MixerX projects.
Installation
yarn add @mixerx/fixed-merkle-treeUsage
import { MerkleTree, PartialMerkleTree } from '@mixerx/fixed-merkle-tree';
const tree = new MerkleTree(10, [1, 2, 3, 4, 5]);
tree.insert(6);
tree.update(3, 42);
const path = tree.proof(3);
console.log(path.pathRoot);
const edge = tree.getTreeEdge(2);
const partial = new PartialMerkleTree(10, edge, tree.elements.slice(edge.edgeIndex));
console.log(partial.root);Scripts
yarn buildyarn typecheck
