-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support inner nodes proving/verification #256
Comments
@staheri14 proposed the following:
Which is apparently the direction we will be following. This is a draft of how this implementation would look like: https://github.com/celestiaorg/nmt/pull/258/files Currently, even if the provided coordinates are not consecutive, we will create a consecutive range of them and prove the whole thing. For example, if the coordinates cover the leaves Is this a valid compromise, or we want the full feature to be supported, aka, ranges that are not adjacent? |
sgtm! |
The question has been raised as to how we can calculate the range of each subtree root. Below is the explanation for that. Assumptions:
Algorithms:
Following the proposal I initially made (available in the GH description), the range of each subtree root can be calculated as follows (below we are relying on the fact the subtree roots are calculated using the Mountain Merkle Range algorithm):
The rest would be according to the initial proposal. |
@staheri14 Thanks a lot for your explanation. The algorithm looks good 👍 The thing is, for the share commitment subtree roots, we assume the tree size to be a power of 2. But in general, the nmt can be any size. Can this algorithm be tweaked to support any tree size? Otherwise, we can first ship your algorithm in a method like: |
@rach-id Update: missed this part of your comment |
Note that in my algorithm, there is no assumption about the number of shares that the subtree roots represent. Hope that clarifies the confusion. |
The NMT implementation follows the RFC 6962 standard. So, it supports any tree size. That's why I asked aboht ir. For the general use case, it's gonna allow users to verify inner nodes in NMT proofs. I think it would be ideal if we kept the NMT implementation general, and not Celestia specific. |
@staheri14 Concerning the algorithm, I am applying it here:
Am I missing something in the application of this algorithm? |
@rach-id We can approach this from a different angle with an entirely new and much simpler solution. While the underlying logic is similar, instead of calculating the ranges of the subtree roots, we select subtree roots as we traverse the tree from top to bottom. As we traverse the tree from top to bottom (as implemented in this function: computeRoot), we keep track of the range of leaves that the
|
How would we select them? You mean we should use coordinates? Like in |
No, without coordinates, in your example, the subtree roots you pass to the function are I0, I1, and I2 (instead of leafhashes), with this exact order. |
I see, but how we know that the subtree root's range is |
The reason can be found in the two statements within my previous comment
|
If I want to put it differently, I'd say the subtree roots are ordered based on the range of leaf indices they cover. And that is why you can pick them up as you traverse the tree inorder (left then right). |
Are all the subtree roots at the same height? Asking as in the previous example in #256 (comment) it was not the case? |
These are all possible cases for the subtree roots |
As per sync discussions with Sanaz, we have the following two propositions:
Now that I am thinking about it, we only need this to be on EVM chains. I am not aware of a place where we would verify the inclusion of subtree roots using a proof without having the actual data.
Decision: Go with the Celestia specific approach. For reference, a draft of the general purpose approach can be found in this PR #258 |
Here is how we can accomodate the subtree root threshold. As we traverse the tree from top to bottom (as implemented in this function: computeRoot), we keep track of the range of leaves that the
cc: @rach-id |
This is how I did it: #260, is this what you're referring to or I am missing something? |
As part of celestiaorg/celestia-node#3361, where we will need to support proving and verifying share commitment subtree roots, the NMT needs to support proving and verifying inner nodes.
The text was updated successfully, but these errors were encountered: