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