Class ProvableSMTUtils

Collection of utility functions for sparse merkle tree in the circuit.

ProvableSMTUtils

Constructors

Properties

EMPTY_VALUE: Field = EMPTY_VALUE

Empty value for sparse merkle tree

Static

Memberof

ProvableSMTUtils

computeRootByField: ((sideNodes, keyHashOrKeyField, valueHashOrValueField, hasher?) => Field) = computeRootByFieldInCircuit

Calculate new root based on sideNodes, keyHashOrKeyField and valueHashOrValueField

Type declaration

    • (sideNodes, keyHashOrKeyField, valueHashOrValueField, hasher?): Field
    • Parameters

      • sideNodes: Field[]
      • keyHashOrKeyField: Field
      • valueHashOrValueField: Field
      • Optional hasher: Hasher = PoseidonHasherFunc

      Returns Field

Static

Returns

{Field}

Memberof

ProvableSMTUtils

verifyProofByField: ((proof, expectedRoot, keyHashOrKeyField, valueHashOrValueField, hasher?) => Bool) = verifyProofByFieldInCircuit

Verify a merkle proof by root, keyHashOrKeyField and valueHashOrValueField

Type declaration

    • (proof, expectedRoot, keyHashOrKeyField, valueHashOrValueField, hasher?): Bool
    • Parameters

      • proof: SparseMerkleProof
      • expectedRoot: Field
      • keyHashOrKeyField: Field
      • valueHashOrValueField: Field
      • Optional hasher: Hasher = PoseidonHasherFunc

      Returns Bool

Static

Returns

{Bool}

Memberof

ProvableSMTUtils

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
      • Optional hasher?: Hasher

    Returns Bool

    {Bool}

    Static

    Memberof

    ProvableSMTUtils

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

    Type Parameters

    • K

    Parameters

    • proof: SparseMerkleProof
    • 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; hashValue: whether to hash the value, the default is true.

      • hashKey: boolean
      • Optional hasher?: Hasher

    Returns Bool

    {Bool}

    Static

    Memberof

    ProvableSMTUtils

  • Calculate new root based on sideNodes, key and value

    Type Parameters

    • K
    • V

    Parameters

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

    Returns Field

    {Field}

    Static

    Memberof

    ProvableSMTUtils