Verify a Merkle Inclusion Proof for a Ledger Transaction
Last updated: November 29, 2026
Quick Overview
Build a binary Merkle tree over a ledger's transactions using domain-separated SHA-256 leaf and inner-node hashes, generate an inclusion proof for one transaction, and write a verifier that checks the proof against only the published root hash.
Ripple
November 29, 20260
0
0 solved
Build a binary Merkle tree over a ledger's transactions using domain-separated SHA-256 leaf and inner-node hashes, generate an inclusion proof for one transaction, and write a verifier that checks the proof against only the published root hash.
Every XRP Ledger header commits to its transaction set and account state through hash trees, which is what lets light clients and auditors trust a single validated hash. This screen checks hashing fundamentals, careful index arithmetic, and whether you know about second-preimage attacks on naive Merkle trees.
What the Interviewer Expects
- Hash leaves and inner nodes with different prefixes
- Handle an odd number of nodes per level with a clear, documented rule
- Record sibling side (left or right) in the proof
- Verify using only the leaf, proof, and root
- Explain proof size and why it is logarithmic
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- The XRP Ledger's SHAMap is a radix-16 tree keyed by hash; how does a proof differ there?
- How would you prove that a transaction is NOT in the set?
- Why is duplicating the last node (as some chains do) dangerous?
- How would a light client obtain a trusted root in the first place?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Given raw transaction bytes in canonical order, produce a root. For index i, produce a proof: a list of (side, sibling_hash) from leaf to root. verify(tx, proof, root) must accept genuine proofs a...
High-Level Design
Leaves are H(0x00 || tx) and inner nodes H(0x01 || left || right). The prefixes stop an attacker presenting an inner node's 64-byte preimage as if it were a transaction. For odd levels I promote t...