UNPKG

1.51 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Nibbles } from './trieNode';
3/**
4 * verifyRangeProof checks whether the given leaf nodes and edge proof
5 * can prove the given trie leaves range is matched with the specific root.
6 *
7 * There are four situations:
8 *
9 * - All elements proof. In this case the proof can be null, but the range should
10 * be all the leaves in the trie.
11 *
12 * - One element proof. In this case no matter the edge proof is a non-existent
13 * proof or not, we can always verify the correctness of the proof.
14 *
15 * - Zero element proof. In this case a single non-existent proof is enough to prove.
16 * Besides, if there are still some other leaves available on the right side, then
17 * an error will be returned.
18 *
19 * - Two edge elements proof. In this case two existent or non-existent proof(fisrt and last) should be provided.
20 *
21 * NOTE: Currently only supports verification when the length of firstKey and lastKey are the same.
22 *
23 * @param rootHash - root hash.
24 * @param firstKey - first key.
25 * @param lastKey - last key.
26 * @param keys - key list.
27 * @param values - value list, one-to-one correspondence with keys.
28 * @param proof - proof node list, if proof is null, both `firstKey` and `lastKey` must be null
29 * @returns a flag to indicate whether there exists more trie node in the trie
30 */
31export declare function verifyRangeProof(rootHash: Buffer, firstKey: Nibbles | null, lastKey: Nibbles | null, keys: Nibbles[], values: Buffer[], proof: Buffer[] | null): Promise<boolean>;