Urkel Tree is an optimized, cryptographically provable key-value store implemented as a base-2 merkelized trie, specifically designed for the Handshake protocol. It significantly outperforms alternatives like Ethereum's base-16 trie by operating as its own database, storing nodes in flat, append-only files for snapshotting and crash consistency. The current stable version is 1.0.3, with releases focusing on stability, minor bug fixes, and internal optimizations rather than rapid feature additions. Key differentiators include its architectural simplicity (only two node types), compact internal node size (76 bytes), and extremely small proof sizes (32 bytes per sibling node), which are crucial for maintaining proof sizes under 1KB even with millions of leaves. It offers fully transactional capabilities and inherently provides history independence and non-destruction properties. A critical usage requirement is that Urkel must be used with uniformly distributed keys, typically achieved through hashing. While compaction is available, it is currently inefficient and manual, with future C implementation planned for optimization.
npm install urkelVerified import paths — ran on the pinned version, not inferred.
This example demonstrates creating an Urkel Tree, performing a batch of insertions within a transaction, committing the changes to get a new root, and then generating and verifying a cryptographic proof for a specific key-value pair.
Avoid frequent tree commissions or prepare for manual compaction, especially in high-throughput scenarios.
Ensure your implementation exclusively uses the `urkel/radix` variant, which is the default for current versions. Refer to the `old-variants` branch if legacy code needs to be adapted.
Always hash your keys (e.g., using BLAKE2b or SHA256) before inserting them into the Urkel Tree to ensure uniform distribution.
Check that the `root`, `key`, `hash` function (e.g., BLAKE2b), and `bits` (key size) passed to `proof.verify()` exactly match those used during tree creation and snapshot generation. Also, ensure the key being proved actually exists or its absence is correctly expected.
Ensure your Node.js project is configured to run as a CommonJS module (e.g., omit `"type": "module"` in `package.json` or rename files to `.cjs`). For browser usage, use a bundler like Webpack or Rollup configured for CommonJS.