UNPKG

@chainsafe/eth2.0-utils

Version:

Utilities required across multiple lodestar packages

31 lines (30 loc) 1.18 kB
/** * @module util/merkleTree */ /// <reference types="node" /> import { MerkleTree, number64, bytes32, Root } from "@chainsafe/eth2.0-types"; import { IProgressiveMerkleTree } from "./interface"; export interface IMerkleTreeSerialization { serializeTree(tree: MerkleTree): Buffer; serializeLength(length: number): Buffer; deserializeTree(tree: Buffer): MerkleTree; } export declare class ProgressiveMerkleTree implements IProgressiveMerkleTree { private readonly _depth; private readonly _zerohashes; private readonly serialization; private _tree; private _dirty; constructor(depth: number, tree: bytes32[][], serialization: IMerkleTreeSerialization); static deserialize(data: Buffer, serialization: IMerkleTreeSerialization): ProgressiveMerkleTree; static empty(depth: number, serialization: IMerkleTreeSerialization): ProgressiveMerkleTree; depth(): number; push(item: bytes32): void; add(index: number64, item: bytes32): void; getProof(index: number): bytes32[]; root(): Root; toObject(): MerkleTree; private calculateBranchesIfNecessary; private calculateBranches; private generateZeroHashes; }