From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 405A098C for ; Thu, 6 Apr 2017 12:02:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from APC01-PU1-obe.outbound.protection.outlook.com (mail-oln040092254026.outbound.protection.outlook.com [40.92.254.26]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5DBE9A4 for ; Thu, 6 Apr 2017 12:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9t5pBT59nlcwQ5Uv3OzKFuSvNTKIdYz+TgFMLBhfQ2Y=; b=NvLyBbmAmfTYOG0K2t3K7ziSTVXDWM1sY+ArdMlm/oDmtxu5pNk7Tgr0EphhWfTZoYXMKvFNmQAhErbJO6iEl6ngYLxs8wW/E9igN1v5QvPc/ZcFtwvNjxOA5kY+iz+h8zegCkOk509ELmc/GIQ8xl2RZkCclhjMKFyDwM0K/a+yJ4OEDE7NU4ryElEreNiOMFKQwF+KSDN3uQ3fRsnGwLSq0wxy/x8dg9FisCpNdK7zpEY+Jrkt25gfDh0yOy+x0SVXgAaPoWf+bkUzAVoM7BjZA6aO8B5DMIjmGv7Zwn2AXlAV4pY9bS36+Cjm6XJqNGlH8wcmjt9Z9qTPF+sa6A== Received: from PU1APC01FT039.eop-APC01.prod.protection.outlook.com (10.152.252.51) by PU1APC01HT240.eop-APC01.prod.protection.outlook.com (10.152.252.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1019.14; Thu, 6 Apr 2017 12:02:32 +0000 Received: from SINPR04MB1949.apcprd04.prod.outlook.com (10.152.252.58) by PU1APC01FT039.mail.protection.outlook.com (10.152.253.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.14 via Frontend Transport; Thu, 6 Apr 2017 12:02:32 +0000 Received: from SINPR04MB1949.apcprd04.prod.outlook.com ([fe80::478:e8f6:541:de19]) by SINPR04MB1949.apcprd04.prod.outlook.com ([fe80::478:e8f6:541:de19%18]) with mapi id 15.01.1019.014; Thu, 6 Apr 2017 12:02:32 +0000 From: Luv Khemani To: Gregory Maxwell , Bitcoin Protocol Discussion Thread-Topic: [bitcoin-dev] BIP proposal: Inhibiting a covert attack on the Bitcoin POW function Thread-Index: AQHSrlUf0BQ3K7r65ESU9KTSZsKj06G4NI5W Date: Thu, 6 Apr 2017 12:02:32 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: xiph.org; dkim=none (message not signed) header.d=none; xiph.org; dmarc=none action=none header.from=hotmail.com; x-incomingtopheadermarker: OriginalChecksum:F8AEFF9E2DA08F6451B5609D5B730D6D251AC4489FB53D56A0F02D8CA94A4331; UpperCasedChecksum:6C64495D57302D4D1727C8B364FA54435750B58F2CB48AE6120834D42A7F86E5; SizeAsReceived:8170; Count:42 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [V6H6LcmKJHgXvOGKUhURkKzvnLizTBGb] x-microsoft-exchange-diagnostics: 1; PU1APC01HT240; 5:wFdnSMGkFpVRtPqO/4o+lKo9hbl7xL+AWgZEtY9Ow678KLkKY4n28AegU8zZee/yK3fdw4DbOkG62fb2b0vmfwIIESVzSKoToTNm/3Twb36cl9/P0pnNSbvf2VAC/+fyyALWV6atbaeR2vM57+ygzA==; 24:PxFUKp2FsNYi5f/J1P/32uU4lSpJ8DzXlRO/NqfL2U1QfFvEGtvHW1AX2OC125FWlj/IfRBVAXCjRSaAopbypht5PycCPandW+9QItgnJbk=; 7:WoBz+A7k2NfA3u2CNoBR4CCmkBn25NcfBKOL+p2R3lBlHO5UiXW3O5kfO634tLlAWj9Bl8MP6buJoAWq2m7IYodjzR6ikL8RYYzdEK4zmC0e4h22mt8k6XujG/KwnzeW2ICguV9qbhdVI4EF7SWHverdwFEogV7IQ4bMbHca+Sudl+kJoAzYrQlkqagwZ3rDW1WlpnHwMH7yKUz8qk++JI60RMHmGejhIMAUv2ISkjTnegXIpghqHGLkPXi6b43V5DX1CJvI+nyIgPi13dpy93Eo8IxSb510fFT3kYANq3vyLHyzYHh7G5lcNQfpGWum x-incomingheadercount: 42 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:PU1APC01HT240; H:SINPR04MB1949.apcprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 9fcb4475-d70f-478b-b7ae-08d47ce4ce93 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031322274)(1603101448)(1601125374)(1701031045); SRVR:PU1APC01HT240; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:PU1APC01HT240; BCL:0; PCL:0; RULEID:; SRVR:PU1APC01HT240; x-forefront-prvs: 02698DF457 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_SINPR04MB19493BB6268FBC75F107C2BAC20D0SINPR04MB1949apcp_" MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2017 12:02:32.5476 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1APC01HT240 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,LOTS_OF_MONEY, RCVD_IN_DNSWL_NONE,T_MONEY_PERCENT autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Thu, 06 Apr 2017 12:10:10 +0000 Subject: Re: [bitcoin-dev] BIP proposal: Inhibiting a covert attack on the Bitcoin POW function X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Apr 2017 12:02:41 -0000 --_000_SINPR04MB19493BB6268FBC75F107C2BAC20D0SINPR04MB1949apcp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Greg Great work in discovering this! > A month ago I was explaining the attack on Bitcoin's SHA2 hashcash which is exploited by ASICBOOST and the various steps which could be used to block it in the network if it became a problem. Could you elaborate on why you consider ASICBOOST to be an attack? Attack h= ere implies ill-intent by the practitioner towards the network as a primary= motivating factor. Personally, i see this as a miner acting in his self-interest and had i bee= n a miner and knew about the covert method, i would use it too. So while i'm no fan of Bitmain/Jihan, i do not condone the vilification he = has received over the use of ASICBOOST to gain an edge. I know i'm griping over semantics, but in the current political climate, th= ey can be amplified by some to cause more drama than is healthy. Other thoughts: Several people have commented that blocking the use of this covert techniqu= e is unethical or "wrong". To quote Emin: >Taking action to block this is similar to the government taking measures t= o block Elon Musk's more efficient electric cars. Specifically prosecuting = a chosen miner, in the current political climate, would send a terrible mes= sage of absolute centralization in the hands of one particular developer gr= oup, and it would severely damage Bitcoin mining and the coin's security. This is a poor analogy and extremely misleading as the the basis for blocki= ng has nothing to do with efficiency and more to do with the following: 1) Blocking upgrades to the protocol that are deemed by the vast majority o= f the technical community/Bitcoin Businesses as being the best way forward 2) An advantage by a miner/group, especially one with majority hashrate is = a threat to decentralisation and security of the network and it is entirely= justifiable for devs to nullify such an advantage. You can see it as an arms race where miners are always finding ways to gain= an edge and devs trying to discover such edges and nullify them to level t= he playing field. This is how the game works and it should not be viewed in a political angle= or taken personally by either party. Miners are acting in their self-inter= est and Devs are trying to secure the network and increase decentralisation= . Both are doing their job. Just by revealing the info, you have effectively ensured the nullification = of any edge enjoyed by miners using the covert technique in the medium to l= ong term. Either miners not using the technique will all start signalling for SegWit = to nullify their competitors edge or they will procure hardware which has t= he edge. Given the threat to decentralisation, i also believe UASF will gain more mo= mentum as users seek to protect the network from further miner centralisati= on. ________________________________ From: bitcoin-dev-bounces@lists.linuxfoundation.org on behalf of Gregory Maxwell via bitcoin-dev Sent: Thursday, April 6, 2017 5:37 AM To: Bitcoin Dev Subject: [bitcoin-dev] BIP proposal: Inhibiting a covert attack on the Bitc= oin POW function A month ago I was explaining the attack on Bitcoin's SHA2 hashcash which is exploited by ASICBOOST and the various steps which could be used to block it in the network if it became a problem. While most discussion of ASICBOOST has focused on the overt method of implementing it, there also exists a covert method for using it. As I explained one of the approaches to inhibit covert ASICBOOST I realized that my words were pretty much also describing the SegWit commitment structure. The authors of the SegWit proposal made a specific effort to not be incompatible with any mining system and, in particular, changed the design at one point to accommodate mining chips with forced payout addresses. Had there been awareness of exploitation of this attack an effort would have been made to avoid incompatibility-- simply to separate concerns. But the best methods of implementing the covert attack are significantly incompatible with virtually any method of extending Bitcoin's transaction capabilities; with the notable exception of extension blocks (which have their own problems). An incompatibility would go a long way to explain some of the more inexplicable behavior from some parties in the mining ecosystem so I began looking for supporting evidence. Reverse engineering of a particular mining chip has demonstrated conclusively that ASICBOOST has been implemented in hardware. On that basis, I offer the following BIP draft for discussion. This proposal does not prevent the attack in general, but only inhibits covert forms of it which are incompatible with improvements to the Bitcoin protocol. I hope that even those of us who would strongly prefer that ASICBOOST be blocked completely can come together to support a protective measure that separates concerns by inhibiting the covert use of it that potentially blocks protocol improvements. The specific activation height is something I currently don't have a strong opinion, so I've left it unspecified for the moment.
  BIP: TBD
  Layer: Consensus
  Title: Inhibiting a covert attack on the Bitcoin POW function
  Author: Greg Maxwell 
  Status: Draft
  Type: Standards Track
  Created: 2016-04-05
  License: PD
=3D=3DAbstract=3D=3D This proposal inhibits the covert exploitation of a known vulnerability in Bitcoin Proof of Work function. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. =3D=3DMotivation=3D=3D Due to a design oversight the Bitcoin proof of work function has a potentia= l attack which can allow an attacking miner to save up-to 30% of their energy costs (though closer to 20% is more likely due to implementation overheads)= . Timo Hanke and Sergio Demian Lerner claim to hold a patent on this attack, which they have so far not licensed for free and open use by the public. They have been marketing their patent licenses under the trade-name ASICBOOST. The document takes no position on the validity or enforceabilit= y of the patent. There are two major ways of exploiting the underlying vulnerability: One obvious way which is highly detectable and is not in use on the network today and a covert way which has significant interaction and potential interference with the Bitcoin protocol. The covert mechanism is not easily detected except through its interference with the protocol. In particular, the protocol interactions of the covert method can block the implementation of virtuous improvements such as segregated witness. Exploitation of this vulnerability could result in payoff of as much as $100 million USD per year at the time this was written (Assuming at 50% hash-power miner was gaining a 30% power advantage and that mining was otherwise at profit equilibrium). This could have a phenomenal centralizing effect by pushing mining out of profitability for all other participants, and the income from secretly using this optimization could be abused to significantly distort the Bitcoin ecosystem in order to preserve the advantage. Reverse engineering of a mining ASIC from a major manufacture has revealed that it contains an undocumented, undisclosed ability to make use of this attack. (The parties claiming to hold a patent on this technique were completely unaware of this use.) On the above basis the potential for covert exploitation of this vulnerability and the resulting inequality in the mining process and interference with useful improvements presents a clear and present danger to the Bitcoin system which requires a response. =3D=3DBackground=3D=3D The general idea of this attack is that SHA2-256 is a merkle damgard hash function which consumes 64 bytes of data at a time. The Bitcoin mining process repeatedly hashes an 80-byte 'block header' whil= e incriminating a 32-bit nonce which is at the end of this header data. This means that the processing of the header involves two runs of the compressio= n function run-- one that consumes the first 64 bytes of the header and a second which processes the remaining 16 bytes and padding. The initial 'message expansion' operations in each step of the SHA2-256 function operate exclusively on that step's 64-bytes of input with no influence from prior data that entered the hash. Because of this if a miner is able to prepare a block header with multiple distinct first 64-byte chunks but identical 16-byte second chunks they can reuse the computation of the initial expansion for multiple trials. This reduces power consumption. There are two broad ways of making use of this attack. The obvious way is to try candidates with different version numbers. Beyond upsetting the soft-fork detection logic in Bitcoin nodes this has little negative effect but it is highly conspicuous and easily blocked. The other method is based on the fact that the merkle root committing to the transactions is contained in the first 64-bytes except for the last 4 bytes of it. If the miner finds multiple candidate root values which have the same final 32-bit then they can use the attack. To find multiple roots with the same trailing 32-bits the miner can use efficient collision finding mechanism which will find a match with as little as 2^16 candidate roots expected, 2^24 operations to find a 4-way hit, though low memory approaches require more computation. An obvious way to generate different candidates is to grind the coinbase extra-nonce but for non-empty blocks each attempt will require 13 or so additional sha2 runs which is very inefficient. This inefficiency can be avoided by computing a sqrt number of candidates of the left side of the hash tree (e.g. using extra nonce grinding) then an additional sqrt number of candidates of the right side of the tree using transaction permutation or substitution of a small number of transactions. All combinations of the left and right side are then combined with only a single hashing operation virtually eliminating all tree related overhead. With this final optimization finding a 4-way collision with a moderate amount of memory requires ~2^24 hashing operations instead of the >2^28 operations that would be require for extra-nonce grinding which would substantially erode the benefit of the attack. It is this final optimization which this proposal blocks. =3D=3DNew consensus rule=3D=3D Beginning block X and until block Y the coinbase transaction of each block MUST either contain a BIP-141 segwit commitment or a correct WTXID commitment with ID 0xaa21a9ef. (See BIP-141 "Commitment structure" for details) Existing segwit using miners are automatically compatible with this proposal. Non-segwit miners can become compatible by simply including an additional output matching a default commitment value returned as part of getblocktemplate. Miners SHOULD NOT automatically discontinue the commitment at the expiration height. =3D=3DDiscussion=3D=3D The commitment in the left side of the tree to all transactions in the right side completely prevents the final sqrt speedup. A stronger inhibition of the covert attack in the form of requiring the least significant bits of the block timestamp to be equal to a hash of the first 64-bytes of the header. This would increase the collision space from 32 to 40 or more bits. The root value could be required to meet a specific hash prefix requirement in order to increase the computational work required to try candidate roots. These change would be more disruptive and there is no reason to believe that it is currently necessary. The proposed rule automatically sunsets. If it is no longer needed due to the introduction of stronger rules or the acceptance of the version-grinding form then there would be no reason to continue with this requirement. If it is still useful at the expiration time the rule can simply be extended with a new softfork that sets longer date ranges. This sun-setting avoids the accumulation of technical debt due to retaining enforcement of this rule when it is no longer needed without requiring a hard fork to remove it. =3D=3D Overt attack =3D=3D The non-covert form can be trivially blocked by requiring that the header version match the coinbase transaction version. This proposal does not include this block because this method may become generally available without restriction in the future, does not generally interfere with improvements in the protocol, and because it is so easily detected that it could be blocked if it becomes an issue in the future. =3D=3DBackward compatibility=3D=3D =3D=3DImplementation=3D=3D =3D=3DAcknowledgments=3D=3D =3D=3DCopyright=3D=3D This document is placed in the public domain. _______________________________________________ bitcoin-dev mailing list bitcoin-dev@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev bitcoin-dev -- Bitcoin Protocol Discussion - Linux Foundation lists.linuxfoundation.org Bitcoin development and protocol discussion. This list is lightly moderated= . - No offensive posts, no personal attacks. - Posts must concern developme= nt of bitcoin ... --_000_SINPR04MB19493BB6268FBC75F107C2BAC20D0SINPR04MB1949apcp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi Greg


Great work in discovering this!


A month ago I was explaining the attack on Bitcoin's= SHA2 hashcash which
is exploited by ASICBOOST and the various steps which could be us= ed to
block it in the network if it became a problem.


Could you elaborate on why you consider ASICBOOST to be an attack? Attack here implies ill-intent by the practitioner towards the networ= k as a primary motivating factor.

Personally, i see this as a miner acting in his self-interest and had i been a miner and knew about the covert method, i would use it too.

So while i'm no fan of Bitmain/Jihan, i do not condone the vilification = he has received over the use of ASICBOOST to gain an edge.

I know i'm griping over semantics, but in the current political climate,= they can be amplified by some to cause more drama than is healthy.


Other thoughts:


Several people have commented that blocking the use of this covert techniqu= e is unethical or "wrong".
To quote Emin:

>Taking action to block this is similar to the gove= rnment taking measures to block Elon Musk's more efficient electric cars. S= pecifically prosecuting a chosen miner, in the current political climate, w= ould send a terrible message of absolute centralization in the hands of one particular developer group, and it woul= d severely damage Bitcoin mining and the coin's security.

This is a poor analogy and extremely misleading as the the basis for b= locking has nothing to do with efficiency and more to do with the following= :

1) Blocking upgrades to the protocol that are deemed by the vast major= ity of the technical community/Bitcoin Businesses as being the best wa= y forward

2) An advantage by a miner/group, especially one with majority hashrat= e is a threat to decentralisation and security of the network and it is ent= irely justifiable for devs to nullify such an advantage.
You can see it as an arms race where miners are always findi= ng ways to gain an edge and devs trying to discover such edges and nullify = them to level the playing field. 
This is how the game works and it should not be viewed in a political = angle or taken personally by either party. Miners are acting in their self-= interest and Devs are trying to secure the network and increase decentralis= ation.
Both are doing their job.

