UNPKG

2.08 kBTypeScriptView Raw
1/// <reference types="node" />
2import { CheckpointTrie } from './checkpointTrie';
3import { Proof } from './baseTrie';
4/**
5 * You can create a secure Trie where the keys are automatically hashed
6 * using **keccak256** by using `import { SecureTrie as Trie } from 'merkle-patricia-tree'`.
7 * It has the same methods and constructor as `Trie`.
8 * @class SecureTrie
9 * @extends Trie
10 * @public
11 */
12export declare class SecureTrie extends CheckpointTrie {
13 constructor(...args: any);
14 /**
15 * Gets a value given a `key`
16 * @param key - the key to search for
17 * @returns A Promise that resolves to `Buffer` if a value was found or `null` if no value was found.
18 */
19 get(key: Buffer): Promise<Buffer | null>;
20 /**
21 * Stores a given `value` at the given `key`.
22 * For a falsey value, use the original key to avoid double hashing the key.
23 * @param key
24 * @param value
25 */
26 put(key: Buffer, val: Buffer): Promise<void>;
27 /**
28 * Deletes a value given a `key`.
29 * @param key
30 */
31 del(key: Buffer): Promise<void>;
32 /**
33 * prove has been renamed to {@link SecureTrie.createProof}.
34 * @deprecated
35 * @param trie
36 * @param key
37 */
38 static prove(trie: SecureTrie, key: Buffer): Promise<Proof>;
39 /**
40 * Creates a proof that can be verified using {@link SecureTrie.verifyProof}.
41 * @param trie
42 * @param key
43 */
44 static createProof(trie: SecureTrie, key: Buffer): Promise<Proof>;
45 /**
46 * Verifies a proof.
47 * @param rootHash
48 * @param key
49 * @param proof
50 * @throws If proof is found to be invalid.
51 * @returns The value from the key.
52 */
53 static verifyProof(rootHash: Buffer, key: Buffer, proof: Proof): Promise<Buffer | null>;
54 /**
55 * Returns a copy of the underlying trie with the interface of SecureTrie.
56 * @param includeCheckpoints - If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
57 */
58 copy(includeCheckpoints?: boolean): SecureTrie;
59}