Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import warnings
  2. warnings.simplefilter("ignore", UserWarning)
  3.  
  4. import merkletools
  5.  
  6. mt = merkletools.MerkleTools(hash_type="sha256")
  7.  
  8. #TBD Add 6 transaction "leaves" to the tree: ["transaction1","transaction2","transaction3"], ["transaction4", "transaction5","transaction6"]
  9. mt.add_leaf(["transaction1","transaction2","transaction3"], True)
  10. mt.add_leaf(["transaction4", "transaction5","transaction6"], True)
  11.  
  12. #TBD Make the tree
  13. mt.make_tree()
  14.  
  15. #TBD Print Merkle Root
  16. print("root:", mt.get_merkle_root() )
  17.  
  18. #TBD Get the proof for transaction2
  19. print(mt.get_proof(1))
  20.  
  21. #TBD Validate the proof. How many transactions were required to validate proof?
  22. print(mt.validate_proof(mt.get_proof(1), mt.get_leaf(1), mt.get_merkle_root()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement