Class MerkleTreeUtils

Collection of utility functions for merkle tree

Hierarchy

  • MerkleTreeUtils

Constructors

Methods

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

    Static

    Returns

    {boolean}

    Memberof

    MerkleTreeUtils

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • value: V
    • valueType: Provable<V>
    • Optional options: {
          hashValue: boolean;
          hasher: Hasher;
      } = ...
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

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

    Static

    Returns

    {boolean}

    Memberof

    MerkleTreeUtils

    Type Parameters

    • V

    Parameters

    Returns boolean

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

    Static

    Returns

    {Field}

    Memberof

    MerkleTreeUtils

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • Optional value: V
    • Optional valueType: Provable<V>
    • Optional options: {
          hashValue: boolean;
          hasher: Hasher;
      } = ...
      • hashValue: boolean
      • hasher: Hasher

    Returns Field

  • Compute new merkle root by index and valueHashOrValueField

    Static

    Returns

    {Field}

    Memberof

    MerkleTreeUtils

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = Poseidon.hash

    Returns Field

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

    Static

    Returns

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

    Memberof

    MerkleTreeUtils

    Parameters

    • proof: BaseMerkleProof
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = Poseidon.hash

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

    • actualRoot: Field
    • updates: [Field, Field[]][]
  • Verify the merkle proof.

    Static

    Returns

    {boolean}

    Memberof

    MerkleTreeUtils

    Type Parameters

    • V

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • Optional value: V
    • Optional valueType: Provable<V>
    • Optional options: {
          hashValue: boolean;
          hasher: Hasher;
      } = ...
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

  • Verify the merkle proof by index and valueHashOrValueField

    Static

    Returns

    {boolean}

    Memberof

    MerkleTreeUtils

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = Poseidon.hash

    Returns boolean

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

    Static

    Returns

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

    Memberof

    MerkleTreeUtils

    Parameters

    • proof: BaseMerkleProof
    • expectedRoot: Field
    • index: bigint
    • valueHashOrValueField: Field
    • Optional hasher: Hasher = Poseidon.hash

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

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

Generated using TypeDoc