Just by revealing the info, you have effectively ensured the null= ification of any edge enjoyed by miners using the covert techniqu= e in the medium to long term.
Either miners not using the technique will all start signalling for Se= gWit to nullify their competitors edge or they will procure hardware w= hich has the edge. 

Given the threat to decentralisation, i also believe UASF will gain mo= re momentum as users seek to protect the network from further miner central= isation.



From: bitcoin-dev-bounces= @lists.linuxfoundation.org <bitcoin-dev-bounces@lists.linuxfoundation.or= g> on behalf of Gregory Maxwell via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org>
Sent: Thursday, April 6, 2017 5:37 AM
To: Bitcoin Dev
Subject: [bitcoin-dev] BIP proposal: Inhibiting a covert attack on t= he Bitcoin POW function
 
A month ago I was explaining the attack on Bitcoin= 's SHA2 hashcash which
is exploited by ASICBOOST and the various steps which could be used to
block it in the network if it became a problem.

While most discussion of ASICBOOST has focused on the overt method
of implementing it, there also exists a covert method for using it.

As I explained one of the approaches to inhibit covert ASICBOOST I
realized that my words were pretty much also describing the SegWit
commitment structure.

The authors of the SegWit proposal made a specific effort to not be
incompatible with any mining system and, in particular, changed the
design at one point to accommodate mining chips with forced payout
addresses.

