Class SMTUtils

Collection of utility functions for sparse merkle tree

SMTUtils

Constructors

Methods

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

    Type Parameters

    • K
    • V

    Parameters

    • proof: SparseMerkleProof
    • expectedRoot: Field
    • key: K
    • keyType: Provable<K>
    • value: V
    • valueType: Provable<V>
    • Optional options: {
          hashKey: boolean;
          hashValue: boolean;
          hasher: Hasher;
      } = ...

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

      • hashKey: boolean
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    SMTUtils

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

    Type Parameters

    • K
    • V

    Parameters

    • proof: SparseMerkleProof
    • expectedRoot: Field
    • key: K
    • keyType: Provable<K>
    • Optional options: {
          hashKey: boolean;
          hashValue: boolean;
          hasher: Hasher;
      } = ...

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

      • hashKey: boolean
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    SMTUtils

  • Calculate new root based on sideNodes, key and value

    Type Parameters

    • K
    • V

    Parameters

    • sideNodes: Field[]
    • key: K
    • keyType: Provable<K>
    • Optional value: V
    • Optional valueType: Provable<V>
    • Optional options: {
          hashKey: boolean;
          hashValue: boolean;
          hasher: Hasher;
      } = ...

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

      • hashKey: boolean
      • hashValue: boolean
      • hasher: Hasher

    Returns Field

    {Field}

    Static

    Memberof

    SMTUtils

  • Verify a compacted merkle proof

    Type Parameters

    • K
    • V

    Parameters

    • cproof: SparseCompactMerkleProof
    • expectedRoot: Field
    • key: K
    • keyType: Provable<K>
    • Optional value: V
    • Optional valueType: Provable<V>
    • Optional options: {
          hashKey: boolean;
          hashValue: boolean;
          hasher: Hasher;
      } = ...
      • hashKey: boolean
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    SMTUtils

  • Verify a merkle proof

    Type Parameters

    • K
    • V

    Parameters

    • proof: SparseMerkleProof
    • expectedRoot: Field
    • key: K
    • keyType: Provable<K>
    • Optional value: V
    • Optional valueType: Provable<V>
    • Optional options: {
          hashKey: boolean;
          hashValue: boolean;
          hasher: Hasher;
      } = ...

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

      • hashKey: boolean
      • hashValue: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    SMTUtils