ethereumjs-monorepo

@ethereumjs/mpt


@ethereumjs/mpt / verifyMerkleRangeProof

Function: verifyMerkleRangeProof()

verifyMerkleRangeProof(rootHash, firstKeyRaw, lastKeyRaw, keysRaw, values, proof, useKeyHashingFunction?): Promise<boolean>

Defined in: proof/range.ts:420

Checks whether the given leaf nodes and edge proof can prove the given trie leaves range is matched with the specific root.

A range proof is a proof that includes the encoded trie nodes from the root node to leaf node for one or more branches of a trie, allowing an entire range of leaf nodes to be validated. This is useful in applications such as snap sync where contiguous ranges of state trie data is received and validated for constructing world state, locally.

There are four situations:

NOTE: Currently only supports verification when the length of firstKey and lastKey are the same.

Parameters

rootHash

Uint8Array

root hash of state trie this proof is being verified against.

firstKeyRaw

Uint8Array<ArrayBufferLike> | null

first key of range being proven (bytes, or null).

lastKeyRaw

Uint8Array<ArrayBufferLike> | null

last key of range being proven (bytes, or null).

keysRaw

Uint8Array<ArrayBufferLike>[]

key list of leaf data being proven.

values

Uint8Array<ArrayBufferLike>[]

value list of leaf data being proven, one-to-one correspondence with keys.

proof

Uint8Array<ArrayBufferLike>[] | null

proof node list, or null for an all-elements proof (both keys must be null too)

useKeyHashingFunction?

HashKeysFunction = keccak_256

hash function for secure trie key hashing (default: keccak256)

Returns

Promise<boolean>

a flag to indicate whether there exists more trie node in the trie