Had there been awareness of exploitation of this attack an effort
would have been made to avoid incompatibility-- simply to separate
concerns.  But the best methods of implementing the covert attack
are significantly incompatible with virtually any method of
extending Bitcoin's transaction capabilities; with the notable
exception of extension blocks (which have their own problems).

An incompatibility would go a long way to explain some of the
more inexplicable behavior from some parties in the mining
ecosystem so I began looking for supporting evidence.

Reverse engineering of a particular mining chip has demonstrated
conclusively that ASICBOOST has been implemented
in hardware.

On that basis, I offer the following BIP draft for discussion.
This proposal does not prevent the attack in general, but only
inhibits covert forms of it which are incompatible with
improvements to the Bitcoin protocol.

I hope that even those of us who would strongly prefer that
ASICBOOST be blocked completely can come together to support
a protective measure that separates concerns by inhibiting
the covert use of it that potentially blocks protocol improvements.

The specific activation height is something I currently don't have
a strong opinion, so I've left it unspecified for the moment.

<pre>
  BIP: TBD
  Layer: Consensus
  Title: Inhibiting a covert attack on the Bitcoin POW function
  Author: Greg Maxwell <greg@xiph.org>
  Status: Draft
  Type: Standards Track
  Created: 2016-04-05
  License: PD
