fixed-merkle-tree/lib/FixedMerkleTree.d.ts

33 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-03-28 11:21:32 +03:00
import { Element, HashFunction, MerkleTreeOptions, ProofPath, SerializedTreeState, TreeEdge, TreeSlice } from './';
2022-03-14 12:42:36 +03:00
import { BaseTree } from './BaseTree';
export default class MerkleTree extends BaseTree {
constructor(levels: number, elements?: Element[], { hashFunction, zeroElement, }?: MerkleTreeOptions);
private _buildHashes;
/**
* Insert multiple elements into the tree.
* @param {Array} elements Elements to insert
*/
bulkInsert(elements: Element[]): void;
2022-03-28 11:21:32 +03:00
indexOf(element: Element, comparator?: <T>(arg0: T, arg1: T) => boolean): number;
proof(element: Element): ProofPath;
2022-03-14 12:42:36 +03:00
getTreeEdge(edgeIndex: number): TreeEdge;
/**
* 🪓
* @param count
*/
getTreeSlices(count?: number): TreeSlice[];
/**
* Serialize entire tree state including intermediate layers into a plain object
* Deserializing it back will not require to recompute any hashes
* Elements are not converted to a plain type, this is responsibility of the caller
*/
serialize(): SerializedTreeState;
/**
* Deserialize data into a MerkleTree instance
* Make sure to provide the same hashFunction as was used in the source tree,
* otherwise the tree state will be invalid
*/
static deserialize(data: SerializedTreeState, hashFunction?: HashFunction<Element>): MerkleTree;
toString(): string;
}