Closed ggutoski closed 1 month ago
I tend to keep it in the original form. But this comment is valuable:
If the leaf value is large then the size of the merkle proof is unnecessarily large.
Forgot to mention: currently MerkleTree::verify
takes a redundant arg pos
. The current implementation merely checks pos
against one of its copies inside MerkleProof
:
Instead verify
args should include both pos
and elem
or neither of these items. Seems strange to take only one but not the other. Naturally, my suggestion is to include both and then remove them from MerkleProof
.
My opinion has changed. We should make these changes along with #642
We will go with two kind of Merkle proof: with and without leaf.
This issue is an opinionated suggestion. Others may disagree.
MerkleProof
struct contains:These items should not be in the merkle proof. Instead,
MerkleTree::verify
should take them as separate args. If the leaf value is large then the size of the merkle proof is unnecessarily large.First copy of index position is
pos
field in `MerkleProof struct: https://github.com/EspressoSystems/jellyfish/blob/92714a4cc509fac07b8e8fc321fc0271c5dbe6b6/merkle_tree/src/internal.rs#L139-L150Digging into
MerklePath
we seehttps://github.com/EspressoSystems/jellyfish/blob/92714a4cc509fac07b8e8fc321fc0271c5dbe6b6/merkle_tree/src/internal.rs#L84
where
MerkleNode
is an enumhttps://github.com/EspressoSystems/jellyfish/blob/92714a4cc509fac07b8e8fc321fc0271c5dbe6b6/merkle_tree/src/internal.rs#L25
with
Leaf
varianthttps://github.com/EspressoSystems/jellyfish/blob/92714a4cc509fac07b8e8fc321fc0271c5dbe6b6/merkle_tree/src/internal.rs#L37-L47
where we find a second copy of
pos
and the leaf valueelem
.If, as I suggest, we remove these occurrences of
pos
thenMerkleProof
becomes just a wrapper forMerklePath
. In that case we should eliminate the wrapper and just useMerklePath
.I suggest that
MerklePath
be an opaque struct. No need to expose the fact that it's aVec<MerkleNode>
.