Class MerkleTree<V>

Merkle Tree.

MerkleTree

Type Parameters

  • V

Constructors

Properties

hashValue: boolean
hasher: Hasher
height: number
maxNumIndex: bigint
root: Field
store: Store<V>
valueType: Provable<V>

Methods

  • Delete a value from tree and return the new root of the tree.

    Parameters

    • index: bigint

    Returns Promise<Field>

    {Promise}

    Memberof

    MerkleTree

  • Get the value for an index from the tree.

    Parameters

    • index: bigint

    Returns Promise<null | V>

    {(Promise<V | null>)}

    Memberof

    MerkleTree

  • Check if the index exists in the tree.

    Parameters

    • index: bigint

    Returns Promise<boolean>

    {Promise}

    Memberof

    MerkleTree

  • Parameters

    • root: Field
    • path: Field

    Returns Promise<{
        leafData: Field;
        pathNodes: Field[];
        sideNodes: Field[];
    }>

  • Update a new value for an index in the tree and return the new root of the tree.

    Parameters

    • index: bigint
    • Optional value: V

    Returns Promise<Field>

    {Promise}

    Memberof

    MerkleTree

  • Update multiple leaves and return the new root of the tree.

    Parameters

    • ivs: {
          index: bigint;
          value?: V;
      }[]

    Returns Promise<Field>

    {Promise}

    Memberof

    MerkleTree

  • Parameters

    • sideNodes: Field[]
    • pathNodes: Field[]
    • oldLeafData: Field
    • path: Field
    • Optional value: V

    Returns Field

  • Build a new merkle tree.

    Type Parameters

    • V

    Parameters

    • store: Store<V>
    • height: number
    • valueType: Provable<V>
    • Optional options: {
          hashValue?: boolean;
          hasher?: Hasher;
      } = ...

      hasher: The hash function to use, defaults to PoseidonHasherFunc; hashValue: whether to hash the value, the default is true.

      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns Promise<MerkleTree<V>>

    {Promise<MerkleTree>}

    Static

    Memberof

    MerkleTree

  • Import a merkle tree via existing store.

    Type Parameters

    • V

    Parameters

    • store: Store<V>
    • height: number
    • valueType: Provable<V>
    • Optional options: {
          hashValue?: boolean;
          hasher?: Hasher;
      } = ...

      hasher: The hash function to use, defaults to PoseidonHasherFunc; hashValue: whether to hash the value, the default is true.

      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns Promise<MerkleTree<V>>

    {Promise<MerkleTree>}

    Static

    Memberof

    MerkleTree