-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into opcode-blobgasfee
- Loading branch information
Showing
5 changed files
with
303 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { utf8ToBytes } from 'ethereum-cryptography/utils' | ||
import { Trie } from '../dist/cjs/index.js' | ||
import { debug } from 'debug' | ||
|
||
debug.enable('*') | ||
|
||
const trie_entries: [string, string | null][] = [ | ||
['do', 'verb'], | ||
['ether', 'wookiedoo'], | ||
['horse', 'stallion'], | ||
['shaman', 'horse'], | ||
['doge', 'coin'], | ||
['ether', null], | ||
['dog', 'puppy'], | ||
['shaman', null], | ||
] | ||
|
||
const main = async () => { | ||
process.env.DEBUG = 'ethjs,*trie*' | ||
const trie = new Trie({ | ||
useRootPersistence: true, | ||
}) | ||
for (const [key, value] of trie_entries) { | ||
await trie.put(utf8ToBytes(key), value === null ? Uint8Array.from([]) : utf8ToBytes(value)) | ||
} | ||
const proof = await trie.createProof(utf8ToBytes('doge')) | ||
const valid = await trie.verifyProof(trie.root(), utf8ToBytes('doge'), proof) | ||
console.log('valid', valid) | ||
} | ||
|
||
main() |
Oops, something went wrong.