fixed-merkle-tree/src/index.ts

44 lines
948 B
TypeScript
Raw Normal View History

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[]>
}
export type SerializedPartialTreeState = {
levels: number,
leaves: Element[]
_zeros: Array<Element>,
_edgeLeafProof: ProofPath,
_initialRoot: Element,
_edgeLeaf: LeafWithIndex
}
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
}
export type LeafWithIndex = { index: number, data: Element }