Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merkle tree deserialize correctness check #5

Open
eozturk1 opened this issue Apr 29, 2020 · 7 comments
Open

Merkle tree deserialize correctness check #5

eozturk1 opened this issue Apr 29, 2020 · 7 comments
Labels
question Further information is requested

Comments

@eozturk1
Copy link

Does mt_deserialize check for correctness of the tree, i.e., root is correct given the nodes in the tree?

@wintersteiger
Copy link

No it doesn't. It performs some lower level checks, but it doesn't recompute the hashes. I'm planning to change the serialization so as not to save internal hashes at all (to save space), but as a side-effect it would also recompute the internal hashes. So far, I haven't had time to actually do that though.

@eozturk1
Copy link
Author

Then, does it make sense to rebuild the tree from the leaves instead of serializing/deserializing if deserializing side does not trust the correctness of the tree it receives? Is there a better/cheaper way to ensure correctness in this case?

@wintersteiger
Copy link

I don't think there's anything cheaper because you have to check every single hash computation since you can't invert them. Maybe we could save some extra information during serialization that allows us to cut some paths during deserialization, but I'm not convinced it would pay off.

@eozturk1
Copy link
Author

eozturk1 commented May 6, 2020

I understand, thank you!

For correctness, after deserialization, would it be enough to get the root with mt_get_root and compare the received root to the expected value? From the code, it seems to me mt_get_root calculates the root starting with the leaves and going up. Therefore, the root returned from this function should be the correct root of the deserialized tree.

@prosecco
Copy link

prosecco commented May 6, 2020 via email

@wintersteiger
Copy link

If I remember correctly, deseralization does set the rhs_ok flag to false, so that it triggers a recalculation, but that's only for the right-most hashes on every level of the tree, so I don't think that would be enough.

@prosecco: I don't know the answer, but if you find it, please forward it to me!

@prosecco
Copy link

prosecco commented May 6, 2020 via email

@beurdouche beurdouche added the question Further information is requested label May 8, 2020
@msprotz msprotz transferred this issue from hacl-star/hacl-star Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants