<oembed><type>rich</type><version>1.0</version><author_name>npub1s4lj77xuzcu7wy04afcr487f0r3za0f8n2775xrpkld2sv639mjqsd44kw</author_name><author_url>https://nostr.ae/npub1s4lj77xuzcu7wy04afcr487f0r3za0f8n2775xrpkld2sv639mjqsd44kw</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2016-01-07&#xA;📝 Original message:Thanks, Ethan, that&#39;s helpful and I&#39;ll stop thinking that collision attacks&#xA;require 2^(n/2) memory...&#xA;&#xA;So can we quantify the incremental increase in security of SHA256(SHA256)&#xA;over RIPEMD160(SHA256) versus the incremental increase in security of&#xA;having a simpler implementation of segwitness?&#xA;&#xA;I&#39;m going to claim that the difference in the first case is very, very,&#xA;very small-- the risk of an implementation error caused by having multiple&#xA;ways of interpreting the segwitness hash in the scriptPubKey is much, much&#xA;greater.&#xA;&#xA;And even if there IS some risk of collision attack now or at some point in&#xA;the future, I claim that it is easy for wallets to mitigate that risk. In&#xA;fact, the principle of security in depth means wallets that don&#39;t&#xA;completely control the scriptPubKeys they&#39;re creating on behalf of users&#xA;SHOULD be coded to mitigate that risk (e.g. not allowing arbitrary data&#xA;around a user&#39;s public key in a Script so targeted substring attacks are&#xA;eliminated entirely).&#xA;&#xA;Purely from a security point of view, I think a single 20-byte segwitness&#xA;in the scriptPubKey is the best design.&#xA;&#34;Keep the design as simple and small as possible&#34;&#xA;https://www.securecoding.cert.org/confluence/plugins/servlet/mobile#content/view/2426&#xA;&#xA;Add in the implied capacity increase of smaller scriptPubKeys and I still&#xA;think it is a no-brainer.&#xA;&#xA;&#xA;On Thu, Jan 7, 2016 at 5:56 PM, Ethan Heilman &lt;eth3rs at gmail.com&gt; wrote:&#xA;&#xA;&gt; &gt;Ethan:  your algorithm will find two arbitrary values that collide. That&#xA;&gt; isn&#39;t useful as an attack in the context we&#39;re talking about here (both of&#xA;&gt; those values will be useless as coin destinations with overwhelming&#xA;&gt; probability).&#xA;&gt;&#xA;&gt; I&#39;m not sure exactly the properties you want here and determining&#xA;&gt; these properties is not an easy task, but the case is far worse than&#xA;&gt; just two random values. For instance: (a). with a small modification&#xA;&gt; my algorithm can also find collisions containing targeted substrings,&#xA;&gt; (b). length extension attacks are possible with RIPEMD160.&#xA;&gt;&#xA;&gt; (a). targeted cycles:&#xA;&gt;&#xA;&gt; target1 = &#34;str to prepend&#34;&#xA;&gt; target2 = &#34;str to end with&#34;&#xA;&gt;&#xA;&gt; seed = {0,1}^160&#xA;&gt; x = hash(seed)&#xA;&gt;&#xA;&gt; for i in 2^80:&#xA;&gt; ....x = hash(target1||x||target2)&#xA;&gt; x_final = x&#xA;&gt;&#xA;&gt; y = hash(tartget1||x_final||target2)&#xA;&gt;&#xA;&gt; for j in 2^80:&#xA;&gt; ....if y == x_final:&#xA;&gt; ........print &#34;cycle len: &#34;+j&#xA;&gt; ........break&#xA;&gt; ....y = hash(target1||y||target2)&#xA;&gt;&#xA;&gt; If a collision is found, the two colliding inputs must both start with&#xA;&gt; &#34;str to prepend&#34; and end with the phrase &#34;str to end with&#34;. As before&#xA;&gt; this only requires 2^81.5 computations and no real memory. For an&#xA;&gt; additional 2**80 an adversary has an good change of finding two&#xA;&gt; different targeted substrings which collide. Consider the case where&#xA;&gt; the attacker mixes the targeted strings with the hash output:&#xA;&gt;&#xA;&gt; hash(&#34;my name is=0x329482039483204324423&#34;+x[1]+&#34;, my favorite number&#xA;&gt; is=&#34;+x) where x[1] is the first bit of x.&#xA;&gt;&#xA;&gt; (b). length extension attacks&#xA;&gt;&#xA;&gt; Even if all the adversary can do is create two random values that&#xA;&gt; collide, you can append substrings to the input and get collisions.&#xA;&gt; Once you find two random values hash(x) = hash(y), you could use a&#xA;&gt; length extension attack on RIPEMD-160 to find hash(x||z) = hash(y||z).&#xA;&gt;&#xA;&gt; Now the bitcoin wiki says:&#xA;&gt; &#34;The padding scheme is identical to MD4 using Merkle–Damgård&#xA;&gt; strengthening to prevent length extension attacks.&#34;[1]&#xA;&gt;&#xA;&gt; Which is confusing to me because:&#xA;&gt;&#xA;&gt; 1. MD4 is vulnerable to length extension attacks&#xA;&gt; 2. Merkle–Damgård strengthening does not protect against length&#xA;&gt; extension: &#34;Indeed, we already pointed out that none of the 64&#xA;&gt; variants above can withstand the &#39;extension&#39; attack on the MAC&#xA;&gt; application, even with the Merkle-Damgard strengthening&#34; [2]&#xA;&gt; 3. RIPEMD-160 is vulnerable to length extension attacks, is Bitcoin&#xA;&gt; using a non-standard version of RIPEMD-160.&#xA;&gt;&#xA;&gt; RIPEMD160(SHA256()) does not protect against length extension attacks&#xA;&gt; on SHA256, but should protect RIPEMD-160 against length extension&#xA;&gt; attacks as RIPEMD-160 uses 512-bit message blocks. That being said we&#xA;&gt; should be very careful here. Research has been done that shows that&#xA;&gt; cascading the same hash function twice is weaker than using HMAC[3]. I&#xA;&gt; can&#39;t find results on cascading RIPEMD160(SHA256()).&#xA;&gt;&#xA;&gt; RIPEMD160(SHA256()) seems better than RIPEMD160() though, but security&#xA;&gt; should not rest on the notion that an attacker requires 2**80 memory,&#xA;&gt; many targeted collision attacks can work without much memory.&#xA;&gt;&#xA;&gt; [1]: https://en.bitcoin.it/wiki/RIPEMD-160&#xA;&gt; [2]: &#34;Merkle-Damgard Revisited: How to Construct a Hash Function&#34;&#xA;&gt; https://www.cs.nyu.edu/~puniya/papers/merkle.pdf&#xA;&gt; [3]: https://www.cs.nyu.edu/~dodis/ps/h-of-h.pdf&#xA;&gt;&#xA;&gt; On Thu, Jan 7, 2016 at 4:06 PM, Gavin Andresen via bitcoin-dev&#xA;&gt; &lt;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&gt; &gt; Maybe I&#39;m asking this question on the wrong mailing list:&#xA;&gt; &gt;&#xA;&gt; &gt; Matt/Adam: do you have some reason to think that RIPEMD160 will be broken&#xA;&gt; &gt; before SHA256?&#xA;&gt; &gt; And do you have some reason to think that they will be so broken that the&#xA;&gt; &gt; nested hash construction RIPEMD160(SHA256()) will be vulnerable?&#xA;&gt; &gt;&#xA;&gt; &gt; Adam: re: &#34;where to stop&#34;  :  I&#39;m suggesting we stop exactly at the&#xA;&gt; current&#xA;&gt; &gt; status quo, where we use RIPEMD160 for P2SH and P2PKH.&#xA;&gt; &gt;&#xA;&gt; &gt; Ethan:  your algorithm will find two arbitrary values that collide. That&#xA;&gt; &gt; isn&#39;t useful as an attack in the context we&#39;re talking about here (both&#xA;&gt; of&#xA;&gt; &gt; those values will be useless as coin destinations with overwhelming&#xA;&gt; &gt; probability).&#xA;&gt; &gt;&#xA;&gt; &gt; Dave: you described a first preimage attack, which is 2**160 cpu time&#xA;&gt; and no&#xA;&gt; &gt; storage.&#xA;&gt; &gt;&#xA;&gt; &gt;&#xA;&gt; &gt; --&#xA;&gt; &gt; --&#xA;&gt; &gt; Gavin Andresen&#xA;&gt; &gt;&#xA;&gt; &gt; _______________________________________________&#xA;&gt; &gt; bitcoin-dev mailing list&#xA;&gt; &gt; bitcoin-dev at lists.linuxfoundation.org&#xA;&gt; &gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt; &gt;&#xA;&gt;&#xA;&#xA;&#xA;&#xA;-- &#xA;--&#xA;Gavin Andresen&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20160107/39e4d3d6/attachment-0001.html&gt;</html></oembed>