Open naterush opened 6 years ago
You can also choose to pass in the data/tx as a separate thing from the proof, but this doesn't seem super necessary IMO (just as much duplication, which is 0).
An example of this interface and implementation, in case it's helpful: https://github.com/Tierion/pymerkletools/blob/master/merkletools/__init__.py#L104
Also, making this change also probably necessitates adding a test to make sure that the verify_proof function will not just return True for any data it is passed ;)
All of these are great suggestions! A lot of the decisions were to have it make sense to students but your changes would work better.
I'll get cracking on this 👍
Currently, the
verify_proof
function takes in a tx and a merkle_proof and returns a recovered root hash. Usually, averify_proof
function for a Merkle tree should take the expected root hash and return a boolean: recovered root hash == the input root hash.First, this makes it so there is no longer duplicated data in the input to the verify function (as the tx must be in the proof already), and also the interface much more intuitive (I would totally write a line of code like
if not verify_proof(...)
, which could lead to issues).