Class CompactSparseMerkleTree<K, V>

Compact Sparse Merkle Tree

CompactSparseMerkleTree

Type Parameters

  • K
  • V

Hierarchy (view full)

Constructors

  • Creates an instance of CompactSparseMerkleTree.

    Type Parameters

    • K
    • V

    Parameters

    • store: Store<V>
    • keyType: Provable<K>
    • valueType: Provable<V>
    • Optional root: Field
    • 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.

      • Optional hashKey?: boolean
      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns CompactSparseMerkleTree<K, V>

    Memberof

    CompactSparseMerkleTree

Properties

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

Type declaration

  • hashKey: boolean
  • hashValue: boolean
keyType: Provable<K>
root: Field
store: Store<V>
th: TreeHasher<K, V>
valueType: Provable<V>

Methods

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

    Parameters

    • key: K

    Returns Promise<Field>

    {Promise}

    Memberof

    CompactSparseMerkleTree

  • Parameters

    • path: Field
    • sideNodes: Field[]
    • pathNodes: Field[]
    • oldLeafData: Field[]

    Returns Promise<Field>

  • Get the value for a key from the tree.

    Parameters

    • key: K

    Returns Promise<null | V>

    {(Promise<V | null>)}

    Memberof

    CompactSparseMerkleTree

  • Check if the key exists in the tree.

    Parameters

    • key: K

    Returns Promise<boolean>

    {Promise}

    Memberof

    CompactSparseMerkleTree

  • Set the root of the tree.

    Parameters

    • root: Field

    Returns Promise<void>

    {Promise}

    Memberof

    CompactSparseMerkleTree

  • Parameters

    • path: Field
    • root: Field
    • getSiblingData: boolean

    Returns Promise<{
        currentData: null | Field[];
        pathNodes: Field[];
        siblingData: null | Field[];
        sideNodes: Field[];
    }>

  • 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 Promise<Field>

    {Promise}

    Memberof

    CompactSparseMerkleTree

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

    Parameters

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

    Returns Promise<Field>

    {Promise}

    Memberof

    CompactSparseMerkleTree

  • Parameters

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

    Returns Field

  • Import a compacted sparse merkle tree

    Type Parameters

    • K
    • V

    Parameters

    • store: Store<V>
    • 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.

      • Optional hashKey?: boolean
      • Optional hashValue?: boolean
      • Optional hasher?: Hasher

    Returns Promise<CompactSparseMerkleTree<K, V>>

    {Promise<CompactSparseMerkleTree<K, V>>}

    Static

    Memberof

    CompactSparseMerkleTree