Class SparseMerkleTree<K, V>

Sparse Merkle Tree

Type Parameters

  • K

  • V

Hierarchy

  • SparseMerkleTree

Constructors

  • Type Parameters

    • K

    • V

    Parameters

    • root: Field
    • store: Store<V>
    • keyType: Provable<K>
    • valueType: Provable<V>
    • hasher: Hasher
    • config: {
          hashKey: boolean;
          hashValue: boolean;
      }
      • hashKey: boolean
      • hashValue: boolean

    Returns SparseMerkleTree<K, V>

Properties

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

Type declaration

  • hashKey: boolean
  • hashValue: boolean
hasher: Hasher
keyType: Provable<K>
root: Field
store: Store<V>
valueType: Provable<V>
initialPoseidonHashRoot: Field = ...

Initial empty tree root based on poseidon hash algorithm

Static

Memberof

SparseMerkleTree

Methods

  • Clear the tree.

    Returns

    {Promise}

    Memberof

    SparseMerkleTree

    Returns Promise<void>

  • Delete a value from tree and return the new root of the tree.

    Returns

    {Promise}

    Memberof

    SparseMerkleTree

    Parameters

    • key: K

    Returns Promise<Field>

  • Get the depth of the tree.

    Returns

    {number}

    Memberof

    SparseMerkleTree

    Returns number

  • Get the value for a key from the tree.

    Returns

    {(Promise<V | null>)}

    Memberof

    SparseMerkleTree

    Parameters

    • key: K

    Returns Promise<null | V>

  • Get the root of the tree.

    Returns

    {Field}

    Memberof

    SparseMerkleTree

    Returns Field

  • Check if the key exists in the tree.

    Returns

    {Promise}

    Memberof

    SparseMerkleTree

    Parameters

    • key: K

    Returns Promise<boolean>

  • Check if the tree is empty.

    Returns

    {boolean}

    Memberof

    SparseMerkleTree

    Returns boolean

  • Set the root of the tree.

    Memberof

    SparseMerkleTree

    Parameters

    • root: Field

    Returns Promise<void>

  • Parameters

    • root: Field
    • path: Field

    Returns Promise<{
        leafData: Field;
        pathNodes: Field[];
        sideNodes: Field[];
    }>

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

    Returns

    {Promise}

    Memberof

    SparseMerkleTree

    Parameters

    • key: K
    • Optional value: V

    Returns Promise<Field>

  • Update multiple leaves and return the new root of the tree.

    Returns

    {Promise}

    Memberof

    SparseMerkleTree

    Parameters

    • kvs: {
          key: K;
          value?: V;
      }[]

    Returns Promise<Field>

  • Parameters

    • root: Field
    • key: K
    • Optional value: V

    Returns Promise<Field>

  • Parameters

    • sideNodes: Field[]
    • pathNodes: Field[]
    • oldLeafData: Field
    • path: Field
    • Optional value: V

    Returns Field

  • Build a new sparse merkle tree

    Static

    Returns

    {Promise<SparseMerkleTree<K, V>>}

    Memberof

    SparseMerkleTree

    Type Parameters

    • K

    • V

    Parameters

    • store: Store<V>
    • KeyType: Provable<K>
    • ValueType: Provable<V>
    • Optional options: {
          hashKey?: boolean;
          hashValue?: boolean;
          hasher?: Hasher;
      } = ...
      • Optional hashKey?: boolean
      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns Promise<SparseMerkleTree<K, V>>

  • Import a sparse merkle tree via existing store

    Static

    Returns

    {Promise<SparseMerkleTree<K, V>>}

    Memberof

    SparseMerkleTree

    Type Parameters

    • K

    • V

    Parameters

    • store: Store<V>
    • keyType: Provable<K>
    • valueType: Provable<V>
    • Optional options: {
          hashKey?: boolean;
          hashValue?: boolean;
          hasher?: Hasher;
      } = ...
      • Optional hashKey?: boolean
      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns Promise<SparseMerkleTree<K, V>>

Generated using TypeDoc