Class MerkleTreeUtils

Collection of utility functions for merkle tree

MerkleTreeUtils

Constructors

Methods

  • Returns true if the value is in the tree and it is at the index from the key

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • value: V
    • 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.

      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    MerkleTreeUtils

  • Returns true if there is no value at the index from the key

    Type Parameters

    • V

    Parameters

    Returns boolean

    {boolean}

    Static

    Memberof

    MerkleTreeUtils

  • Calculate new root based on value. Note: This method cannot be executed in a circuit.

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • Optional value: V
    • Optional 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.

      • hashValue: boolean
      • hasher: Hasher

    Returns Field

    {Field}

    Static

    Memberof

    MerkleTreeUtils

  • Compute new merkle root by index and valueHashOrValueField

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = PoseidonHasherFunc

    Returns Field

    {Field}

    Static

    Memberof

    MerkleTreeUtils

  • Compute new merkle root by index and valueHashOrValueField, return new root and updates.

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = PoseidonHasherFunc

    Returns {
        actualRoot: Field;
        updates: [Field, Field[]][];
    }

    {{ actualRoot: Field; updates: [Field, Field[]][] }}

    • actualRoot: Field
    • updates: [Field, Field[]][]

    Static

    Memberof

    MerkleTreeUtils

  • Verify the merkle proof.

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • Optional value: V
    • Optional 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.

      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    MerkleTreeUtils

  • Verify the merkle proof by index and valueHashOrValueField

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = PoseidonHasherFunc

    Returns boolean

    {boolean}

    Static

    Memberof

    MerkleTreeUtils

  • Verify the merkle proof by index and valueHashOrValueField, return result and updates

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = PoseidonHasherFunc

    Returns {
        ok: boolean;
        updates: [Field, Field[]][];
    }

    {{ ok: boolean; updates: [Field, Field[]][] }}

    • ok: boolean
    • updates: [Field, Field[]][]

    Static

    Memberof

    MerkleTreeUtils