Verified interview challenge
Build and verify Merkle proofs
Build a Merkle tree, generate inclusion proofs and decide whether a supplied proof supports a claimed root.
Unlock with Full AccessThe challenge
The task combines tree traversal with exact hashing rules. Construct a tree from the supplied leaf values, return its root and produce proofs for selected leaves. Your verifier must also handle externally supplied proofs, including malformed entries, without relying on the original tree.
What you'll practise
Byte-exact hashing
Follow the specified leaf and parent encodings so the computed root matches the contract.
Proof construction
Track a leaf's path through the tree, including uneven levels.
Independent verification
Check supplied proofs and reject malformed data without borrowing state from the original tree.
def merkle_results(
leaves, operations
):
# Your implementation goes here
passRun your code to see results.