All problems
Merkle Proof Path
Problem
Return the sibling hashes needed to verify leaf `index` of a four-leaf Merkle tree, using the pairing hash h(a, b) = (a * 1000003 + b) mod 2^32. The list has two entries: the sibling leaf and the sibling subtree hash, from the leaf level upward.
Hint
A proof needs one hash per level of the tree.
Test cases
case 1
in: [[1,2,3,4],0]
expected: [2,3000013]
case 2
in: [[1,2,3,4],1]
expected: [1,3000013]
case 3
in: [[1,2,3,4],2]
expected: [1000005,4]
case 4
in: [[1,2,3,4],3]
expected: [1000005,3]
Starter codePython
def merkle_proof(leaves, index):
# Your code here
pass4 test cases · run your code against them in the editor