2022-03-01 06:33:46 +01:00
|
|
|
export { default as MerkleTree } from './FixedMerkleTree'
|
|
|
|
export { PartialMerkleTree } from './PartialMerkleTree'
|
2022-02-28 08:00:28 +01:00
|
|
|
export { simpleHash } from './simpleHash'
|
2022-02-22 09:45:31 +01:00
|
|
|
|
2022-02-28 08:00:28 +01:00
|
|
|
export type HashFunction<T> = {
|
|
|
|
(left: T, right: T): string
|
2020-07-31 03:00:33 +02:00
|
|
|
}
|
|
|
|
|
2022-02-22 09:45:31 +01:00
|
|
|
export type MerkleTreeOptions = {
|
2022-02-28 08:00:28 +01:00
|
|
|
hashFunction?: HashFunction<Element>
|
2022-02-22 09:45:31 +01:00
|
|
|
zeroElement?: Element
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Element = string | number
|
|
|
|
|
|
|
|
export type SerializedTreeState = {
|
|
|
|
levels: number,
|
|
|
|
_zeros: Array<Element>,
|
|
|
|
_layers: Array<Element[]>
|
|
|
|
}
|
2022-02-24 04:21:14 +01:00
|
|
|
|
2022-03-02 03:02:23 +01:00
|
|
|
export type SerializedPartialTreeState = {
|
|
|
|
levels: number,
|
|
|
|
leaves: Element[]
|
|
|
|
_zeros: Array<Element>,
|
|
|
|
_edgeLeafProof: ProofPath,
|
|
|
|
_initialRoot: Element,
|
|
|
|
_edgeLeaf: LeafWithIndex
|
|
|
|
}
|
|
|
|
|
2022-02-24 04:21:14 +01:00
|
|
|
export type ProofPath = {
|
|
|
|
pathElements: Element[],
|
|
|
|
pathIndices: number[],
|
|
|
|
pathPositions: number[],
|
2022-03-09 07:25:49 +01:00
|
|
|
pathRoot: Element
|
2022-02-22 09:45:31 +01:00
|
|
|
}
|
2022-02-28 08:00:28 +01:00
|
|
|
export type TreeEdge = {
|
|
|
|
edgeElement: Element;
|
|
|
|
edgePath: ProofPath;
|
2022-03-09 07:25:49 +01:00
|
|
|
edgeIndex: number;
|
2022-02-28 08:00:28 +01:00
|
|
|
}
|
2022-03-02 03:02:23 +01:00
|
|
|
export type LeafWithIndex = { index: number, data: Element }
|
|
|
|
|