verifier_4.py 293 B

123456
  1. def hash_merkle_root(self, merkle_s, target_hash, pos):
  2. h = hash_decode(target_hash)
  3. for i in range(len(merkle_s)):
  4. item = merkle_s[i]
  5. h = Hash( hash_decode(item) + h ) if ((pos >> i) & 1) else Hash( h + hash_decode(item) )
  6. return hash_encode(h)