mirror of
https://github.com/tornadocash/fixed-merkle-tree.git
synced 2024-11-25 11:18:31 +01:00
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { Element, HashFunction, MerkleTreeOptions, SerializedTreeState, TreeEdge, TreeSlice } from './';
|
|
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;
|
|
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;
|
|
}
|