</pre>

=3D=3DAbstract=3D=3D

This proposal inhibits the covert exploitation of a known
vulnerability in Bitcoin Proof of Work function.

The key words "MUST", "MUST NOT", "REQUIRED",= "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "= MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119.

=3D=3DMotivation=3D=3D

Due to a design oversight the Bitcoin proof of work function has a potentia= l
attack which can allow an attacking miner to save up-to 30% of their energy=
costs (though closer to 20% is more likely due to implementation overheads)= .

Timo Hanke and Sergio Demian Lerner claim to hold a patent on this attack,<= br> which they have so far not licensed for free and open use by the public. They have been marketing their patent licenses under the trade-name
ASICBOOST.  The document takes no position on the validity or enforcea= bility
of the patent.

There are two major ways of exploiting the underlying vulnerability: One obvious way which is highly detectable and is not in use on the network
today and a covert way which has significant interaction and potential
interference with the Bitcoin protocol.  The covert mechanism is not easily detected except through its interference with the protocol.

In particular, the protocol interactions of the covert method can block the=
implementation of virtuous improvements such as segregated witness.

Exploitation of this vulnerability could result in payoff of as much as
$100 million USD per year at the time this was written (Assuming at
50% hash-power miner was gaining a 30% power advantage and that mining
was otherwise at profit equilibrium).  This could have a phenomenal centralizing effect by pushing mining out of profitability for all
other participants, and the income from secretly using this
optimization could be abused to significantly distort the Bitcoin
ecosystem in order to preserve the advantage.

