← Code LabPython0/50 solved · 0%
Web3 integration · hard

47. Merkle root

Combine leaf hashes into a single root.

Write `merkle_root(leaves)` (list of `bytes`) that hashes each leaf with SHA-256, then repeatedly combines adjacent pairs (duplicating the last node if the level is odd) until one root hash remains, returning it as `bytes`.
Required in your answer: def merkle_roothashlib.sha256