Fix rst rendering errors.

This commit is contained in:
Kris Nuttycombe 2021-01-26 15:06:30 -07:00
parent 7558c6995d
commit e3729e8e7c
9 changed files with 618 additions and 134 deletions

View File

@ -100,8 +100,8 @@ Index of ZIPs
<tr> <td>222</td> <td class="left"><a href="zip-0222.rst">Transparent Zcash Extensions</a></td> <td>Draft</td>
<tr> <td><span class="reserved">224</span></td> <td class="left"><a class="reserved" href="zip-0224.rst">Orchard Shielded Protocol</a></td> <td>Reserved</td>
<tr> <td>243</td> <td class="left"><a href="zip-0243.rst">Transaction Signature Validation for Sapling</a></td> <td>Final</td>
<tr> <td><span class="reserved">244</span></td> <td class="left"><a class="reserved" href="zip-0244.rst">Transaction Signature Validation for Transparent Zcash Extensions</a></td> <td>Reserved</td>
<tr> <td><span class="reserved">245</span></td> <td class="left"><a class="reserved" href="zip-0245.rst">Transaction Non-Malleability</a></td> <td>Reserved</td>
<tr> <td>244</td> <td class="left"><a href="zip-0244.rst">Transaction Identifier Non-Malleability</a></td> <td>Draft</td>
<tr> <td><span class="reserved">245</span></td> <td class="left"><a class="reserved" href="zip-0245.rst">Transaction Identifier Digests & Signature Validation for Transparent Zcash Extensions</a></td> <td>Reserved</td>
<tr> <td>250</td> <td class="left"><a href="zip-0250.rst">Deployment of the Heartwood Network Upgrade</a></td> <td>Final</td>
<tr> <td>251</td> <td class="left"><a href="zip-0251.rst">Deployment of the Canopy Network Upgrade</a></td> <td>Implemented (zcashd)</td>
<tr> <td><span class="reserved">252</span></td> <td class="left"><a class="reserved" href="zip-0252.rst">Deployment of the NU5 Network Upgrade</a></td> <td>Reserved</td>

View File

@ -73,8 +73,8 @@
<tr> <td>222</td> <td class="left"><a href="zip-0222">Transparent Zcash Extensions</a></td> <td>Draft</td>
<tr> <td><span class="reserved">224</span></td> <td class="left"><a class="reserved" href="zip-0224">Orchard Shielded Protocol</a></td> <td>Reserved</td>
<tr> <td>243</td> <td class="left"><a href="zip-0243">Transaction Signature Validation for Sapling</a></td> <td>Final</td>
<tr> <td><span class="reserved">244</span></td> <td class="left"><a class="reserved" href="zip-0244">Transaction Signature Validation for Transparent Zcash Extensions</a></td> <td>Reserved</td>
<tr> <td><span class="reserved">245</span></td> <td class="left"><a class="reserved" href="zip-0245">Transaction Non-Malleability</a></td> <td>Reserved</td>
<tr> <td>244</td> <td class="left"><a href="zip-0244">Transaction Identifier Non-Malleability</a></td> <td>Draft</td>
<tr> <td><span class="reserved">245</span></td> <td class="left"><a class="reserved" href="zip-0245">Transaction Identifier Digests & Signature Validation for Transparent Zcash Extensions</a></td> <td>Reserved</td>
<tr> <td>250</td> <td class="left"><a href="zip-0250">Deployment of the Heartwood Network Upgrade</a></td> <td>Final</td>
<tr> <td>251</td> <td class="left"><a href="zip-0251">Deployment of the Canopy Network Upgrade</a></td> <td>Implemented (zcashd)</td>
<tr> <td><span class="reserved">252</span></td> <td class="left"><a class="reserved" href="zip-0252">Deployment of the NU5 Network Upgrade</a></td> <td>Reserved</td>

View File

@ -144,7 +144,7 @@ License: MIT</pre>
<span class="n">uint256</span> <span class="n">hashJoinSplits</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="n">SIGHASH_ANYONECANPAY</span><span class="p">))</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_PREVOUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_PREVOUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">prevout</span><span class="p">;</span>
<span class="p">}</span>
@ -152,7 +152,7 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="n">SIGHASH_ANYONECANPAY</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_NONE</span><span class="p">)</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SEQUENCE_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SEQUENCE_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">nSequence</span><span class="p">;</span>
<span class="p">}</span>
@ -160,19 +160,19 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">((</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_NONE</span><span class="p">)</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">[</span><span class="n">n</span><span class="p">];</span>
<span class="p">}</span>
<span class="n">hashOutputs</span> <span class="o">=</span> <span class="n">ss</span><span class="p">.</span><span class="n">GetHash</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">((</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">==</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="n">nIn</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">.</span><span class="n">size</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">[</span><span class="n">nIn</span><span class="p">];</span>
<span class="n">hashOutputs</span> <span class="o">=</span> <span class="n">ss</span><span class="p">.</span><span class="n">GetHash</span><span class="p">();</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">.</span><span class="n">empty</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_JOINSPLITS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_JOINSPLITS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">[</span><span class="n">n</span><span class="p">];</span>
<span class="p">}</span>

View File

