Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MerkleTree

Index

Constructors

  • Please use MerkleTree.sparseMerkleTreeFromLeaves to create trees instead. This method is exposed for testing purposes, and for those that are familiar with the MerkleTree data structure.

    Parameters

    • leaves: Buffer[]

      leaf nodes of the tree

    Returns MerkleTree

Properties

depth: number
leaves: TreeNode[]
root: Buffer

Methods

  • getProof(leafIndex: number, minimizeProofHeight?: boolean, treeHeight?: number, verbose?: boolean): MerkleTreeProof
  • getRoot(): Buffer
  • updateLeaf(leafIndex: number, newLeaf: Buffer, verbose?: boolean): void
  • sparseMerkleTreeFromLeaves(leaves: Buffer[], depth: number): MerkleTree
  • This is the recommended way to create MerkleTrees. If you're trying to match an on-chain MerkleTree, set depth to <a href="index.ConcurrentMerkleTreeAccount.html">ConcurrentMerkleTreeAccount</a>.getMaxDepth()

    Parameters

    • leaves: Buffer[]

      leaves of the tree

    • depth: number

      number of levels in the tree

    Returns MerkleTree

    MerkleTree

  • verify(root: Buffer, merkleTreeProof: MerkleTreeProof, verbose?: boolean): boolean
  • Verifies that a root matches the proof.

    Parameters

    • root: Buffer

      Root of a MerkleTree

    • merkleTreeProof: MerkleTreeProof

      Proof to a leaf in the MerkleTree

    • verbose: boolean = false

      Whether to print hashed nodes

    Returns boolean

    Whether the proof is valid

Generated using TypeDoc