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

Feat: covert the merkle path from celestia to nmt_rs. #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ludete
Copy link

@ludete ludete commented Nov 7, 2024

No description provided.

…ted by the nmt_rs library.

tests: add more uint tests and import solidity contract tests covert the feat
@ludete
Copy link
Author

ludete commented Nov 7, 2024

Hi, while translating the Merkle tree unit tests from the Celestia Solidity contract to nmt_rs, I discovered that the two libraries use different methods for generating Merkle paths.

In Celestia, the Merkle path generation starts from the leaf node and goes up to the root, while in the nmt_rs library, the Merkle path is generated starting from the root node and going down to the leaf. These two approaches are completely opposite, which causes a failure when directly using the nmt_rs library to verify Merkle paths generated by Celestia. Therefore, I added a method to convert the Celestia-generated Merkle path into the format used by nmt_rs and added extensive unit tests to cover this functionality.

celesita merkle path : https://github.com/celestiaorg/celestia-core/blob/v0.34.x-celestia/crypto/merkle/proof.go#L213
nmt merkle path: https://github.com/Sovereign-Labs/nmt-rs/blob/master/src/simple_merkle/tree.rs#L256
solidity contract tests: https://github.com/celestiaorg/blobstream-contracts/blob/dc02821/src/lib/tree/binary/test/TreeHasher.t.sol

This work is from bitlayer.org.

@ludete
Copy link
Author

ludete commented Nov 7, 2024

image

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.

2 participants