Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Refactor BMT and BMST to generate proofs without the leaf data as the first entry #14

Open
bvrooman opened this issue Jun 19, 2021 · 3 comments · Fixed by #115
Open
Assignees

Comments

@bvrooman
Copy link
Contributor

bvrooman commented Jun 19, 2021

Currently, the proof sets generated by the Binary Merkle Tree and the Binary Merkle Sum Tree (PR #8) include the leaf for which the proof being generated.

E.g. given the tree:

      N3
     /  \
    /    \
  N1      N2
 /  \    /  \
L1  L2  L3  L4

A proof for leaf L2 will include: L2, L1, and N2. To be compliant with the RFC specification, we need to modify the logic such that proofs are generated without the leaf for which we are generating the proof (i.e. L2).

The currently implemented algorithm imposes a restriction where the leaf at the given proof index must be included in the proof set. This is a corollary of the algorithm, resulting from the way it generates the proof set and maintains order. The algorithm checks the length of the proof set against the height of the tree's head (the most recently joined subtree); This check is logically sound only when the proof set includes the leaf at the proof index when pushing in the tree.

Therefore, we must change the algorithm to calculate proof sets independently of the tree operations (push, join, etc.). This may be best achieved once the algorithm also uses persistent storage.

@Voxelot
Copy link
Member

Voxelot commented Sep 8, 2022

@bvrooman is this still relevant?

@bvrooman
Copy link
Contributor Author

bvrooman commented Sep 12, 2022

Yes, I just checked the code and this issue is still relevant. It will be a very simple fix at this point (now that we use storage backing), so I can tackle this one as part of a tech debt ticket this week.

@bvrooman
Copy link
Contributor Author

Reopened since I reverted #115.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants