Class DeepSparseMerkleSubTree<K, V>

DeepSparseMerkleSubTree is a deep sparse merkle subtree for working on only a few leafs.

DeepSparseMerkleSubTree

Type Parameters

  • K
  • V

Constructors

  • Creates an instance of DeepSparseMerkleSubTree.

    Type Parameters

    • K
    • V

    Parameters

    • root: Field

      merkle root

    • keyType: Provable<K>
    • 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 DeepSparseMerkleSubTree<K, V>

    Memberof

    DeepSparseMerkleSubTree

Properties

config: {
    hashKey: boolean;
    hashValue: boolean;
}

Type declaration

  • hashKey: boolean
  • hashValue: boolean
hasher: Hasher
keyType: Provable<K>
nodeStore: Map<string, Field[]>
root: Field
valueStore: Map<string, Field>
valueType: Provable<V>

Methods

  • Add a branch to the tree, a branch is generated by smt.prove.

    Parameters

    • proof: SparseMerkleProof
    • key: K
    • Optional value: V
    • Optional ignoreInvalidProof: boolean = false

      whether to throw an error when proof is invalid

    Returns void

    Memberof

    DeepSparseMerkleSubTree

  • Check whether there is a corresponding key and value in the tree

    Parameters

    • key: K
    • value: V

    Returns boolean

    {boolean}

    Memberof

    DeepSparseMerkleSubTree

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

    Parameters

    • key: K
    • Optional value: V

    Returns Field

    {Field}

    Memberof

    DeepSparseMerkleSubTree