diff --git a/zip-0221.rst b/zip-0221.rst index 72f53f7d..89ba16da 100644 --- a/zip-0221.rst +++ b/zip-0221.rst @@ -452,7 +452,7 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc peaks: List[ZcashMMRNode] = [] # Get number of leaves. - leaves = latest_height - earliest_height + 1 + leaves = latest_height - (earliest_height - 1) # Check if the number of leaves is a power of two. if (leaves & (leaves - 1)) == 0: @@ -488,8 +488,8 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc # This will produce a list of peaks in reverse order current = leaf for peak in peaks[::-1]: - current_leaves = current.latest_height - current.earliest_height + 1 - peak_leaves = peak.latest_height - peak.earliest_height + 1 + current_leaves = current.latest_height - (current.earliest_height - 1) + peak_leaves = peak.latest_height - (peak.earliest_height - 1) if current_leaves == peak_leaves: current = make_parent(peak, current) @@ -513,7 +513,7 @@ in the right subtree of the MMR root. Return the new tree root ''' - n_leaves = root.latest_height - root.earliest_height + 1 + n_leaves = root.latest_height - (root.earliest_height - 1) # if there were an odd number of leaves, # simply replace root with left_child if n_leaves & 1: @@ -590,7 +590,7 @@ In leaf nodes, some information is repeated. We chose to do this so that leaf no be treated identically to internal and root nodes for all algorithms and (de)serializers. Leaf nodes are easily identifiable, as they will show proof of work in the ``hashSubtreeCommitment`` field, and their block range (calculated as -``nLatestHeight - nEarliestHeight + 1``) will be precisely 1. For the same reason, we +``nLatestHeight - (nEarliestHeight - 1)``) will be precisely 1. For the same reason, we change the semantics of ``hashSubtreeCommitment`` in leaf nodes to commit Personalized BLAKE2b-256 was selected to match existing Zcash conventions. Adding the