Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Index

Constructors

constructor

Methods

encodePath

  • encodePath(path: Uint8Array, nibbleCount: number, isLeaf: boolean): Uint8Array
  • Encode path depends on node type and nibble count

    Parameters

    • path: Uint8Array

      path buffer

    • nibbleCount: number

      number of nibbles

    • isLeaf: boolean

      is leaf node

    Returns Uint8Array

    encoded path

getBitsFromMask

  • getBitsFromMask(mask: any): string[]
  • Decompose a bitmask to get number of bit's indices

    Parameters

    • mask: any

      bitmask

    Returns string[]

    array of the indices of bits

getBranchHash

  • Calculate branch hash. Hash(encodedPath + 16 links)

    Parameters

    • encodedPath: string

      encoded path of the branch in hexadecimal format

    • links: MerkleTreeBranchLink[]

      branch links array

    Returns string

    branch hash (Hash(encodedPath + links))

getLeafHash

  • getLeafHash(encodedPath: string, leafValue: any): string
  • Calculate leaf hash. Hash(encodedPath + leaf value)

    Parameters

    • encodedPath: string

      encoded path of the leaf in hexadecimal format

    • leafValue: any

      leaf value

    Returns string

    leaf hash (Hash(encodedPath + leaf value))

getPathLength

  • getPathLength(nibbleCount: any): number
  • Calculate path length from given nibbles count

    Parameters

    • nibbleCount: any

      Nibbles count

    Returns number

    the length of the path

isBranch

  • isBranch(marker: any): boolean

isLeaf

  • isLeaf(marker: any): boolean

nibbleAt

  • nibbleAt(path: Uint8Array, index: number): number

parseBranch

  • parseBranch(offsetRaw: Uint8Array, path: Uint8Array, nibbleCount: number): [Uint8Array, MerkleTreeBranch]
  • Parse branch tree node

    Parameters

    • offsetRaw: Uint8Array

      partial raw buffer

    • path: Uint8Array

      merkle tree path

    • nibbleCount: number

      number of nibbles

    Returns [Uint8Array, MerkleTreeBranch]

    unprocess raw buffer

parseLeaf

  • parseLeaf(offsetRaw: Uint8Array, path: Uint8Array, nibbleCount: number): [Uint8Array, MerkleTreeLeaf]
  • Parse leaf tree node

    Parameters

    • offsetRaw: Uint8Array

      partial raw buffer

    • path: Uint8Array

      merkle tree path

    • nibbleCount: number

      number of nibbles

    Returns [Uint8Array, MerkleTreeLeaf]

    unprocess raw buffer

parseMerkleTreeFromRaw

Generated using TypeDoc