Reverse engineering of a mining ASIC from a major manufacture has
revealed that it contains an undocumented, undisclosed ability
to make use of this attack. (The parties claiming to hold a
patent on this technique were completely unaware of this use.)

On the above basis the potential for covert exploitation of this
vulnerability and the resulting inequality in the mining process
and interference with useful improvements presents a clear and
present danger to the Bitcoin system which requires a response.

=3D=3DBackground=3D=3D

The general idea of this attack is that SHA2-256 is a merkle damgard hash function which consumes 64 bytes of data at a time.

The Bitcoin mining process repeatedly hashes an 80-byte 'block header' whil= e
incriminating a 32-bit nonce which is at the end of this header data. This<= br> means that the processing of the header involves two runs of the compressio= n
function run-- one that consumes the first 64 bytes of the header and a
second which processes the remaining 16 bytes and padding.

The initial 'message expansion' operations in each step of the SHA2-256
function operate exclusively on that step's 64-bytes of input with no
influence from prior data that entered the hash.

Because of this if a miner is able to prepare a block header with
multiple distinct first 64-byte chunks but identical 16-byte
second chunks they can reuse the computation of the initial
expansion for multiple trials. This reduces power consumption.

There are two broad ways of making use of this attack. The obvious
way is to try candidates with different version numbers.  Beyond
upsetting the soft-fork detection logic in Bitcoin nodes this has
little negative effect but it is highly conspicuous and easily
blocked.

