<oembed><type>rich</type><version>1.0</version><author_name>npub1f2nvlx49er5c7sqa43src6ssyp6snd4qwvtkwm5avc2l84cs84esecrwet</author_name><author_url>https://nostr.ae/npub1f2nvlx49er5c7sqa43src6ssyp6snd4qwvtkwm5avc2l84cs84esecrwet</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2017-04-05&#xA;📝 Original message:A month ago I was explaining the attack on Bitcoin&#39;s SHA2 hashcash which&#xA;is exploited by ASICBOOST and the various steps which could be used to&#xA;block it in the network if it became a problem.&#xA;&#xA;While most discussion of ASICBOOST has focused on the overt method&#xA;of implementing it, there also exists a covert method for using it.&#xA;&#xA;As I explained one of the approaches to inhibit covert ASICBOOST I&#xA;realized that my words were pretty much also describing the SegWit&#xA;commitment structure.&#xA;&#xA;The authors of the SegWit proposal made a specific effort to not be&#xA;incompatible with any mining system and, in particular, changed the&#xA;design at one point to accommodate mining chips with forced payout&#xA;addresses.&#xA;&#xA;Had there been awareness of exploitation of this attack an effort&#xA;would have been made to avoid incompatibility-- simply to separate&#xA;concerns.  But the best methods of implementing the covert attack&#xA;are significantly incompatible with virtually any method of&#xA;extending Bitcoin&#39;s transaction capabilities; with the notable&#xA;exception of extension blocks (which have their own problems).&#xA;&#xA;An incompatibility would go a long way to explain some of the&#xA;more inexplicable behavior from some parties in the mining&#xA;ecosystem so I began looking for supporting evidence.&#xA;&#xA;Reverse engineering of a particular mining chip has demonstrated&#xA;conclusively that ASICBOOST has been implemented&#xA;in hardware.&#xA;&#xA;On that basis, I offer the following BIP draft for discussion.&#xA;This proposal does not prevent the attack in general, but only&#xA;inhibits covert forms of it which are incompatible with&#xA;improvements to the Bitcoin protocol.&#xA;&#xA;I hope that even those of us who would strongly prefer that&#xA;ASICBOOST be blocked completely can come together to support&#xA;a protective measure that separates concerns by inhibiting&#xA;the covert use of it that potentially blocks protocol improvements.&#xA;&#xA;The specific activation height is something I currently don&#39;t have&#xA;a strong opinion, so I&#39;ve left it unspecified for the moment.&#xA;&#xA;&lt;pre&gt;&#xA;  BIP: TBD&#xA;  Layer: Consensus&#xA;  Title: Inhibiting a covert attack on the Bitcoin POW function&#xA;  Author: Greg Maxwell &lt;greg at xiph.org&gt;&#xA;  Status: Draft&#xA;  Type: Standards Track&#xA;  Created: 2016-04-05&#xA;  License: PD&#xA;&lt;/pre&gt;&#xA;&#xA;==Abstract==&#xA;&#xA;This proposal inhibits the covert exploitation of a known&#xA;vulnerability in Bitcoin Proof of Work function.&#xA;&#xA;The key words &#34;MUST&#34;, &#34;MUST NOT&#34;, &#34;REQUIRED&#34;, &#34;SHALL&#34;, &#34;SHALL NOT&#34;,&#xA;&#34;SHOULD&#34;, &#34;SHOULD NOT&#34;, &#34;RECOMMENDED&#34;, &#34;MAY&#34;, and &#34;OPTIONAL&#34; in this&#xA;document are to be interpreted as described in RFC 2119.&#xA;&#xA;==Motivation==&#xA;&#xA;Due to a design oversight the Bitcoin proof of work function has a potential&#xA;attack which can allow an attacking miner to save up-to 30% of their energy&#xA;costs (though closer to 20% is more likely due to implementation overheads).&#xA;&#xA;Timo Hanke and Sergio Demian Lerner claim to hold a patent on this attack,&#xA;which they have so far not licensed for free and open use by the public.&#xA;They have been marketing their patent licenses under the trade-name&#xA;ASICBOOST.  The document takes no position on the validity or enforceability&#xA;of the patent.&#xA;&#xA;There are two major ways of exploiting the underlying vulnerability: One&#xA;obvious way which is highly detectable and is not in use on the network&#xA;today and a covert way which has significant interaction and potential&#xA;interference with the Bitcoin protocol.  The covert mechanism is not&#xA;easily detected except through its interference with the protocol.&#xA;&#xA;In particular, the protocol interactions of the covert method can block the&#xA;implementation of virtuous improvements such as segregated witness.&#xA;&#xA;Exploitation of this vulnerability could result in payoff of as much as&#xA;$100 million USD per year at the time this was written (Assuming at&#xA;50% hash-power miner was gaining a 30% power advantage and that mining&#xA;was otherwise at profit equilibrium).  This could have a phenomenal&#xA;centralizing effect by pushing mining out of profitability for all&#xA;other participants, and the income from secretly using this&#xA;optimization could be abused to significantly distort the Bitcoin&#xA;ecosystem in order to preserve the advantage.&#xA;&#xA;Reverse engineering of a mining ASIC from a major manufacture has&#xA;revealed that it contains an undocumented, undisclosed ability&#xA;to make use of this attack. (The parties claiming to hold a&#xA;patent on this technique were completely unaware of this use.)&#xA;&#xA;On the above basis the potential for covert exploitation of this&#xA;vulnerability and the resulting inequality in the mining process&#xA;and interference with useful improvements presents a clear and&#xA;present danger to the Bitcoin system which requires a response.&#xA;&#xA;==Background==&#xA;&#xA;The general idea of this attack is that SHA2-256 is a merkle damgard hash&#xA;function which consumes 64 bytes of data at a time.&#xA;&#xA;The Bitcoin mining process repeatedly hashes an 80-byte &#39;block header&#39; while&#xA;incriminating a 32-bit nonce which is at the end of this header data. This&#xA;means that the processing of the header involves two runs of the compression&#xA;function run-- one that consumes the first 64 bytes of the header and a&#xA;second which processes the remaining 16 bytes and padding.&#xA;&#xA;The initial &#39;message expansion&#39; operations in each step of the SHA2-256&#xA;function operate exclusively on that step&#39;s 64-bytes of input with no&#xA;influence from prior data that entered the hash.&#xA;&#xA;Because of this if a miner is able to prepare a block header with&#xA;multiple distinct first 64-byte chunks but identical 16-byte&#xA;second chunks they can reuse the computation of the initial&#xA;expansion for multiple trials. This reduces power consumption.&#xA;&#xA;There are two broad ways of making use of this attack. The obvious&#xA;way is to try candidates with different version numbers.  Beyond&#xA;upsetting the soft-fork detection logic in Bitcoin nodes this has&#xA;little negative effect but it is highly conspicuous and easily&#xA;blocked.&#xA;&#xA;The other method is based on the fact that the merkle root&#xA;committing to the transactions is contained in the first 64-bytes&#xA;except for the last 4 bytes of it.  If the miner finds multiple&#xA;candidate root values which have the same final 32-bit then they&#xA;can use the attack.&#xA;&#xA;To find multiple roots with the same trailing 32-bits the miner can&#xA;use efficient collision finding mechanism which will find a match&#xA;with as little as 2^16 candidate roots expected, 2^24 operations to&#xA;find a 4-way hit, though low memory approaches require more&#xA;computation.&#xA;&#xA;An obvious way to generate different candidates is to grind the&#xA;coinbase extra-nonce but for non-empty blocks each attempt will&#xA;require 13 or so additional sha2 runs which is very inefficient.&#xA;&#xA;This inefficiency can be avoided by computing a sqrt number of&#xA;candidates of the left side of the hash tree (e.g. using extra&#xA;nonce grinding) then an additional sqrt number of candidates of&#xA;the right  side of the tree using transaction permutation or&#xA;substitution of a small number of transactions.  All combinations&#xA;of the left and right side are then combined with only a single&#xA;hashing operation virtually eliminating all tree related&#xA;overhead.&#xA;&#xA;With this final optimization finding a 4-way collision with a&#xA;moderate amount of memory requires ~2^24 hashing operations&#xA;instead of the &gt;2^28 operations that would be require for&#xA;extra-nonce  grinding which would substantially erode the&#xA;benefit of the attack.&#xA;&#xA;It is this final optimization which this proposal blocks.&#xA;&#xA;==New consensus rule==&#xA;&#xA;Beginning block X and until block Y the coinbase transaction of&#xA;each block MUST either contain a BIP-141 segwit commitment or a&#xA;correct WTXID commitment with ID 0xaa21a9ef.&#xA;&#xA;(See BIP-141 &#34;Commitment structure&#34; for details)&#xA;&#xA;Existing segwit using miners are automatically compatible with&#xA;this proposal. Non-segwit miners can become compatible by simply&#xA;including an additional output matching a default commitment&#xA;value returned as part of getblocktemplate.&#xA;&#xA;Miners SHOULD NOT automatically discontinue the commitment&#xA;at the expiration height.&#xA;&#xA;==Discussion==&#xA;&#xA;The commitment in the left side of the tree to all transactions&#xA;in the right side completely prevents the final sqrt speedup.&#xA;&#xA;A stronger inhibition of the covert attack in the form of&#xA;requiring the least significant bits of the block timestamp&#xA;to be equal to a hash of the first 64-bytes of the header. This&#xA;would increase the collision space from 32 to 40 or more bits.&#xA;The root value could be required to meet a specific hash prefix&#xA;requirement in order to increase the computational work required&#xA;to try candidate roots. These change would be more disruptive and&#xA;there is no reason to believe that it is currently necessary.&#xA;&#xA;The proposed rule automatically sunsets. If it is no longer needed&#xA;due to the introduction of stronger rules or the acceptance of the&#xA;version-grinding form then there would be no reason to continue&#xA;with this requirement.  If it is still useful at the expiration&#xA;time the rule can simply be extended with a new softfork that&#xA;sets longer date ranges.&#xA;&#xA;This sun-setting avoids the accumulation of technical debt due&#xA;to retaining enforcement of this rule when it is no longer needed&#xA;without requiring a hard fork to remove it.&#xA;&#xA;== Overt attack ==&#xA;&#xA;The non-covert form can be trivially blocked by requiring that&#xA;the header version match the coinbase transaction version.&#xA;&#xA;This proposal does not include this block because this method&#xA;may become generally available without restriction in the future,&#xA;does not generally interfere with improvements in the protocol,&#xA;and because it is so easily detected that it could be blocked if&#xA;it becomes an issue in the future.&#xA;&#xA;==Backward compatibility==&#xA;&#xA;&#xA;==Implementation==&#xA;&#xA;&#xA;==Acknowledgments==&#xA;&#xA;&#xA;==Copyright==&#xA;&#xA;This document is placed in the public domain.</html></oembed>