Skip to main content

MerkleListIterator

o1js / Modules / MerkleListIterator

Class: MerkleListIterator\<T>

MerkleListIterator helps iterating through a Merkle list. This works similar to calling list.pop() repeatedly, but maintaining the entire list instead of removing elements.

The core method that supports iteration is ().

let iterator = MerkleListIterator.startIterating(list);

let firstElement = iterator.next();

We maintain two commitments, both of which are equivalent to a Merkle list hash starting from the end of the array:

  • One to the entire array, to prove that we start iterating at the beginning.
  • One to the array from the current index until the end, to efficiently step forward.

Type parameters

Name
T

Implements

  • MerkleListIteratorBase\<T>

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new MerkleListIterator\<T>(value)

Type parameters

Name
T

Parameters

NameType
valueMerkleListIteratorBase\<T>

Defined in

lib/provable-types/merkle-list.ts:333

Properties

currentHash

currentHash: Field

Implementation of

MerkleListIteratorBase.currentHash

Defined in

lib/provable-types/merkle-list.ts:330


currentIndex

currentIndex: Unconstrained\<number>

Implementation of

MerkleListIteratorBase.currentIndex

Defined in

lib/provable-types/merkle-list.ts:331


data

Readonly data: Unconstrained\<WithHash\<T>[]>

Implementation of

MerkleListIteratorBase.data

Defined in

lib/provable-types/merkle-list.ts:326


hash

Readonly hash: Field

Implementation of

MerkleListIteratorBase.hash

Defined in

lib/provable-types/merkle-list.ts:327


_emptyHash

Static _emptyHash: undefined | Field

Defined in

lib/provable-types/merkle-list.ts:476


_innerProvable

Static _innerProvable: undefined | ProvableHashable\<any>

Defined in

lib/provable-types/merkle-list.ts:479


_nextHash

Static _nextHash: undefined | (hash: Field, value: any) => Field

Defined in

lib/provable-types/merkle-list.ts:475


_provable

Static _provable: undefined | ProvableHashable\<MerkleListIterator\<any>>

Defined in

lib/provable-types/merkle-list.ts:478

Accessors

Constructor

get Constructor(): typeof MerkleListIterator

Returns

typeof MerkleListIterator

Defined in

lib/provable-types/merkle-list.ts:481


innerProvable

get innerProvable(): ProvableHashable\<T>

Returns

ProvableHashable\<T>

Defined in

lib/provable-types/merkle-list.ts:498


emptyHash

Static get emptyHash(): Field

Returns

Field

Defined in

lib/provable-types/merkle-list.ts:493

Methods

assertAtStart

assertAtStart(): void

Returns

void

Defined in

lib/provable-types/merkle-list.ts:337


clone

clone(): MerkleListIterator\<T>

Returns

MerkleListIterator\<T>

Defined in

lib/provable-types/merkle-list.ts:394


isAtEnd

isAtEnd(): Bool

Returns

Bool

Defined in

lib/provable-types/merkle-list.ts:341


jumpToEnd

jumpToEnd(): void

Returns

void

Defined in

lib/provable-types/merkle-list.ts:344


jumpToEndIf

jumpToEndIf(condition): void

Parameters

NameType
conditionBool

Returns

void

Defined in

lib/provable-types/merkle-list.ts:350


next

next(): T

Returns

T

Defined in

lib/provable-types/merkle-list.ts:363


nextHash

nextHash(hash, value): Field

Parameters

NameType
hashField
valueT

Returns

Field

Defined in

lib/provable-types/merkle-list.ts:485


create

Static create\<T>(type, nextHash?, emptyHash_?): typeof MerkleListIterator & { empty: () => MerkleListIterator\<T> ; from: (array: T[]) => MerkleListIterator\<T> ; provable: ProvableHashable\<MerkleListIterator\<T>> ; startIterating: (list: MerkleListBase\<T>) => MerkleListIterator\<T> }

Create a Merkle array type

Type parameters

Name
T

Parameters

NameTypeDefault value
typeProvableHashable\<T>undefined
nextHash(hash: Field, value: T) => Fieldundefined
emptyHash_FieldemptyHash

Returns

typeof MerkleListIterator & { empty: () => MerkleListIterator\<T> ; from: (array: T[]) => MerkleListIterator\<T> ; provable: ProvableHashable\<MerkleListIterator\<T>> ; startIterating: (list: MerkleListBase\<T>) => MerkleListIterator\<T> }

Defined in

lib/provable-types/merkle-list.ts:408


createFromList

Static createFromList\<T>(merkleList): typeof MerkleListIterator & { empty: () => MerkleListIterator\<T> ; from: (array: T[]) => MerkleListIterator\<T> ; provable: ProvableHashable\<MerkleListIterator\<T>> ; startIterating: (list: MerkleListBase\<T>) => MerkleListIterator\<T> }

Type parameters

Name
T

Parameters

NameType
merkleListtypeof MerkleList

Returns

typeof MerkleListIterator & { empty: () => MerkleListIterator\<T> ; from: (array: T[]) => MerkleListIterator\<T> ; provable: ProvableHashable\<MerkleListIterator\<T>> ; startIterating: (list: MerkleListBase\<T>) => MerkleListIterator\<T> }

Defined in

lib/provable-types/merkle-list.ts:467