@ -335,25 +335,25 @@ License: MIT</pre>
</section>
<section id="tree-nodes-and-hashing-pseudocode"><h3><span class="section-heading">Tree nodes and hashing (pseudocode)</span><span class="section-anchor"> <a rel="bookmark" href="#tree-nodes-and-hashing-pseudocode"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<pre data-language="python"><span class="k">def</span> <span class="nf">H</span><span class="p">(</span><span class="n">msg</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">consensusBranchId</span><span class="p">:</span> <span class="nb">bytes</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bytes</span><span class="p">:</span>
<span class="k">return</span> <span class="n">blake2b256</span><span class="p">(</span><span class="n">msg</span><span class="p">,</span> <span class="n">personalization</span><span class="o">=</span><span class="n">b</span><span class="s">&#39;ZcashHistory&#39;</span> <span class="o">+</span> <span class="n">consensusBranchId</span><span class="p">)</span>
<span class="k">return</span> <span class="n">blake2b256</span><span class="p">(</span><span class="n">msg</span><span class="p">,</span> <span class="n">personalization</span><span class="o">=</span><span class="sa">b</span><span class="s1">&#39;ZcashHistory&#39;</span> <span class="o">+</span> <span class="n">consensusBranchId</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">ZcashMMRNode</span><span class="p">():</span>
<span class="c"># leaf nodes have no children</span>
<span class="c1"># leaf nodes have no children</span>
<span class="n">left_child</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]</span>
<span class="n">right_child</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]</span>
<span class="c"># commitments</span>
<span class="c1"># commitments</span>
<span class="n">hashSubtreeCommitment</span><span class="p">:</span> <span class="nb">bytes</span>
<span class="n">nEarliestTimestamp</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">nLatestTimestamp</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">nEarliestTargetBits</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">nLatestTargetBits</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">hashEarliestSaplingRoot</span><span class="p">:</span> <span class="nb">bytes</span> <span class="c"># left child&#39;s sapling root</span>
<span class="n">hashLatestSaplingRoot</span><span class="p">:</span> <span class="nb">bytes</span> <span class="c"># right child&#39;s sapling root</span>
<span class="n">nSubTreeTotalWork</span><span class="p">:</span> <span class="nb">int</span> <span class="c"># total difficulty accumulated within each subtree</span>
<span class="n">hashEarliestSaplingRoot</span><span class="p">:</span> <span class="nb">bytes</span> <span class="c1"># left child&#39;s sapling root</span>
<span class="n">hashLatestSaplingRoot</span><span class="p">:</span> <span class="nb">bytes</span> <span class="c1"># right child&#39;s sapling root</span>
<span class="n">nSubTreeTotalWork</span><span class="p">:</span> <span class="nb">int</span> <span class="c1"># total difficulty accumulated within each subtree</span>
<span class="n">nEarliestHeight</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">nLatestHeight</span><span class="p">:</span> <span class="nb">int</span>
<span class="n">nSaplingTxCount</span><span class="p">:</span> <span class="nb">int</span> <span class="c"># number of Sapling transactions in block</span>
<span class="n">nSaplingTxCount</span><span class="p">:</span> <span class="nb">int</span> <span class="c1"># number of Sapling transactions in block</span>
<span class="n">consensusBranchId</span><span class="p">:</span> <span class="nb">bytes</span>
@ -361,8 +361,8 @@ License: MIT</pre>
<span class="k">def</span> <span class="nf">from_block</span><span class="p">(</span><span class="n">Z</span><span class="p">,</span> <span class="n">block</span><span class="p">:</span> <span class="n">ZcashBlock</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">ZcashMMRNode</span><span class="p">:</span>
<span class="sd">&#39;&#39;&#39;Create a leaf node from a block&#39;&#39;&#39;</span>
<span class="k">return</span> <span class="n">Z</span><span class="p">(</span>
<span class="n">left_child</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">right_child</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">left_child</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">right_child</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">hashSubtreeCommitment</span><span class="o">=</span><span class="n">block</span><span class="o">.</span><span class="n">header_hash</span><span class="p">,</span>
<span class="n">nEarliestTimestamp</span><span class="o">=</span><span class="n">block</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span>
<span class="n">nLatestTimestamp</span><span class="o">=</span><span class="n">block</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span>
@ -425,18 +425,18 @@ License: MIT</pre>
<pre data-language="python"><span class="k">def</span> <span class="nf">get_peaks</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">ZcashMMRNode</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]:</span>
<span class="n">peaks</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c"># Get number of leaves.</span>
<span class="c1"># Get number of leaves.</span>
<span class="n">leaves</span> <span class="o">=</span> <span class="n">latest_height</span> <span class="o">-</span> <span class="p">(</span><span class="n">earliest_height</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">assert</span><span class="p">(</span><span class="n">leaves</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span>
<span class="c"># Check if the number of leaves is a power of two.</span>
<span class="c1"># Check if the number of leaves is a power of two.</span>
<span class="k">if</span> <span class="p">(</span><span class="n">leaves</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">leaves</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="c"># Tree is full, hence a single peak. This also covers the</span>
<span class="c"># case of a single isolated leaf.</span>
<span class="c1"># Tree is full, hence a single peak. This also covers the</span>
<span class="c1"># case of a single isolated leaf.</span>
<span class="n">peaks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c"># If the number of leaves is not a power of two, then this</span>
<span class="c"># node must be internal, and cannot be a peak.</span>
<span class="c1"># If the number of leaves is not a power of two, then this</span>
<span class="c1"># node must be internal, and cannot be a peak.</span>
<span class="n">peaks</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">get_peaks</span><span class="p">(</span><span class="n">left_child</span><span class="p">))</span>
<span class="n">peaks</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">get_peaks</span><span class="p">(</span><span class="n">right_child</span><span class="p">))</span>
@ -455,12 +455,12 @@ License: MIT</pre>
<span class="k">def</span> <span class="nf">append</span><span class="p">(</span><span class="n">root</span><span class="p">:</span> <span class="n">ZcashMMRNode</span><span class="p">,</span> <span class="n">leaf</span><span class="p">:</span> <span class="n">ZcashMMRNode</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">ZcashMMRNode</span><span class="p">:</span>
<span class="sd">&#39;&#39;&#39;Append a leaf to an existing tree, return the new tree root&#39;&#39;&#39;</span>
<span class="c"># recursively find a list of peaks in the current tree</span>
<span class="c1"># recursively find a list of peaks in the current tree</span>
<span class="n">peaks</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]</span> <span class="o">=</span> <span class="n">get_peaks</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
<span class="n">merged</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">ZcashMMRNode</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c"># Merge peaks from right to left.</span>
<span class="c"># This will produce a list of peaks in reverse order</span>
<span class="c1"># Merge peaks from right to left.</span>
<span class="c1"># This will produce a list of peaks in reverse order</span>
<span class="n">current</span> <span class="o">=</span> <span class="n">leaf</span>
<span class="k">for</span> <span class="n">peak</span> <span class="ow">in</span> <span class="n">peaks</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
<span class="n">current_leaves</span> <span class="o">=</span> <span class="n">current</span><span class="o">.</span><span class="n">latest_height</span> <span class="o">-</span> <span class="p">(</span><span class="n">current</span><span class="o">.</span><span class="n">earliest_height</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
@ -473,7 +473,7 @@ License: MIT</pre>
<span class="n">current</span> <span class="o">=</span> <span class="n">peak</span>
<span class="n">merged</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">current</span><span class="p">)</span>
<span class="c"># finally, bag the merged peaks</span>
<span class="c1"># finally, bag the merged peaks</span>
<span class="k">return</span> <span class="n">bag_peaks</span><span class="p">(</span><span class="n">merged</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span></pre>
<p>In case of a block reorg, we have to delete the latest (i.e. rightmost) MMR leaf nodes, up to the reorg length. This operation is
<span class="math">\(O(\log(k))\)</span>
@ -487,19 +487,19 @@ License: MIT</pre>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">n_leaves</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">latest_height</span> <span class="o">-</span> <span class="p">(</span><span class="n">root</span><span class="o">.</span><span class="n">earliest_height</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="c"># if there were an odd number of leaves,</span>
<span class="c"># simply replace root with left_child</span>
<span class="c1"># if there were an odd number of leaves,</span>
<span class="c1"># simply replace root with left_child</span>
<span class="k">if</span> <span class="n">n_leaves</span> <span class="o">&amp;</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">return</span> <span class="n">root</span><span class="o">.</span><span class="n">left_child</span>
<span class="c"># otherwise, we need to re-bag the peaks.</span>
<span class="c1"># otherwise, we need to re-bag the peaks.</span>
<span class="k">else</span><span class="p">:</span>
<span class="c"># first peak</span>
<span class="c1"># first peak</span>
<span class="n">peaks</span> <span class="o">=</span> <span class="p">[</span><span class="n">root</span><span class="o">.</span><span class="n">left_child</span><span class="p">]</span>
<span class="c"># we do this traversing the right (unbalanced) side of the tree</span>
<span class="c"># we keep the left side (balanced subtree or leaf) of each subtree</span>
<span class="c"># until we reach a leaf</span>
<span class="c1"># we do this traversing the right (unbalanced) side of the tree</span>
<span class="c1"># we keep the left side (balanced subtree or leaf) of each subtree</span>
<span class="c1"># until we reach a leaf</span>
<span class="n">subtree_root</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">right_child</span>
<span class="k">while</span> <span class="n">subtree_root</span><span class="o">.</span><span class="n">left_child</span><span class="p">:</span>
<span class="n">peaks</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="n">subtree_root</span><span class="o">.</span><span class="n">left_child</span><span class="p">)</span>

View File

@ -119,7 +119,7 @@ License: MIT</pre>
<span class="n">uint256</span> <span class="n">hashShieldedOutputs</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="n">SIGHASH_ANYONECANPAY</span><span class="p">))</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_PREVOUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_PREVOUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">prevout</span><span class="p">;</span>
<span class="p">}</span>
@ -127,7 +127,7 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="n">SIGHASH_ANYONECANPAY</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_NONE</span><span class="p">)</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SEQUENCE_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SEQUENCE_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vin</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">nSequence</span><span class="p">;</span>
<span class="p">}</span>
@ -135,19 +135,19 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">((</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">!=</span> <span class="n">SIGHASH_NONE</span><span class="p">)</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">[</span><span class="n">n</span><span class="p">];</span>
<span class="p">}</span>
<span class="n">hashOutputs</span> <span class="o">=</span> <span class="n">ss</span><span class="p">.</span><span class="n">GetHash</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">((</span><span class="n">nHashType</span> <span class="o">&amp;</span> <span class="mh">0x1f</span><span class="p">)</span> <span class="o">==</span> <span class="n">SIGHASH_SINGLE</span> <span class="o">&amp;&amp;</span> <span class="n">nIn</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">.</span><span class="n">size</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vout</span><span class="p">[</span><span class="n">nIn</span><span class="p">];</span>
<span class="n">hashOutputs</span> <span class="o">=</span> <span class="n">ss</span><span class="p">.</span><span class="n">GetHash</span><span class="p">();</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">.</span><span class="n">empty</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_JOINSPLITS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_JOINSPLITS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vjoinsplit</span><span class="p">[</span><span class="n">n</span><span class="p">];</span>
<span class="p">}</span>
@ -156,7 +156,7 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedSpend</span><span class="p">.</span><span class="n">empty</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SHIELDED_SPENDS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SHIELDED_SPENDS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedSpend</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedSpend</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">cv</span><span class="p">;</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedSpend</span><span class="p">[</span><span class="n">n</span><span class="p">].</span><span class="n">anchor</span><span class="p">;</span>
@ -168,7 +168,7 @@ License: MIT</pre>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedOutput</span><span class="p">.</span><span class="n">empty</span><span class="p">())</span> <span class="p">{</span>
<span class="n">CBLAKE2bWriter</span> <span class="n">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SHIELDED_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="n">CBLAKE2bWriter</span> <span class="nf">ss</span><span class="p">(</span><span class="n">SER_GETHASH</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ZCASH_SHIELDED_OUTPUTS_HASH_PERSONALIZATION</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedOutput</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">n</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">txTo</span><span class="p">.</span><span class="n">vShieldedOutput</span><span class="p">[</span><span class="n">n</span><span class="p">];</span>
<span class="p">}</span>

View File

@ -1,17 +1,371 @@
<!DOCTYPE html>
<html>
<head>
<title>ZIP 244: Transaction Signature Validation for Transparent Zcash Extensions</title>
<title>ZIP 244: Transaction Identifier Non-Malleability</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="css/style.css"></head>
<body>
<section>
<pre>ZIP: 244
Title: Transaction Signature Validation for Transparent Zcash Extensions
Title: Transaction Identifier Non-Malleability
Owners: Kris Nuttycombe &lt;kris@electriccoin.co&gt;
Status: Reserved
Daira Hopwood &lt;daira@electriccoin.co&gt;
Status: Draft
Category: Consensus
Discussions-To: &lt;<a href="https://github.com/zcash/zips/issues/384">https://github.com/zcash/zips/issues/384</a>&gt;</pre>
Created: 2021-01-06
License: MIT
Discussions-To: &lt;<a href="https://github.com/zcash/zips/issues/411">https://github.com/zcash/zips/issues/411</a>&gt;</pre>
<section id="terminology"><h2><span class="section-heading">Terminology</span><span class="section-anchor"> <a rel="bookmark" href="#terminology"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>The key words "MUST" and "MUST NOT" in this document are to be interpreted as described in RFC 2119. <a id="id1" class="footnote_reference" href="#rfc2119">1</a></p>
<p>The terms "consensus branch", "epoch", and "network upgrade" in this document are to be interpreted as described in ZIP 200. <a id="id2" class="footnote_reference" href="#zip-0200">2</a></p>
</section>
<section id="abstract"><h2><span class="section-heading">Abstract</span><span class="section-anchor"> <a rel="bookmark" href="#abstract"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>This proposal defines a new transaction digest algorithm for the &lt;TBD&gt; network upgrade onward, in order to introduce non-malleable transaction identifiers that commit to all transaction data except for attestations to transaction validity.</p>
<p>This proposal also defines a new transaction digest algorithm for signature validation, which shares all available structure produced during the construction of transaction identifiers, in order to minimize redundant data hashing in validation.</p>
<p>This proposal also defines a new name and semantics for the <code>hashLightClientRoot</code> field of the block header, to enable additional commitments to be represented in this hash and to provide a mechanism for future extensibility of the set of commitments represented.</p>
</section>
<section id="motivation"><h2><span class="section-heading">Motivation</span><span class="section-anchor"> <a rel="bookmark" href="#motivation"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>In all cases, but particularly in order to support the use of transactions in higher-level protocols, any modification of the transaction that has not been explicitly permitted (such as via anyone-can-spend inputs) should invalidate attestations to spend authority or to the included outputs. Following the activation of this proposed change, transaction identifiers will be stable irrespective of any possible malleation of "witness data" such as proofs and transaction signatures.</p>
</section>
<section id="requirements"><h2><span class="section-heading">Requirements</span><span class="section-anchor"> <a rel="bookmark" href="#requirements"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<ul>
<li>Continue to support existing functionality of the protocol (multisig, signing modes for transparent inputs).</li>
<li>Allow the use of transaction ids, and pairs of the form (transaction id, output index) as stable identifiers.</li>
<li>A sender must be able to recognize their own transaction, even given allowed forms of malleability such as recomputation of transaction signatures.</li>
<li>In the case of transparent inputs, it should be possible to create a transaction (B) that spends the outputs from a previous transaction (A) even before (A) has been mined. This should also be possible in the case that the creator of (B) does not wait for confirmations of (A). That is, (B) should remain valid so long as any variant of (A) is eventually mined.</li>
<li>It should not be possible for an attacker to malleate a transaction in a fashion that would result in the transaction being interpreted as a double-spend.</li>
<li>It should be possible in the future to upgrade the protocol in such a fashion that only non-malleable transactions are accepted.</li>
<li>It should be possible to use the transaction id unmodified as the value that is used to produce a signature hash in the case that the transaction contains no transparent inputs, or in the case that only the <code>SIGHASH_ALL</code> flag is used.</li>
</ul>
</section>
<section id="non-requirements"><h2><span class="section-heading">Non-requirements</span><span class="section-anchor"> <a rel="bookmark" href="#non-requirements"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>In order to support backwards-compatibility with parts of the ecosystem that have not yet upgraded to the non-malleable transaction format, it is not an initial requirement that all transactions be non-malleable.</p>
</section>
<section id="specification"><h2><span class="section-heading">Specification</span><span class="section-anchor"> <a rel="bookmark" href="#specification"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<section id="digests"><h3><span class="section-heading">Digests</span><span class="section-anchor"> <a rel="bookmark" href="#digests"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>All digests are personalized BLAKE2b-256 hashes. In cases where no elements are available for hashing (for example, if there are no transparent inputs) the resulting hash will be over just the personalization string, providing domain separation even for empty data fields.</p>
<section id="txid-digest"><h4><span class="section-heading">TxId Digest</span><span class="section-anchor"> <a rel="bookmark" href="#txid-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>A new transaction digest algorithm is defined that constructs the identifier for a transaction from a tree of hashes. Each branch of the tree of hashes will correspond to a specific subset of transaction data. The overall structure of the hash is as follows; each name referenced here will be described in detail below:</p>
<pre>txid_digest
├── header_digest
├── transparent_digest
│   ├── prevouts_digest
│   ├── sequence_digest
│   └── outputs_digest
├── sprout_digest
└── sapling_digest
   ├── sapling_spends_digest
│   ├── sapling_spends_compact_digest
│   └── sapling_spends_noncompact_digest
├── sapling_outputs_digest
│   ├── sapling_outputs_compact_digest
│   ├── sapling_outputs_memos_digest
│   └── sapling_outputs_noncompact_digest
  └── valueBalance</pre>
<p>Each node written as <code>snake_case</code> in this tree is a BLAKE2b-256 hash of its children, initialized with a personalization string specific to that branch of the tree. Nodes that are not themselves digests are written in <code>camelCase</code>. In the specification below, nodes of the tree are presented in depth-first order.</p>
<section id="id3"><h5><span class="section-heading"><code>txid_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#id3"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* T.1: ``header_digest`` (32-byte hash output)
* T.2: ``transparent_digest`` (32-byte hash output)
* T.3: ``sprout_digest (32-byte hash output)
* T.4: ``sapling_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZcashTxHash_" || CONSENSUS_BRANCH_ID</pre>
<p>As in ZIP 143 <a id="id4" class="footnote_reference" href="#zip-0143">5</a>, CONSENSUS_BRANCH_ID is the 4-byte little-endian encoding of the consensus branch ID for the epoch of the block containing the transaction. Domain separation of the transaction id hash across parallel consensus branches provides replay protection: transactions targeted for one consensus branch will not have the same transaction identifier on other consensus branches.</p>
<section id="t-1-header-digest"><h6><span class="section-heading">T.1: <code>header_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-1-header-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* T.1a. ``version`` (4-byte little-endian version identifier including overwinter flag)
* T.1b. ``version_group_id`` (4-byte little-endian version group identifier)
* T.1c. ``consensus_branch_id`` (4-byte little-endian consensus branch id)
* T.1d. ``lock_time`` (4-byte little-endian nLockTime value)
* T.1e. ``expiry_height`` (4-byte little-endian block height)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdHeadersHash"</pre>
</section>
<section id="t-2-transparent-digest"><h6><span class="section-heading">T.2: <code>transparent_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-2-transparent-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* T.2a. ``prevouts_digest`` (32-byte hash)
* T.2b. ``sequence_digest`` (32-byte hash)
* T.2c. ``outputs_digest`` (32-byte hash)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdTranspaHash"</pre>
<section id="t-2a-prevouts-digest"><h7><span class="section-heading">T.2a: <code>prevouts_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-2a-prevouts-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>A BLAKE2b-256 hash of the field encoding of all <code>outpoint</code> field values of transparent inputs to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdPrevoutHash"</pre>
</section>
<section id="t-2b-sequence-digest"><h7><span class="section-heading">T.2b: <code>sequence_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-2b-sequence-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>A BLAKE2b-256 hash of the 32-bit little-endian representation of all <code>nSequence</code> field values of transparent inputs to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSequencHash"</pre>
</section>
<section id="t-2c-outputs-digest"><h7><span class="section-heading">T.2c: <code>outputs_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-2c-outputs-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>A BLAKE2b-256 hash of the field encodings of all <code>prevout</code> field values of transparent inputs belonging to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdOutputsHash"</pre>
</section>
</section>
<section id="t-3-sprout-digest"><h6><span class="section-heading">T.3: <code>sprout_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-3-sprout-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the non-authorizing components of Sprout <code>JSDescription</code> values belonging to the transaction. For each <code>JSDescription</code>, the following elements are appended to the hash</p>
<pre>* T.3a. ``vpub_old`` (8-byte signed little-endian)
* T.3b. ``vpub_new`` (8-byte signed little-endian)
* T.3c. ``anchor`` (32 bytes)
* T.3d. ``nullifiers`` (2 x 32 bytes)
* T.3e. ``commitments`` (2 x 32 bytes)
* T.3f. ``ephemeral_key`` (32 bytes)
* T.3g. ``random_seed`` (32 bytes)
* T.3h. ``macs`` (2 x 32 bytes)
* T.3i. ``ciphertexts`` (2 x 601 bytes)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdJSplitsHash"</pre>
</section>
<section id="t-4-sapling-digest"><h6><span class="section-heading">T.4: <code>sapling_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4-sapling-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>The digest of Sapling components is composed of two subtrees which are organized to permit easy interoperability with the <code>CompactBlock</code> representation of Sapling data specified by the ZIP 307 Light Client Protocol <a id="id5" class="footnote_reference" href="#zip-0307">6</a>.</p>
<p>This digest is a BLAKE2b-256 hash of the following values</p>
<pre>* T.4a. ``sapling_spends_digest`` (32-byte hash)
* T.4b. ``sapling_outputs_digest`` (32-byte hash)
* T.4c. ``valueBalance`` (64-bit signed little-endian)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSaplingHash"</pre>
<section id="t-4a-sapling-spends-digest"><h7><span class="section-heading">T.4a: <code>sapling_spends_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4a-sapling-spends-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This digest is a BLAKE2b-256 hash of the following values</p>
<pre>* T.4a.i. ``sapling_spends_compact_digest`` (32-byte hash)
* T.4a.ii. ``sapling_spends_noncompact_digest`` (32-byte hash)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSSpendsHash"</pre>
<section id="t-4a-i-sapling-spends-compact-digest"><h8><span class="section-heading">T.4a.i: <code>sapling_spends_compact_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4a-i-sapling-spends-compact-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h8>
<p>A BLAKE2b-256 hash of the field encoding of all <code>nullifier</code> field values of Sapling shielded spends belonging to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSSpendCHash"</pre>
</section>
<section id="t-4a-ii-sapling-spends-noncompact-digest"><h8><span class="section-heading">T.4a.ii: <code>sapling_spends_noncompact_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4a-ii-sapling-spends-noncompact-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h8>
<p>A BLAKE2b-256 hash of the non-nullifier information for all Sapling shielded spends belonging to the transaction, excluding zkproof data. For each spend, the following elements are included in the hash:</p>
<pre>* T.4a.ii.1 ``cv`` (field encoding bytes)
* T.4a.ii.2 ``anchor`` (field encoding bytes)
* T.4a.ii.3 ``rk`` (field encoding bytes)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSSpendNHash"</pre>
</section>
</section>
<section id="t-4b-sapling-outputs-digest"><h7><span class="section-heading">T.4b: <code>sapling_outputs_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4b-sapling-outputs-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This digest is a BLAKE2b-256 hash of the following values</p>
<pre>* T.4a.i. ``sapling_outputs_compact_digest`` (32-byte hash)
* T.4b.ii. ``sapling_outputs_memos_digest`` (32-byte hash)
* T.4b.iii. ``sapling_outputs_noncompact_digest`` (32-byte hash)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSOutputHash"</pre>
<section id="t-4b-i-sapling-outputs-compact-digest"><h8><span class="section-heading">T.4b.i: <code>sapling_outputs_compact_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4b-i-sapling-outputs-compact-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h8>
<p>A BLAKE2b-256 hash of the subset of Sapling output information included in the ZIP-307 <a id="id6" class="footnote_reference" href="#zip-0307">6</a> <code>CompactBlock</code> format for all Sapling shielded outputs belonging to the transaction. For each output, the following elements are included in the hash:</p>
<pre>* T.4b.i.1 ``cmu`` (field encoding bytes)
* T.4b.i.2 ``ephemeral_key`` (field encoding bytes)
* T.4b.i.3 ``enc_ciphertext[..52]`` (First 52 bytes of field encoding)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSOutC__Hash"</pre>
</section>
<section id="t-4a-ii-sapling-outputs-memos-digest"><h8><span class="section-heading">T.4a.ii: <code>sapling_outputs_memos_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4a-ii-sapling-outputs-memos-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h8>
<p>A BLAKE2b-256 hash of the subset of Sapling shielded memo field data for all Sapling shielded outputs belonging to the transaction. For each output, the following elements are included in the hash:</p>
<pre>* T.4b.ii.1 ``enc_ciphertext[52..564] (contents of the encrypted memo field)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSOutM__Hash"</pre>
</section>
<section id="t-4a-iii-sapling-outputs-noncompact-digest"><h8><span class="section-heading">T.4a.iii: <code>sapling_outputs_noncompact_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#t-4a-iii-sapling-outputs-noncompact-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h8>
<p>A BLAKE2b-256 hash of the remaining subset of Sapling output information <strong>not</strong> included in the ZIP 307 <a id="id7" class="footnote_reference" href="#zip-0307">6</a> <code>CompactBlock</code> format, excluding zkproof data, for all Sapling shielded outputs belonging to the transaction. For each output, the following elements are included in the hash:</p>
<pre>* T.4b.iii.1 ``cv`` (field encoding bytes)
* T.4b.iii.2 ``enc_ciphertext[564..]`` (post-memo suffix of field encoding)
* T.4b.iii.3 ``out_ciphertext`` (field encoding bytes)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdSOutN__Hash" (2 underscore characters)</pre>
</section>
</section>
</section>
</section>
</section>
<section id="signature-digest"><h4><span class="section-heading">Signature Digest</span><span class="section-anchor"> <a rel="bookmark" href="#signature-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>A new per-input transaction digest algorithm is defined that constructs a hash that may be signed by a transaction creator to commit to the effects of the transaction. In the case that the transaction consumes no transparent inputs, it should be possible to just sign the transaction identifier produced by the <code>TxId Digest</code> algorithm. In the case that transparent inputs are present, this algorithm follows closely the ZIP 143 <a id="id8" class="footnote_reference" href="#zip-0143">5</a> algorithm.</p>
<p>The overall structure of the hash is as follows; each name referenced here will be described in detail below:</p>
<pre>signature_digest
├── header_digest
├── transparent_digest
├── sprout_digest
└── sapling_digest</pre>
<section id="id9"><h5><span class="section-heading"><code>signature_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#id9"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* S.1: ``header_digest`` (32-byte hash output)
* S.2: ``transparent_digest`` (32-byte hash output)
* S.3: ``sprout_digest (32-byte hash output)
* S.4: ``sapling_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZcashTxHash_" || CONSENSUS_BRANCH_ID</pre>
<p>This value must have the same personalization as the top hash of the transaction identifier digest tree, in order to make it possible to sign the transaction id in the case that there are no transparent inputs.</p>
<section id="s-1-header-digest"><h6><span class="section-heading">S.1: <code>header_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-1-header-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>Identical to that specified for the transaction identifier.</p>
</section>
<section id="s-2-transparent-digest"><h6><span class="section-heading">S.2: <code>transparent_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-2-transparent-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>If we are producing a hash for the signature over a transparent input, the value of the digest produced here depends upon the value of a <code>hash_type</code> flag as in ZIP 143 <a id="id10" class="footnote_reference" href="#zip-0143">5</a>.</p>
<p>The construction of each component below depends upon the values of the <code>hash_type</code> flag bits. Each component will be described separately</p>
<p>This digest is a BLAKE2b-256 hash of the following values</p>
<pre>* S.2a. ``prevouts_digest`` (32-byte hash)
* S.2b. ``sequence_digest`` (32-byte hash)
* S.2c. ``outputs_digest`` (32-byte hash)
* S.2d. ``txin_sig_digest`` (32-byte hash)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdTranspaHash"</pre>
<section id="s-2a-prevouts-digest"><h7><span class="section-heading">S.2a: <code>prevouts_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-2a-prevouts-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This is a BLAKE2b-256 hash initialized with the personalization field value "ZTxIdPrevoutHash".</p>
<p>If the <code>SIGHASH_ANYONECANPAY</code> flag is not set:</p>
<pre>* identical to the value of ``prevouts_digest`` as specified for the
transaction identifier in section T.2a.</pre>
<p>otherwise:</p>
<pre>* the hash is immediately finalized, without being updated with any
additional data</pre>
</section>
<section id="s-2b-sequence-digest"><h7><span class="section-heading">S.2b: <code>sequence_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-2b-sequence-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This is a BLAKE2b-256 hash initialized with the personalization field value "ZTxIdSequencHash".</p>
<p>If none of the <code>SIGHASH_ANYONECANPAY</code>, <code>SIGHASH_SINGLE</code>, or <code>SIGHASH_NONE</code> flags are set:</p>
<pre>* identical to the value of ``sequence_digest`` as specified for the
transaction identifier in section T.2b.</pre>
<p>otherwise:</p>
<pre>* the hash is immediately finalized, without being updated with any
additional data</pre>
</section>
<section id="s-2c-outputs-digest"><h7><span class="section-heading">S.2c: <code>outputs_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-2c-outputs-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This is a BLAKE2b-256 hash initialized with the personalization field value "ZTxIdOutputsHash".</p>
<p>If none of the <code>SIGHASH_SINGLE</code> or <code>SIGHASH_NONE</code> flags are set:</p>
<pre>* identical to the value of ``outputs_digest`` as specified for the
transaction identifier in section T.2c.</pre>
<p>If the <code>SIGHASH_SINGLE</code> flag is set and the signature hash is being computed for the transparent input at a particular index, and a transparent output appears in the transaction at that index:</p>
<pre>* the hash is updated with the transaction serialized form of the
transparent output at that index, and finalized.</pre>
<p>If the <code>SIGHASH_SINGLE</code> flag is set and the signature is being computed for a shielded input, or if the <code>SIGHASH_NONE</code> flag is set:</p>
<pre>* the hash is immediately finalized, without being updated with any
additional data</pre>
</section>
<section id="s-2d-txin-sig-digest"><h7><span class="section-heading">S.2d: <code>txin_sig_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-2d-txin-sig-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h7>
<p>This is a BLAKE2b-256 hash initialized with the personalization field value "Zcash___TxInHash" (3 underscores).</p>
<p>If the signature hash is being computed for a transparent input, the hash is updated with the following properties of that input:</p>
<pre>* S.2d.i. ``prevout`` (field encoding)
* S.2d.ii. ``script_code`` (field encoding)
* S.2d.iii. ``value`` (8-byte signed little-endian)
* S.2d.iv. ``nSequence`` (4-byte unsigned little-endian)</pre>
<p>otherwise:</p>
<pre>* the hash is immediately finalized, without being updated with any
additional data</pre>
</section>
</section>
<section id="s-3-sprout-digest"><h6><span class="section-heading">S.3: <code>sprout_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-3-sprout-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>Identical to that specified for the transaction identifier.</p>
</section>
<section id="s-4-sapling-digest"><h6><span class="section-heading">S.4: <code>sapling_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-4-sapling-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>Identical to that specified for the transaction identifier.</p>
</section>
</section>
</section>
<section id="authorizing-data-commitment"><h4><span class="section-heading">Authorizing Data Commitment</span><span class="section-anchor"> <a rel="bookmark" href="#authorizing-data-commitment"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>A new transaction digest algorithm is defined that constructs a digest which commits to the authorizing data of a transaction from a tree of BLAKE2b-256 hashes. The overall structure of the hash is as follows:</p>
<blockquote>
<p>auth_digest ├── transparent_scripts_digest ├── sprout_sigs_digest └── sapling_sigs_digest</p>
</blockquote>
<p>Each node written as <code>snake_case</code> in this tree is a BLAKE2b-256 hash of authorizing data of the transaction.</p>
<p>The pair (Transaction Identifier, Auth Commitment) constitutes a commitment to all the data of a serialized transaction that may be included in a block.</p>
<section id="auth-digest"><h5><span class="section-heading"><code>auth_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#auth-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* ``transparent_scripts_digest`` (32-byte hash output)
* ``sprout_auth_digest (32-byte hash output)
* ``sapling_auth_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxAuthHash_" || CONSENSUS_BRANCH_ID</pre>
<section id="a-1-transparent-scripts-digest"><h6><span class="section-heading">A.1: <code>transparent_scripts_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#a-1-transparent-scripts-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the field encoding of the Bitcoin script associated with each transparent input belonging to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxAuthTransHash"</pre>
</section>
<section id="a-2-sprout-auth-digest"><h6><span class="section-heading">A.2: <code>sprout_auth_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#a-2-sprout-auth-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the field encoding of the <code>zkproof</code> values of each <code>JSDescription</code> belonging to the transaction, followed by the <code>joinsplit_pubkey</code> and <code>joinsplit_sig</code>:</p>
<pre>* A.2a. ``zkproofs`` (field encoding bytes)
* A.2b. ``joinsplit_pubkey``
* A.2b. ``joinsplit_sig``</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxAuthSprouHash"</pre>
</section>
<section id="a-3-sapling-auth-digest"><h6><span class="section-heading">A.3: <code>sapling_auth_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#a-3-sapling-auth-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the field encoding of the Sapling zkproof values of each Sapling spend description and output description belonging to the transaction, followed by the field encoding of the binding signature</p>
<pre>* A.3a. ``spend_zkproofs`` (field encoding bytes)
* A.3b. ``output_zkproofs`` (field encoding bytes)
* A.3c. ``binding_sig``</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxAuthSapliHash"</pre>
</section>
</section>
</section>
</section>
<section id="block-header-changes"><h3><span class="section-heading">Block Header Changes</span><span class="section-anchor"> <a rel="bookmark" href="#block-header-changes"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>The nonmalleable transaction identifier specified by this ZIP will be used in the place of the current malleable transaction identifier within the Merkel tree committed to by the <code>hashMerkleRoot</code> value. However, this change now means that <code>hashMerkleRoot</code> is not sufficient to fully commit to the transaction data, including witnesses, that appear within the block.</p>
<p>As a consequence, we now need to add a new commitment to the block header. This commitment will be the root of a Merkle tree that has parallel structure to the tree committed to by <code>hashMerkleRoot</code> (a path through this merkle tree to a transaction identifies the same transaction as that path reaches in the tree rooted at <code>hashMerkleRoot</code>) but where the leaves are hashes produced according to the <cite>Authorizing Data Commitment</cite> part of this specification.</p>
<p>This new commitment is named <code>hashAuthDataRoot</code> and is the root of a left-dense binary merkle tree of transaction authorizing data commitments. Empty internal nodes and leaves in the merkle tree (nodes without children) have the "null" hash value <code>[0u8; 32]</code>. Hashes in this tree are BLAKE2b-256 hashes personalized by the string <code>"ZcashAuthDatHash"</code>.</p>
<p>Changing the block header format to allow space for an additional commitment is somewhat invasive. Instead, the name and meaning of the <code>hashLightClientRoot</code> field is changed.</p>
<p><code>hashLightClientRoot</code> is renamed to <code>hashBlockCommitments</code>. The value of this hash is the BLAKE2b-256 hash personalized by the string <code>"ZcashBlockCommit"</code> of the following elements:</p>
<pre>* ``hashLightClientRoot`` as described in ZIP 221 [#zip-0221]_
* ``hashAuthDataRoot``
* ``terminator`` [0u8;32]</pre>
<p>This representation treats the <code>hashBlockCommitments</code> value as a linked list of hashes terminated by arbitrary data. In the case of protocol upgrades where additional commitments need to be included in the block header, it is possible to replace this terminator with the hash of a newly defined structure which ends in a similar terminator. Fully validating nodes MUST always use the entire structure defined by the latest activated protocol version that they support.</p>
<p>The linked structure of this hash is intended to provide extensibility for use by light clients which may be connected to a third-party server that supports a later protocol version. Such a third party SHOULD provide a value that can be used instead of the all-zeros terminator to permit the light client to perform validation of the parts of the structure it needs.</p>
</section>
</section>
<section id="reference-implementation"><h2><span class="section-heading">Reference implementation</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<ul>
<li><a href="https://github.com/zcash/librustzcash/pull/319/files">https://github.com/zcash/librustzcash/pull/319/files</a></li>
</ul>
</section>
<section id="references"><h2><span class="section-heading">References</span><span class="section-anchor"> <a rel="bookmark" href="#references"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<table id="rfc2119" class="footnote">
<tbody>
<tr>
<th>1</th>
<td><a href="https://www.rfc-editor.org/rfc/rfc2119.html">RFC 2119: Key words for use in RFCs to Indicate Requirement Levels</a></td>
</tr>
</tbody>
</table>
<table id="zip-0200" class="footnote">
<tbody>
<tr>
<th>2</th>
<td><a href="zip-0200">ZIP 200: Network Upgrade Activation Mechanism</a></td>
</tr>
</tbody>
</table>
<table id="zip-0221" class="footnote">
<tbody>
<tr>
<th>3</th>
<td><a href="zip-0221">ZIP 221: FlyClient - Consensus Layer Changes</a></td>
</tr>
</tbody>
</table>
<table id="zip-0076" class="footnote">
<tbody>
<tr>
<th>4</th>
<td><a href="zip-0076">ZIP 76: Transaction Signature Validation before Overwinter</a></td>
</tr>
</tbody>
</table>
<table id="zip-0143" class="footnote">
<tbody>
<tr>
<th>5</th>
<td><a href="zip-0143">ZIP 143: Transaction Signature Validation for Overwinter</a></td>
</tr>
</tbody>
</table>
<table id="zip-0307" class="footnote">
<tbody>
<tr>
<th>6</th>
<td><a href="zip-0307">ZIP 307: Light Client Protocol for Payment Detection</a></td>
</tr>
</tbody>
</table>
</section>
</section>
</body>
</html>

View File

@ -1,7 +1,7 @@
::
ZIP: 244
Title: Transaction Non-Malleability
Title: Transaction Identifier Non-Malleability
Owners: Kris Nuttycombe <kris@electriccoin.co>
Daira Hopwood <daira@electriccoin.co>
Status: Draft
@ -107,7 +107,7 @@ A new transaction digest algorithm is defined that constructs the identifier for
a transaction from a tree of hashes. Each branch of the tree of hashes will
correspond to a specific subset of transaction data. The overall structure of
the hash is as follows; each name referenced here will be described in detail
below:
below::
txid_digest
├── header_digest
@ -132,7 +132,7 @@ of the tree. Nodes that are not themselves digests are written in ``camelCase``.
In the specification below, nodes of the tree are presented in depth-first order.
``txid_digest``
--------------
---------------
A BLAKE2b-256 hash of the following values ::
* T.1: ``header_digest`` (32-byte hash output)
@ -151,33 +151,33 @@ protection: transactions targeted for one consensus branch will not have the sam
transaction identifier on other consensus branches.
T.1: ``header_digest``
`````````````````````````
``````````````````````
A BLAKE2b-256 hash of the following values ::
* T.1a. ``version`` (4-byte little-endian version identifier including overwinter flag)
* T.1b. ``version_group_id`` (4-byte little-endian version group identifier)
* T.1c. ``consensus_branch_id`` (4-byte little-endian consensus branch id)
* T.1d. ``lock_time`` (4-byte little-endian nLockTime value)
* T.1e. ``expiry_height`` (4-byte little-endian block height)
* T.1a. ``version`` (4-byte little-endian version identifier including overwinter flag)
* T.1b. ``version_group_id`` (4-byte little-endian version group identifier)
* T.1c. ``consensus_branch_id`` (4-byte little-endian consensus branch id)
* T.1d. ``lock_time`` (4-byte little-endian nLockTime value)
* T.1e. ``expiry_height`` (4-byte little-endian block height)
The personalization field of this hash is set to::
"ZTxIdHeadersHash"
T.2: ``transparent_digest``
`````````````````````````
```````````````````````````
A BLAKE2b-256 hash of the following values ::
* T.2a. ``prevouts_digest`` (32-byte hash)
* T.2b. ``sequence_digest`` (32-byte hash)
* T.2c. ``outputs_digest`` (32-byte hash)
* T.2a. ``prevouts_digest`` (32-byte hash)
* T.2b. ``sequence_digest`` (32-byte hash)
* T.2c. ``outputs_digest`` (32-byte hash)
The personalization field of this hash is set to::
"ZTxIdTranspaHash"
T.2a: ``prevouts_digest``
'''''''''''''''''''''''
'''''''''''''''''''''''''
A BLAKE2b-256 hash of the field encoding of all ``outpoint``
field values of transparent inputs to the transaction.
@ -186,7 +186,7 @@ The personalization field of this hash is set to::
"ZTxIdPrevoutHash"
T.2b: ``sequence_digest``
'''''''''''''''''''''''
'''''''''''''''''''''''''
A BLAKE2b-256 hash of the 32-bit little-endian representation of all ``nSequence``
field values of transparent inputs to the transaction.
@ -195,7 +195,7 @@ The personalization field of this hash is set to::
"ZTxIdSequencHash"
T.2c: ``outputs_digest``
''''''''''''''''''''''
''''''''''''''''''''''''
A BLAKE2b-256 hash of the field encodings of all ``prevout`` field values of
transparent inputs belonging to the transaction.
@ -204,27 +204,27 @@ The personalization field of this hash is set to::
"ZTxIdOutputsHash"
T.3: ``sprout_digest``
`````````````````````````
``````````````````````
A BLAKE2b-256 hash of the non-authorizing components of Sprout ``JSDescription`` values
belonging to the transaction. For each ``JSDescription``, the following elements are
appended to the hash ::
* T.3a. ``vpub_old`` (8-byte signed little-endian)
* T.3b. ``vpub_new`` (8-byte signed little-endian)
* T.3c. ``anchor`` (32 bytes)
* T.3d. ``nullifiers`` (2 x 32 bytes)
* T.3e. ``commitments`` (2 x 32 bytes)
* T.3f. ``ephemeral_key`` (32 bytes)
* T.3g. ``random_seed`` (32 bytes)
* T.3h. ``macs`` (2 x 32 bytes)
* T.3i. ``ciphertexts`` (2 x 601 bytes)
* T.3a. ``vpub_old`` (8-byte signed little-endian)
* T.3b. ``vpub_new`` (8-byte signed little-endian)
* T.3c. ``anchor`` (32 bytes)
* T.3d. ``nullifiers`` (2 x 32 bytes)
* T.3e. ``commitments`` (2 x 32 bytes)
* T.3f. ``ephemeral_key`` (32 bytes)
* T.3g. ``random_seed`` (32 bytes)
* T.3h. ``macs`` (2 x 32 bytes)
* T.3i. ``ciphertexts`` (2 x 601 bytes)
The personalization field of this hash is set to::
"ZTxIdJSplitsHash"
T.4: ``sapling_digest``
`````````````````````
```````````````````````
The digest of Sapling components is composed of two subtrees which are organized to
permit easy interoperability with the ``CompactBlock`` representation of Sapling data
specified by the ZIP 307 Light Client Protocol [#zip-0307]_.
@ -240,7 +240,7 @@ The personalization field of this hash is set to::
"ZTxIdSaplingHash"
T.4a: ``sapling_spends_digest``
''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
This digest is a BLAKE2b-256 hash of the following values ::
* T.4a.i. ``sapling_spends_compact_digest`` (32-byte hash)
@ -251,7 +251,7 @@ The personalization field of this hash is set to::
"ZTxIdSSpendsHash"
T.4a.i: ``sapling_spends_compact_digest``
.......................................
.........................................
A BLAKE2b-256 hash of the field encoding of all ``nullifier`` field
values of Sapling shielded spends belonging to the transaction.
@ -260,7 +260,7 @@ The personalization field of this hash is set to::
"ZTxIdSSpendCHash"
T.4a.ii: ``sapling_spends_noncompact_digest``
...........................................
.............................................
A BLAKE2b-256 hash of the non-nullifier information for all Sapling shielded spends
belonging to the transaction, excluding zkproof data. For each spend, the following
elements are included in the hash::
@ -274,7 +274,7 @@ The personalization field of this hash is set to::
"ZTxIdSSpendNHash"
T.4b: ``sapling_outputs_digest``
'''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''
This digest is a BLAKE2b-256 hash of the following values ::
* T.4a.i. ``sapling_outputs_compact_digest`` (32-byte hash)
@ -286,7 +286,7 @@ The personalization field of this hash is set to::
"ZTxIdSOutputHash"
T.4b.i: ``sapling_outputs_compact_digest``
.........................................
..........................................
A BLAKE2b-256 hash of the subset of Sapling output information included in the
ZIP-307 [#zip-0307]_ ``CompactBlock`` format for all Sapling shielded outputs
belonging to the transaction. For each output, the following elements are included
@ -301,7 +301,7 @@ The personalization field of this hash is set to::
"ZTxIdSOutC__Hash"
T.4a.ii: ``sapling_outputs_memos_digest``
........................................
.........................................
A BLAKE2b-256 hash of the subset of Sapling shielded memo field data for all Sapling
shielded outputs belonging to the transaction. For each output, the following elements
are included in the hash::
@ -313,7 +313,7 @@ The personalization field of this hash is set to::
"ZTxIdSOutM__Hash"
T.4a.iii: ``sapling_outputs_noncompact_digest``
..............................................
...............................................
A BLAKE2b-256 hash of the remaining subset of Sapling output information **not** included
in the ZIP 307 [#zip-0307]_ ``CompactBlock`` format, excluding zkproof data, for all
Sapling shielded outputs belonging to the transaction. For each output, the following
@ -338,7 +338,7 @@ transparent inputs are present, this algorithm follows closely the ZIP 143 [#zip
algorithm.
The overall structure of the hash is as follows; each name referenced here will be
described in detail below:
described in detail below::
signature_digest
├── header_digest
@ -364,11 +364,11 @@ identifier digest tree, in order to make it possible to sign the transaction id
in the case that there are no transparent inputs.
S.1: ``header_digest``
`````````````````````````
``````````````````````
Identical to that specified for the transaction identifier.
S.2: ``transparent_digest``
`````````````````````````
```````````````````````````
If we are producing a hash for the signature over a transparent input,
the value of the digest produced here depends upon the value of a ``hash_type``
flag as in ZIP 143 [#zip-0143]_.
@ -388,7 +388,7 @@ The personalization field of this hash is set to::
"ZTxIdTranspaHash"
S.2a: ``prevouts_digest``
'''''''''''''''''''''''
'''''''''''''''''''''''''
This is a BLAKE2b-256 hash initialized with the personalization field value
"ZTxIdPrevoutHash".
@ -403,7 +403,7 @@ otherwise::
additional data
S.2b: ``sequence_digest``
'''''''''''''''''''''''
'''''''''''''''''''''''''
This is a BLAKE2b-256 hash initialized with the personalization field value
"ZTxIdSequencHash".
@ -419,7 +419,7 @@ otherwise::
additional data
S.2c: ``outputs_digest``
'''''''''''''''''''''''
''''''''''''''''''''''''
This is a BLAKE2b-256 hash initialized with the personalization field value
"ZTxIdOutputsHash".
@ -460,11 +460,11 @@ otherwise::
additional data
S.3: ``sprout_digest``
`````````````````````````
``````````````````````
Identical to that specified for the transaction identifier.
S.4: ``sapling_digest``
`````````````````````````
```````````````````````
Identical to that specified for the transaction identifier.
Authorizing Data Commitment
@ -486,7 +486,7 @@ The pair (Transaction Identifier, Auth Commitment) constitutes a commitment to a
data of a serialized transaction that may be included in a block.
``auth_digest``
--------------
---------------
A BLAKE2b-256 hash of the following values ::
* ``transparent_scripts_digest`` (32-byte hash output)
@ -497,8 +497,8 @@ The personalization field of this hash is set to::
"ZTxAuthHash_" || CONSENSUS_BRANCH_ID
1: ``transparent_scripts_digest``
`````````````````````````````````
A.1: ``transparent_scripts_digest``
```````````````````````````````````
A BLAKE2b-256 hash of the field encoding of the Bitcoin script associated
with each transparent input belonging to the transaction.
@ -506,29 +506,29 @@ The personalization field of this hash is set to::
"ZTxAuthTransHash"
2: ``sprout_auth_digest``
A.2: ``sprout_auth_digest``
```````````````````````````
A BLAKE2b-256 hash of the field encoding of the ``zkproof`` values of each
``JSDescription`` belonging to the transaction, followed by the
``joinsplit_pubkey`` and ``joinsplit_sig``.
``joinsplit_pubkey`` and ``joinsplit_sig``::
* 2a. ``zkproofs`` (field encoding bytes)
* 2b. ``joinsplit_pubkey``
* 2b. ``joinsplit_sig``
* A.2a. ``zkproofs`` (field encoding bytes)
* A.2b. ``joinsplit_pubkey``
* A.2b. ``joinsplit_sig``
The personalization field of this hash is set to::
"ZTxAuthSprouHash"
3: ``sapling_auth_digest``
```````````````````````````
A.3: ``sapling_auth_digest``
````````````````````````````
A BLAKE2b-256 hash of the field encoding of the Sapling zkproof values
of each Sapling spend description and output description belonging to
the transaction, followed by the field encoding of the binding signature ::
* 3a. ``spend_zkproofs`` (field encoding bytes)
* 3b. ``output_zkproofs`` (field encoding bytes)
* 3c. ``binding_sig``
* A.3a. ``spend_zkproofs`` (field encoding bytes)
* A.3b. ``output_zkproofs`` (field encoding bytes)
* A.3c. ``binding_sig``
The personalization field of this hash is set to::
@ -540,22 +540,22 @@ Block Header Changes
The nonmalleable transaction identifier specified by this ZIP will be used
in the place of the current malleable transaction identifier within the
Merkle tree committed to by the ``hashMerkleRoot`` value. However, this
Merkel tree committed to by the ``hashMerkleRoot`` value. However, this
change now means that ``hashMerkleRoot`` is not sufficient to fully commit
to the transaction data, including witnesses, that appear within the block.
As a consequence, we now need to add a new commitment to the block header.
This commitment will be the root of a Merkle tree that has parallel structure
to the tree committed to by ``hashMerkleRoot`` (the position of the transaction
in this Merkle tree identifies the same transaction as the same position in the
tree rooted at ``hashMerkleRoot``) but where the leaves are hashes produced
according to the :ref:`Authorizing Data Commitment<Authorizing Data Commitment>`
to the tree committed to by ``hashMerkleRoot`` (a path through this merkle
tree to a transaction identifies the same transaction as that path reaches
in the tree rooted at ``hashMerkleRoot``) but where the leaves are hashes
produced according to the `Authorizing Data Commitment` part of this
specification.
This new commitment is named ``hashAuthDataRoot`` and is the root of a left-dense
binary Merkle tree of transaction-authorizing data commitments. Empty internal nodes
and leaves in the Merkle tree (nodes without children) have the "null" hash value
``[0u8; 32]``. Hashes in this tree are BLAKE2b-256 hashes, personalized by the string
binary merkle tree of transaction authorizing data commitments. Empty internal nodes
and leaves in the merkle tree (nodes without children) have the "null" hash value
``[0u8; 32]``. Hashes in this tree are BLAKE2b-256 hashes personalized by the string
``"ZcashAuthDatHash"``.
Changing the block header format to allow space for an additional
@ -564,7 +564,7 @@ commitment is somewhat invasive. Instead, the name and meaning of the
``hashLightClientRoot`` is renamed to ``hashBlockCommitments``. The value
of this hash is the BLAKE2b-256 hash personalized by the string ``"ZcashBlockCommit"``
of the following elements:
of the following elements::
* ``hashLightClientRoot`` as described in ZIP 221 [#zip-0221]_
* ``hashAuthDataRoot``
@ -601,3 +601,4 @@ References
.. [#zip-0076] `ZIP 76: Transaction Signature Validation before Overwinter <zip-0076.rst>`_
.. [#zip-0143] `ZIP 143: Transaction Signature Validation for Overwinter <zip-0143.rst>`_
.. [#zip-0307] `ZIP 307: Light Client Protocol for Payment Detection <zip-0307.rst>`_

View File

@ -1,18 +1,159 @@
<!DOCTYPE html>
<html>
<head>
<title>ZIP 245: Transaction Non-Malleability</title>
<title>ZIP 245: Transaction Identifier Digests &amp; Signature Validation for Transparent Zcash Extensions</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="css/style.css"></head>
<body>
<section>
<pre>ZIP: 245
Title: Transaction Non-Malleability
Owners: Daira Hopwood &lt;daira@electriccoin.co&gt;
Kris Nuttycombe &lt;kris@electriccoin.co&gt;
Title: Transaction Identifier Digests &amp; Signature Validation for Transparent Zcash Extensions
Owners: Kris Nuttycombe &lt;kris@electriccoin.co&gt;
Status: Reserved
Category: Consensus
Discussions-To: &lt;<a href="https://github.com/zcash/zips/issues/411">https://github.com/zcash/zips/issues/411</a>&gt;</pre>
Discussions-To: &lt;<a href="https://github.com/zcash/zips/issues/384">https://github.com/zcash/zips/issues/384</a>&gt;</pre>
<section id="terminology"><h2><span class="section-heading">Terminology</span><span class="section-anchor"> <a rel="bookmark" href="#terminology"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>The key words "MUST" and "MUST NOT" in this document are to be interpreted as described in RFC 2119. <a id="id1" class="footnote_reference" href="#rfc2119">1</a></p>
<p>The terms "consensus branch", "epoch", and "network upgrade" in this document are to be interpreted as described in ZIP 200. <a id="id2" class="footnote_reference" href="#zip-0200">2</a></p>
</section>
<section id="abstract"><h2><span class="section-heading">Abstract</span><span class="section-anchor"> <a rel="bookmark" href="#abstract"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>This proposal defines changes to ZIP 244 <a id="id3" class="footnote_reference" href="#zip-0244">4</a> transaction id and signature digest algorithms to accommodate the inclusion of transparent Zcash extensions (TZEs) as defined in ZIP 222 <a id="id4" class="footnote_reference" href="#zip-0222">3</a>.</p>
</section>
<section id="specification"><h2><span class="section-heading">Specification</span><span class="section-anchor"> <a rel="bookmark" href="#specification"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<section id="txid-digest"><h3><span class="section-heading">TxId Digest</span><span class="section-anchor"> <a rel="bookmark" href="#txid-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>The tree of hashes defined by ZIP 244 <a id="id5" class="footnote_reference" href="#zip-0244">4</a> is re-structured to include a new branch for TZE hashes. The <code>tze_digest</code> branch is the only new addition to the tree; <code>header_digest</code>, <code>transparent_digest</code>, <code>sprout_digest</code>, and <code>sapling_digest</code> are as in ZIP 244:</p>
<pre>txid_digest
├── header_digest
├── transparent_digest
├── tze_digest
│   ├── tzein_digest
│   └── tzeout_digest
├── sprout_digest
└── sapling_digest</pre>
<section id="id6"><h4><span class="section-heading"><code>txid_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#id6"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>The top hash of the <code>txid_digest</code> tree is modified from the ZIP 244 structure to be a BLAKE2b-256 hash of the following values</p>
<pre>* ``header_digest`` (32-byte hash output)
* ``transparent_digest`` (32-byte hash output)
* ``tze_digest (32-byte hash output)
* ``sprout_digest (32-byte hash output)
* ``sapling_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is unmodified from ZIP 244.</p>
<section id="tze-digest"><h5><span class="section-heading">2: <code>tze_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#tze-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* 2a. ``tzein_digest`` (32-byte hash)
* 2b. ``tzeout_digest`` (32-byte hash)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdTZE____Hash" (4 underscore characters)</pre>
<section id="a-tzein-digest"><h6><span class="section-heading">2a: <code>tzein_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#a-tzein-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of all TZE inputs to the transaction, excluding witness data. For each TZE input, the following values are appended to this hash:</p>
<pre>* 2a.i. the field encoding of the CompactSize representation
of the TZE extension id for the input.
* 2a.i. the field encoding of the CompactSize representation
of the TZE mode for the input.</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdTZEIns_Hash" (1 underscore character)</pre>
</section>
<section id="a-tzeout-digest"><h6><span class="section-heading">2a: <code>tzeout_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#a-tzeout-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h6>
<p>A BLAKE2b-256 hash of the field encoding of all TZE outputs belonging to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxIdTzeOutsHash"</pre>
</section>
</section>
</section>
</section>
<section id="signature-digest"><h3><span class="section-heading">Signature Digest</span><span class="section-anchor"> <a rel="bookmark" href="#signature-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>The signature digest creation algorithm defined by ZIP 244 <a id="id7" class="footnote_reference" href="#zip-0244">4</a> is modified to include a new branch for TZE hashes. The <code>tze_digest</code> branch is the only new addition to the tree; <code>header_digest</code>, <code>transparent_digest</code>, <code>sprout_digest</code>, and <code>sapling_digest</code> are as in ZIP 244:</p>
<pre>signature_digest
├── header_digest
├── transparent_digest
├── tze_digest
│   ├── tzein_digest
│   └── tzeout_digest
├── sprout_digest
└── sapling_digest</pre>
<section id="id8"><h4><span class="section-heading"><code>signature_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#id8"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>A BLAKE2b-256 hash of the following values</p>
<pre>* S.1: ``header_digest`` (32-byte hash output)
* S.2: ``transparent_digest`` (32-byte hash output)
* S.3: ``tze_digest`` (32-byte hash output)
* S.4: ``sprout_digest (32-byte hash output)
* S.5: ``sapling_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"ZcashTxHash_" || CONSENSUS_BRANCH_ID</pre>
<p>This value must have the same personalization as the top hash of the transaction identifier digest tree, in order to make it possible to sign the transaction id in the case that there are no transparent inputs.</p>
<section id="s-3-tze-digest"><h5><span class="section-heading">S.3: <code>tze_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#s-3-tze-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>This digest is a BLAKE2b-256 hash of the following values of the TZE input being signed:</p>
<pre>* S.3a. ``prevout_digest`` (field encoding bytes)
* S.3b. ``extension_id`` (CompactSize field encoding)
* S.3c. ``mode`` (CompactSize field encoding)
* S.3d. ``payload`` (arbitrary bytes)
* S.3e. ``value`` of the output spent by this input (8-byte little endian)</pre>
<p>The personalization field of this hash is set to:</p>
<pre>"Zcash__TzeInHash"</pre>
</section>
</section>
</section>
<section id="authorizing-data-commitment"><h3><span class="section-heading">Authorizing Data Commitment</span><span class="section-anchor"> <a rel="bookmark" href="#authorizing-data-commitment"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>The tree of hashes defined by ZIP 244 <a id="id9" class="footnote_reference" href="#zip-0244">4</a> for authorizing data commitments is re-structured to include a new branch for TZE hashes. The <code>tze_digest</code> branch is the only new addition to the tree; <code>transparent_digest</code>, <code>sprout_digest</code>, and <code>sapling_digest</code> are as in ZIP 244:</p>
<pre>auth_digest
├── transparent_scripts_digest
├── tze_witnesses_digest
├── sprout_sigs_digest
└── sapling_sigs_digest</pre>
<section id="auth-digest"><h4><span class="section-heading"><code>auth_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#auth-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>The top hash of the <code>auth_digest</code> tree is modified from the ZIP 244 structure to be a BLAKE2b-256 hash of the following values</p>
<pre>* ``transparent_scripts_digest`` (32-byte hash output)
* ``tze_witnesses_digest (32-byte hash output)
* ``sprout_sigs_digest (32-byte hash output)
* ``sapling_sigs_digest (32-byte hash output)</pre>
<p>The personalization field of this hash is unmodified from ZIP 244.</p>
</section>
<section id="tze-witnesses-digest"><h4><span class="section-heading">2: <code>tze_witnesses_digest</code></span><span class="section-anchor"> <a rel="bookmark" href="#tze-witnesses-digest"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>A BLAKE2b-256 hash of the field encoding of the witness <code>payload</code> data associated with each TZE input belonging to the transaction.</p>
<p>The personalization field of this hash is set to:</p>
<pre>"ZTxAuthTZE__Hash" (2 underscore characters)</pre>
</section>
</section>
</section>
<section id="reference-implementation"><h2><span class="section-heading">Reference implementation</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<ul>
<li><a href="https://github.com/zcash/librustzcash/pull/319/files">https://github.com/zcash/librustzcash/pull/319/files</a></li>
</ul>
</section>
<section id="references"><h2><span class="section-heading">References</span><span class="section-anchor"> <a rel="bookmark" href="#references"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<table id="rfc2119" class="footnote">
<tbody>
<tr>
<th>1</th>
<td><a href="https://www.rfc-editor.org/rfc/rfc2119.html">RFC 2119: Key words for use in RFCs to Indicate Requirement Levels</a></td>
</tr>
</tbody>
</table>
<table id="zip-0200" class="footnote">
<tbody>
<tr>
<th>2</th>
<td><a href="zip-0200">ZIP 200: Network Upgrade Activation Mechanism</a></td>
</tr>
</tbody>
</table>
<table id="zip-0222" class="footnote">
<tbody>
<tr>
<th>3</th>
<td><a href="zip-0222">ZIP 222: Transparent Zcash Extensions</a></td>
</tr>
</tbody>
</table>
<table id="zip-0244" class="footnote">
<tbody>
<tr>
<th>4</th>
<td><a href="zip-0244">ZIP 244: Transaction Identifier Non-Malleability</a></td>
</tr>
</tbody>
</table>
</section>
</section>
</body>
</html>

View File

@ -107,7 +107,7 @@ to the tree; ``header_digest``, ``transparent_digest``, ``sprout_digest``, and
└── sapling_digest
``signature_digest``
--------------------
````````````````````
A BLAKE2b-256 hash of the following values ::
* S.1: ``header_digest`` (32-byte hash output)
@ -124,16 +124,8 @@ This value must have the same personalization as the top hash of the transaction
identifier digest tree, in order to make it possible to sign the transaction id
in the case that there are no transparent inputs.
S.1: ``header_digest``
`````````````````````````
Identical to that specified by S.1 in ZIP 244
S.2: ``transparent_digest``
```````````````````````````
Identical to that specified by S.2 in ZIP 244
S.3: ``tze_digest``
`````````````````````````
'''''''''''''''''''
This digest is a BLAKE2b-256 hash of the following values of the TZE
input being signed::
@ -147,15 +139,6 @@ The personalization field of this hash is set to::
"Zcash__TzeInHash"
S.4: ``sprout_digest``
`````````````````````````
Identical to that specified by S.3 in ZIP 244
S.5: ``sapling_digest``
`````````````````````````
Identical to that specified by S.4 in ZIP 244
Authorizing Data Commitment
---------------------------
@ -198,3 +181,8 @@ Reference implementation
References
==========
.. [#RFC2119] `RFC 2119: Key words for use in RFCs to Indicate Requirement Levels <https://www.rfc-editor.org/rfc/rfc2119.html>`_
.. [#zip-0200] `ZIP 200: Network Upgrade Activation Mechanism <zip-0200.rst>`_
.. [#zip-0222] `ZIP 222: Transparent Zcash Extensions <zip-0222.rst>`_
.. [#zip-0244] `ZIP 244: Transaction Identifier Non-Malleability <zip-0244.rst>`_