The other method is based on the fact that the merkle root
committing to the transactions is contained in the first 64-bytes
except for the last 4 bytes of it.  If the miner finds multiple
candidate root values which have the same final 32-bit then they
can use the attack.

To find multiple roots with the same trailing 32-bits the miner can
use efficient collision finding mechanism which will find a match
with as little as 2^16 candidate roots expected, 2^24 operations to
find a 4-way hit, though low memory approaches require more
computation.

An obvious way to generate different candidates is to grind the
coinbase extra-nonce but for non-empty blocks each attempt will
require 13 or so additional sha2 runs which is very inefficient.

This inefficiency can be avoided by computing a sqrt number of
candidates of the left side of the hash tree (e.g. using extra
nonce grinding) then an additional sqrt number of candidates of
the right  side of the tree using transaction permutation or
substitution of a small number of transactions.  All combinations
of the left and right side are then combined with only a single
hashing operation virtually eliminating all tree related
overhead.

With this final optimization finding a 4-way collision with a
moderate amount of memory requires ~2^24 hashing operations
instead of the >2^28 operations that would be require for
extra-nonce  grinding which would substantially erode the
benefit of the attack.

It is this final optimization which this proposal blocks.

=3D=3DNew consensus rule=3D=3D

Beginning block X and until block Y the coinbase transaction of
each block MUST either contain a BIP-141 segwit commitment or a
correct WTXID commitment with ID 0xaa21a9ef.

