This repository has been archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Feat: Add PositionPath
and PositionPathIter
to calculate the path and side positions from root to leaf
#55
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bvrooman
changed the title
Feat: Add
Feat: Add Jan 4, 2022
Position::path_set
to return the path and side positions from root to leafPositionPath
and PositionPathIter
to calculate the path and side positions from root to leaf
bvrooman
force-pushed
the
bvrooman-feat-position-root-leaf-path
branch
from
January 8, 2022 20:22
21d6fbb
to
d132470
Compare
adlerjohn
reviewed
Jan 9, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks fine to me! Will let the Rustaceans make sure the Rust is okay.
Dentosal
previously approved these changes
Jan 9, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nits, but generally LGTM
Dentosal
approved these changes
Jan 10, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issues:
prove
algorithm to generate proofs "top down" #31This PR introduces the
PositionPath
, a concrete representation of the path formed by a start position (root) and an end position (leaf). A path can be generated by callingpath(...)
on a start position, supplying the end position and leaves count as arguments. A path can be iterated upon by callingiter()
, returning aPositionPathIter
. Each iteration yields the next path node, as well as the corresponding side node.The
PositionPathIter
wraps the existingPathIter
, providing additional logic specific to thePosition
struct. The underlying path supplies thePositionPathIter
with the specifiedleaves_count
argument, allowing the iterator to handle imbalanced trees (Merkle Mountain Ranges).This PR also modifies the existing
common::Node
trait to require aheight
member method on implementing structs, so that thePathIter
can identify the correct starting index (distance from the MSB) when reading the next "left or right" instruction bit. This is necessary for dense (non-sparse) trees that do not fill their leaf index keys.