MerkleListIterator
MerkleListIterator helps iterating through a Merkle list.
This works similar to calling list.pop()
or list.push()
repeatedly, but maintaining the entire list instead of removing elements.
The core methods that support iteration are () and ().
let iterator = MerkleListIterator.startIterating(list);
let firstElement = iterator.next();
We maintain two commitments:
- One to the entire array, to be able to prove that we end iteration at the correct point.
- One to the array from the current index until the end, to efficiently step forward.
Type parameters
• T
Implements
Constructors
new MerkleListIterator()
new MerkleListIterator<T>(value: MerkleListIteratorBase<T>): MerkleListIterator<T>
Parameters
• value: MerkleListIteratorBase
\<T
>
Returns
Source
lib/provable/merkle-list.ts:350
Properties
currentHash
currentHash: Field;
Implementation of
MerkleListIteratorBase.currentHash
Source
lib/provable/merkle-list.ts:347
currentIndex
currentIndex: Unconstrained<number>;
Implementation of
MerkleListIteratorBase.currentIndex
Source
lib/provable/merkle-list.ts:348
data
readonly data: Unconstrained<WithHash<T>[]>;
Implementation of
MerkleListIteratorBase.data
Source
lib/provable/merkle-list.ts:343
hash
readonly hash: Field;
Implementation of
MerkleListIteratorBase.hash
Source
lib/provable/merkle-list.ts:344
_emptyHash
static _emptyHash: undefined | Field;
Source
lib/provable/merkle-list.ts:640
_innerProvable
static _innerProvable: undefined | ProvableHashable<any>;
Source
lib/provable/merkle-list.ts:643
_nextHash
static _nextHash: undefined | (hash: Field, value: any) => Field;
Source
lib/provable/merkle-list.ts:639
_provable
static _provable: undefined | ProvableHashable<MerkleListIterator<any>>;
Source
lib/provable/merkle-list.ts:642
Accessors
Constructor
get Constructor(): typeof MerkleListIterator
Returns
typeof MerkleListIterator
Source
lib/provable/merkle-list.ts:645
Unsafe
get Unsafe(): {
"next": {
"element": T;
"isDummy": Bool;
};
"previous": {
"element": T;
"isDummy": Bool;
};
}
Low-level APIs for advanced uses
Returns
{
"next": {
"element": T;
"isDummy": Bool;
};
"previous": {
"element": T;
"isDummy": Bool;
};
}
next()
Version of next which doesn't guarantee anything about the returned element in case the iterator is at the end.
Instead, the isDummy
flag is also returned so that this case can
be handled in a custom way.
Returns
{
"element": T;
"isDummy": Bool;
}
element
element: T;
isDummy
isDummy: Bool;
previous()
Version of previous which doesn't guarantee anything about the returned element in case the iterator is at the start.
Instead, the isDummy
flag is also returned so that this case can
be handled in a custom way.
Returns
{
"element": T;
"isDummy": Bool;
}
element
element: T;
isDummy
isDummy: Bool;
Source
lib/provable/merkle-list.ts:477
innerProvable
get innerProvable(): ProvableHashable<T>
Returns
ProvableHashable
\<T
>
Source
lib/provable/merkle-list.ts:662
emptyHash
get static emptyHash(): Field
Returns
Source
lib/provable/merkle-list.ts:657
Methods
_index()
_index(direction: "next" | "previous", i?: number): number
Parameters
• direction: "next"
| "previous"
• i?: number
Returns
number
Source
lib/provable/merkle-list.ts:404
_updateIndex()
_updateIndex(direction: "next" | "previous"): void
Parameters
• direction: "next"
| "previous"
Returns
void
Source
lib/provable/merkle-list.ts:412
assertAtEnd()
assertAtEnd(): void
Returns
void
Source
lib/provable/merkle-list.ts:376
assertAtStart()
assertAtStart(): void
Returns
void
Source
lib/provable/merkle-list.ts:354
clone()
clone(): MerkleListIterator<T>
Returns
Source
lib/provable/merkle-list.ts:534
isAtEnd()
isAtEnd(): Bool
Returns
Source
lib/provable/merkle-list.ts:358
isAtStart()
isAtStart(): Bool
Returns
Source
lib/provable/merkle-list.ts:380
jumpToEnd()
jumpToEnd(): void
Returns
void
Source
lib/provable/merkle-list.ts:362
jumpToEndIf()
jumpToEndIf(condition: Bool): void
Parameters
• condition: Bool
Returns
void
Source
lib/provable/merkle-list.ts:367
jumpToStart()
jumpToStart(): void
Returns
void
Source
lib/provable/merkle-list.ts:384
jumpToStartIf()
jumpToStartIf(condition: Bool): void
Parameters
• condition: Bool
Returns
void
Source
lib/provable/merkle-list.ts:391
next()
next(): T
Returns
T
Source
lib/provable/merkle-list.ts:450
nextHash()
nextHash(hash: Field, value: T): Field
Parameters
• hash: Field
• value: T
Returns
Source
lib/provable/merkle-list.ts:649
previous()
previous(): T
Returns
T
Source
lib/provable/merkle-list.ts:419
create()
static create<T>(
type: ProvableHashable<T>,
nextHash: (hash: Field, value: T) => Field,
emptyHash_: Field): typeof MerkleListIterator & {
"empty": () => MerkleListIterator<T>;
"from": (array: T[]) => MerkleListIterator<T>;
"provable": ProvableHashable<MerkleListIterator<T>>;
"startIterating": (list: MerkleListBase<T>) => MerkleListIterator<T>;
"startIteratingFromLast": (list: MerkleListBase<T>) => MerkleListIterator<T>;
}
Create a Merkle array type
Type parameters
• T
Parameters
• type: ProvableHashable
\<T
>
• nextHash= undefined
• emptyHash_: Field
= emptyHash
Returns
typeof MerkleListIterator
& {
"empty"
: () => MerkleListIterator
\<T
>;
"from"
: (array
: T
[]) => MerkleListIterator
\<T
>;
"provable"
: ProvableHashable
\<MerkleListIterator
\<T
>>;
"startIterating"
: (list
: MerkleListBase
\<T
>) => MerkleListIterator
\<T
>;
"startIteratingFromLast"
: (list
: MerkleListBase
\<T
>) => MerkleListIterator
\<T
>;
}
Source
lib/provable/merkle-list.ts:548
createFromList()
static createFromList<T>(merkleList: typeof MerkleList): typeof MerkleListIterator & {
"empty": () => MerkleListIterator<T>;
"from": (array: T[]) => MerkleListIterator<T>;
"provable": ProvableHashable<MerkleListIterator<T>>;
"startIterating": (list: MerkleListBase<T>) => MerkleListIterator<T>;
"startIteratingFromLast": (list: MerkleListBase<T>) => MerkleListIterator<T>;
}
Type parameters
• T
Parameters
• merkleList: typeof MerkleList
Returns
typeof MerkleListIterator
& {
"empty"
: () => MerkleListIterator
\<T
>;
"from"
: (array
: T
[]) => MerkleListIterator
\<T
>;
"provable"
: ProvableHashable
\<MerkleListIterator
\<T
>>;
"startIterating"
: (list
: MerkleListBase
\<T
>) => MerkleListIterator
\<T
>;
"startIteratingFromLast"
: (list
: MerkleListBase
\<T
>) => MerkleListIterator
\<T
>;
}