Skip to content

Commit 818dfec

Browse files
committed
Clarify the starting node business
1 parent a970be7 commit 818dfec

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

draft-davidben-tls-merkle-tree-certs.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,15 +1685,15 @@ This can be generalized to arbitrary-sized Merkle Trees. {{fig-merkle-tree-bits-
16851685

16861686
When the size of a Merkle Tree is not a power of two, some levels on the rightmost edge of the tree are skipped. The rightmost edge is the path to the last element. The skipped levels can be seen in its binary representation. Here, the last element is 5, which has binary representation `0b101`. When a bit is set, the corresponding node is a right child. When it is unset, the corresponding node is skipped.
16871687

1688-
In a tree of the next power of two size, the skipped nodes in this path are where there *would* have been a right child, had there been enough elements to construct a right sibling. {{fig-merkle-tree-bits-partial-comparison}} depicts this for a tree of size 6.
1688+
In a tree of the next power of two size, the skipped nodes in this path are where there *would* have been a right child, had there been enough elements to construct one. Without a right child, the hash operation is skipped and a skipped node has the same value as its singular child.{{fig-merkle-tree-bits-partial-comparison}} depicts this for a tree of size 6.
16891689

16901690
~~~aasvg
16911691
+----------------+
16921692
| [0, 6) | level 3
16931693
+----------------+
16941694
/ \
16951695
+--------+ +--------+
1696-
| [0, 4) | | skip | level 2
1696+
| [0, 4) | | [4, 6) | level 2
16971697
+--------+ +--------+
16981698
/ \ / \
16991699
+-----+ +-----+ +-----+ +-----+
@@ -1726,9 +1726,47 @@ Inclusion proofs can also be evaluated by considering these two stages separatel
17261726

17271727
The procedure in {{verifying-a-subtree-consistency-proof}} iteratively builds two hashes, `fr` and `sr`, which are expected to equal `node_hash` and `root_hash`, respectively. Everything hashed into `fr` is also hashed into `sr`, so success demonstrates that `root_hash` contains `node_hash`.
17281728

1729-
A subtree consistency proof for `[start, end)` with the tree of `n` elements is a truncated inclusion proof for element `end - 1`. The proof is truncated until the highest common node between the right edge of `[start, end)` and the right edge of the tree.
1729+
A subtree consistency proof for `[start, end)` and the tree of `n` elements is very similar to an inclusion proof for element `end - 1`. Starting at this element, incorporating the whole inclusion proof should reconstruct `root_hash` and incorporating a subset of the inclusion proof should reconstruct `node_hash`. However, instead of starting at level 0, the proof can be optimized to start at a higher level, specifically the highest ancestor of `end - 1` that is also directly contained in the tree.
17301730

1731-
Steps 3 and 4 skip to this common node. It may be:
1731+
{{fig-truncate-consistency-proof}} depicts a subtree consistency proof between the subtree `[0, 6)` and the Merkle Tree of size 7. The consistency proof begins at level 1, or node `[4, 6)`. Note that, although element 6 at level 0 is in the consistency proof, there is a corresponding skipped node at level 1, the starting level. To demonstrate this, the figure denotes skipped nodes with duplicate values.
1732+
1733+
~~~aasvg
1734+
+----------------+
1735+
| [0, 6) | level 3
1736+
+----------------+
1737+
/ |
1738+
+========+ +--------+
1739+
| [0, 4) | | [4, 6) | level 2
1740+
+========+ +--------+
1741+
/ \ |
1742+
+-----+ +-----+ +~~~~~+
1743+
|[0,2)| |[2,4)| |[4,6)| level 1
1744+
+-----+ +-----+ +~~~~~+
1745+
/ \ / \ / \
1746+
+-+ +-+ +-+ +-+ +-+ +-+
1747+
|0| |1| |2| |3| |4| |5| level 0
1748+
+-+ +-+ +-+ +-+ +-+ +-+
1749+
1750+
1751+
+----------------+
1752+
| [0, 7) | level 3
1753+
+----------------+
1754+
/ \
1755+
+========+ +--------+
1756+
| [0, 4) | | [4, 7) | level 2
1757+
+========+ +--------+
1758+
/ \ / |
1759+
+-----+ +-----+ +~~~~~+ +=+
1760+
|[0,2)| |[2,4)| |[4,6)| |6| level 1
1761+
+-----+ +-----+ +~~~~~+ +=+
1762+
/ \ / \ / \ |
1763+
+-+ +-+ +-+ +-+ +-+ +-+ +-+
1764+
|0| |1| |2| |3| |4| |5| |6| level 0
1765+
+-+ +-+ +-+ +-+ +-+ +-+ +-+
1766+
~~~
1767+
{: #fig-truncate-consistency-proof title="A subtree consistency proof that starts at level 1 instead of level 0"}
1768+
1769+
Steps 3 and 4 skip to this starting node. The starting node may be:
17321770

17331771
* The entire subtree `[start, end)` if `[start, end)` is directly contained in the tree. This will occur if `end` is `n`, or if `[start, end)` is full.
17341772

0 commit comments

Comments
 (0)