(See BIP-141 "Commitment structure" for details)

Existing segwit using miners are automatically compatible with
this proposal. Non-segwit miners can become compatible by simply
including an additional output matching a default commitment
value returned as part of getblocktemplate.

Miners SHOULD NOT automatically discontinue the commitment
at the expiration height.

=3D=3DDiscussion=3D=3D

The commitment in the left side of the tree to all transactions
in the right side completely prevents the final sqrt speedup.

A stronger inhibition of the covert attack in the form of
requiring the least significant bits of the block timestamp
to be equal to a hash of the first 64-bytes of the header. This
would increase the collision space from 32 to 40 or more bits.
The root value could be required to meet a specific hash prefix
requirement in order to increase the computational work required
to try candidate roots. These change would be more disruptive and
there is no reason to believe that it is currently necessary.

The proposed rule automatically sunsets. If it is no longer needed
due to the introduction of stronger rules or the acceptance of the
version-grinding form then there would be no reason to continue
with this requirement.  If it is still useful at the expiration
time the rule can simply be extended with a new softfork that
sets longer date ranges.

This sun-setting avoids the accumulation of technical debt due
to retaining enforcement of this rule when it is no longer needed
without requiring a hard fork to remove it.

=3D=3D Overt attack =3D=3D

The non-covert form can be trivially blocked by requiring that
the header version match the coinbase transaction version.

This proposal does not include this block because this method
may become generally available without restriction in the future,
does not generally interfere with improvements in the protocol,
and because it is so easily detected that it could be blocked if
it becomes an issue in the future.

=3D=3DBackward compatibility=3D=3D


=3D=3DImplementation=3D=3D


=3D=3DAcknowledgments=3D=3D


=3D=3DCopyright=3D=3D

This document is placed in the public domain.
_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.or= g/mailman/listinfo/bitcoin-dev
lists.linuxfoundation.org
Bitcoin development and protocol discussion. This list is lightly moderated= . - No offensive posts, no personal attacks. - Posts must concern developme= nt of bitcoin ...


--_000_SINPR04MB19493BB6268FBC75F107C2BAC20D0SINPR04MB1949apcp_--