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

Fix merkle root for odd number of elements #8

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

markspanbroek
Copy link
Member

There was an off-by-one error in the calculation of merkle roots of odd elements.

@bkomuves
Copy link
Contributor

bkomuves commented Nov 9, 2023

good catch!

that's an example of why I like to have independent implementations, ideally in at least two different languages (one "reference" implementation being just very straightforward code, disregarding efficiency), and comparing the results, that usually catches such mistakes.

Btw halfn = (m+1) div 2 would probably also fix the bug.

@markspanbroek markspanbroek merged commit 3cbd9a3 into main Nov 13, 2023
2 checks passed
@markspanbroek markspanbroek deleted the fix-merkleroot-odd-elements branch November 13, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants