Hierarchy

  • MerkleList<Field, this>
    • FieldList

Constructors

  • Parameters

    • __namedParameters: MerkleListBase<Field>

    Returns FieldList

Properties

data: Unconstrained<WithHash<Field>[]>
hash: Field
_emptyHash: undefined | Field
_innerProvable: undefined | ProvableHashable<any>
_nextHash: undefined | (hash: Field, t: any) => Field
_provable: undefined | ProvableHashable<MerkleList<any>>
empty: () => MerkleList<Field>
from: (array: Field[]) => MerkleList<Field>
fromReverse: (array: Field[]) => MerkleList<Field>
provable: ProvableHashable<MerkleList<Field>>

Accessors

  • get Constructor(): typeof MerkleList

    Returns typeof MerkleList

  • get innerProvable(): ProvableHashable<T>

    Returns ProvableHashable<T>

  • get emptyHash(): Field

    Returns Field

Methods

  • Returns MerkleList<Field>

  • Iterate through the list in a fixed number of steps any apply a given callback on each element.

    Proves that the iteration traverses the entire list. Once past the last element, dummy elements will be passed to the callback.

    Note: There are no guarantees about the contents of dummy elements, so the callback is expected to handle the isDummy flag separately.

    Parameters

    • length: number
    • callback: (element: Field, isDummy: Bool, i: number) => void

    Returns void

  • Returns Bool

  • Returns Unconstrained<number>

  • Parameters

    • hash: Field
    • value: Field

    Returns Field

  • Remove the last element from the list and return it.

    If the list is empty, returns a dummy element.

    Returns Field

  • Remove the last element from the list and return it.

    This proves that the list is non-empty, and fails otherwise.

    Returns Field

  • Return the last element, but only remove it if condition is true.

    If the list is empty, returns a dummy element.

    Parameters

    • condition: Bool

    Returns Field

  • Low-level, minimal version of pop() which lets the caller decide whether there is an element to pop.

    I.e. this proves:

    • If the input condition is true, this returns the last element and removes it from the list.
    • If the input condition is false, the list is unchanged and the return value is garbage.

    Note that if the caller passes true but the list is empty, this will fail. If the caller passes false but the list is non-empty, this succeeds and just doesn't pop off an element.

    Parameters

    • shouldPop: Bool

    Returns Field

  • Push a new element to the list.

    Parameters

    • element: Field

    Returns void

  • Push a new element to the list, if the condition is true.

    Parameters

    • condition: Bool
    • element: Field

    Returns void

  • Returns MerkleListIterator<Field>

  • Returns MerkleListIterator<Field>

  • Returns Unconstrained<Field[]>

  • Create a Merkle list type

    Optionally, you can tell create() how to do the hash that pushes a new list element, by passing a nextHash function.

    Type Parameters

    • T

    Parameters

    • type: WithProvable<ProvableHashable<T>>
    • OptionalnextHash: (hash: Field, value: T) => Field
    • OptionalemptyHash_: Field

    Returns typeof MerkleList & {
        empty: () => MerkleList<T>;
        from: (array: T[]) => MerkleList<T>;
        fromReverse: (array: T[]) => MerkleList<T>;
        provable: ProvableHashable<MerkleList<T>>;
    }

    class MyList extends MerkleList.create(Field, (hash, x) =>
    Poseidon.hashWithPrefix('custom', [hash, x])
    ) {}