2022-03-24 17:41:06 +03:00
|
|
|
import { default as MerkleTree } from './FixedMerkleTree';
|
2022-03-14 12:42:36 +03:00
|
|
|
export { PartialMerkleTree } from './PartialMerkleTree';
|
|
|
|
export { simpleHash } from './simpleHash';
|
2022-03-24 17:41:06 +03:00
|
|
|
export { MerkleTree };
|
|
|
|
export default MerkleTree;
|
2023-09-12 12:32:36 +03:00
|
|
|
export type HashFunction<T> = {
|
2022-03-14 12:42:36 +03:00
|
|
|
(left: T, right: T): string;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type MerkleTreeOptions = {
|
2022-03-14 12:42:36 +03:00
|
|
|
hashFunction?: HashFunction<Element>;
|
|
|
|
zeroElement?: Element;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type Element = string | number;
|
|
|
|
export type SerializedTreeState = {
|
2022-03-14 12:42:36 +03:00
|
|
|
levels: number;
|
|
|
|
_zeros: Array<Element>;
|
|
|
|
_layers: Array<Element[]>;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type SerializedPartialTreeState = {
|
2022-03-14 12:42:36 +03:00
|
|
|
levels: number;
|
2022-03-28 10:44:50 +03:00
|
|
|
_layers: Element[][];
|
2022-03-14 12:42:36 +03:00
|
|
|
_zeros: Array<Element>;
|
|
|
|
_edgeLeafProof: ProofPath;
|
|
|
|
_edgeLeaf: LeafWithIndex;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type ProofPath = {
|
2022-03-14 12:42:36 +03:00
|
|
|
pathElements: Element[];
|
|
|
|
pathIndices: number[];
|
|
|
|
pathPositions: number[];
|
|
|
|
pathRoot: Element;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type TreeEdge = {
|
2022-03-14 12:42:36 +03:00
|
|
|
edgeElement: Element;
|
|
|
|
edgePath: ProofPath;
|
|
|
|
edgeIndex: number;
|
|
|
|
edgeElementsCount: number;
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type TreeSlice = {
|
2022-03-14 12:42:36 +03:00
|
|
|
edge: TreeEdge;
|
|
|
|
elements: Element[];
|
|
|
|
};
|
2023-09-12 12:32:36 +03:00
|
|
|
export type LeafWithIndex = {
|
2022-03-14 12:42:36 +03:00
|
|
|
index: number;
|
|
|
|
data: Element;
|
|
|
|
};
|