-
Notifications
You must be signed in to change notification settings - Fork 14
Merkle trees misc cleanup and fixes #41
Comments
Things to add:
|
Independent of the prefixing, I'm not sure the annotated and the namespaced merkle tree hashes the correct thing. Looking at how @musalbas defined the hashing in his paper:
OK, and:
Using the notation in the spec, my understanding is that this would result in:
but we have:
Similarly, for the inner nodes, I think the hash of should be something like: I know the spec's version is just a logical abstraction but at least it isn't obvious how both are compatible. |
Ah, while writing this up, I think I see how they can be seen as equivalent. |
The two ways of computing node values aren't identical but should provide the same guarantees maybe? I need to double-check, but if not the annotated Merkle tree abstraction can be changed to reflect the way NMTs are described in the paper. |
I think it's actually closer to the paper as it seem on 1st sight, with the difference that leaf nodes are "namespace-hashed" as Something else I've noted: the spec makes the assumption that each leaf message m, somehow contains the namespace id via: My understanding is that a share implicitly belongs to a namespace but reading through it again, the connection between share and namespace doesn't seem clear enough to me. |
I would suggest to remove the "Annotated Merkle Tree" section as it is not really needed as part of the LL specification and directly introduce the concrete and simpler special case we need, namely the NMT. Unless we foresee any use for the generalisation (the annotated tree), which I currently don't see. |
The min and max values of a node should be outside of the hash of the children, so that a client that wants to verify that they have received all the messages for their namespace should not need to download more data than they need to (specifically, the values of nodes that they aren't interested in). |
https://github.com/lazyledger/lazyledger-specs/blob/master/specs/data_structures.md#sparse-merkle-tree
Better to use a different word than message here (otherwise this might be conflated with the other use of the word messages)
Also, it would help getting a quick understanding, if there was 2-3 simple to follow examples how an smt and its will look like (including trivial edge-case like all-empty tree, only one entry, and one realistic example with a few entries).
The text was updated successfully, but these errors were encountered: