<div dir="ltr">I&#39;m hoisting this from some private feedback I sent on the segregated witness BIP:<div><br></div><div>I said:</div><div><br></div><div><span style="color:rgb(80,0,80);font-size:12.8px">&quot;I&#39;d also use RIPEMD160(SHA256()) as the hash function and save the 12 bytes-- a successful preimage attack against that ain&#39;t gonna happen before we&#39;re all dead. I&#39;m probably being dense, but I just don&#39;t see how a collision attack is relevant here.&quot;</span></div><div><font color="#500050"><span style="font-size:12.8px"><br></span></font></div><div><font color="#500050"><span style="font-size:12.8px">Pieter responded:</span></font></div><div><p dir="ltr" style="color:rgb(80,0,80);font-size:12.8px">&quot;The problem case is where someone in a contract setup shows you a script, which you accept as being a payment to yourself. An attacker could use a collision attack to construct scripts with identical hashes, only one of which does have the property you want, and steal coins.</p><p dir="ltr" style="color:rgb(80,0,80);font-size:12.8px">So you really want collision security, and I don&#39;t think 80 bits is something we should encourage for that. Normal pubkey hashes don&#39;t have that problem, as they can&#39;t be constructed to pay to you.&quot;</p></div><div><font color="#500050"><span style="font-size:12.8px">... but I&#39;m unconvinced:</span></font></div><div><font color="#500050"><span style="font-size:12.8px"><br></span></font></div><div><font color="#500050"><span style="font-size:12.8px">&quot;</span></font><span style="font-size:12.8px">But it is trivial for contract wallets to protect against collision attacks-- if you give me a script that is &quot;gavin_pubkey CHECKSIG arbitrary_data OP_DROP&quot; with &quot;I promise I&#39;m not trying to rip you off, just ignore that arbitrary data&quot; a wallet can just refuse. Even more likely, a contract wallet won&#39;t even recognize that as a pay-to-gavin transaction.</span><div class="gmail_quote" style="font-size:12.8px"><div><br></div><div>I suppose it could be looking for some form of &quot;gavin_pubkey somebody_else_pubkey CHECKMULTISIG ... with the attacker using somebody_else_pubkey to force the collision, but, again, trivial contract protocol tweaks (&quot;send along a proof you have the private key corresponding to the public key&quot; or &quot;everybody pre-commits pubkeys they&#39;ll use at protocol start&quot;) would protect against that.</div><div><br></div><div>Adding an extra 12 bytes to every segwit to prevent an attack that takes 2^80 computation and 2^80 storage, is unlikely to be a problem in practice, and is trivial to protect against is the wrong tradeoff to make.&quot;</div><div><br></div><div>20 bytes instead of 32 bytes is a savings of almost 40%, which is significant.</div><div><br></div><div>The general question I&#39;d like to raise on this list is:</div><div><br></div><div>Should we be worried, today, about collision attacks against RIPEMD160 (our 160-bit hash)?</div><div><br></div><div>Mounting a successful brute-force collision attack would require at least O(2^80) CPU, which is kinda-sorta feasible (Pieter pointed out that Bitcoin POW has computed more SHA256 hashes than that). But it also requires O(2^80) storage, which is utterly infeasible (there is something on the order of 2^35 bytes of storage in the entire world).  Even assuming doubling every single year (faster than Moore&#39;s Law), we&#39;re four decades away from an attacker with THE ENTIRE WORLD&#39;s storage capacity being able to mount a collision attack.</div><div><br></div></div><div><br></div><div>References: </div><div><br></div><div><a href="https://en.wikipedia.org/wiki/Collision_attack">https://en.wikipedia.org/wiki/Collision_attack</a><br></div><div><br></div><div><a href="https://vsatglobalseriesblog.wordpress.com/2013/06/21/in-2013-the-amount-of-data-generated-worldwide-will-reach-four-zettabytes/">https://vsatglobalseriesblog.wordpress.com/2013/06/21/in-2013-the-amount-of-data-generated-worldwide-will-reach-four-zettabytes/</a><br></div><div><br></div><div><br></div>-- <br><div class="gmail_signature">--<br>Gavin Andresen<br></div><div class="gmail_signature"><br></div>
</div></div>