Class CSMTUtils

Collection of utility functions for compact sparse merkle tree

CSMTUtils

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: CompactSparseMerkleProof
    • 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

    CSMTUtils

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

    Type Parameters

    • K
    • V

    Parameters

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

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

      • hashKey: boolean
      • hasher: Hasher

    Returns boolean

    {boolean}

    Static

    Memberof

    CSMTUtils

  • Verify Compact Proof for Compact Sparse Merkle Tree

    Type Parameters

    • K
    • V

    Parameters

    • cproof: CSparseCompactMerkleProof
    • 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

    CSMTUtils

  • Verify Proof of Compact Sparse Merkle Tree

    Type Parameters

    • K
    • V

    Parameters

    • proof: CompactSparseMerkleProof
    • root: 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

    CSMTUtils

  • Verify a merkle proof, return result and updates.

    Type Parameters

    • K
    • V

    Parameters

    • proof: CompactSparseMerkleProof
    • 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 {
        ok: boolean;
        updates: null | [Field, Field[]][];
    }

    {({ ok: boolean; updates: [Field, Field[]][] | null; })}

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

    Static

    Memberof

    CSMTUtils