// npm install urkel bcrypto const bcrypto = require('bcrypto'); const random = require('bcrypto/lib/random'); const urkel = require('urkel'); const {BLAKE2b} = bcrypto; const {randomBytes} = random; const {Tree, Proof} = urkel; const dir = process.cwd(); (async () => { const tree = new Tree(BLAKE2b, 256, dir); await tree.open(); const txn = tree.transaction(); const k1 = Buffer.alloc(32); const v1 = randomBytes(300); const k2 = Buffer.alloc(32); k2[31] = 1; const v2 = randomBytes(300); await txn.insert(k1, v1); await txn.insert(k2, v2); const root = await txn.commit(); const snapshot = tree.snapshot(root); const proof = await snapshot.prove(k1); console.log(proof.nodes.length) })().catch(err => { console.log(err) });