<oembed><type>rich</type><version>1.0</version><author_name>npub1e46n428mcyfwznl7nlsf6d3s7rhlwm9x3cmkuqzt3emmdpadmkaqqjxmcu</author_name><author_url>https://nostr.ae/npub1e46n428mcyfwznl7nlsf6d3s7rhlwm9x3cmkuqzt3emmdpadmkaqqjxmcu</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2016-01-07&#xA;📝 Original message:So just because other attacks are possible we should weaken the crypto&#xA;we use? You may feel comfortable weakening crypto used to protect a few&#xA;billion dollars of other peoples&#39; money, but I dont.&#xA;&#xA;On 01/07/16 23:39, Gavin Andresen via bitcoin-dev wrote:&#xA;&gt; Thanks, Ethan, that&#39;s helpful and I&#39;ll stop thinking that collision&#xA;&gt; attacks require 2^(n/2) memory...&#xA;&gt; &#xA;&gt; So can we quantify the incremental increase in security of&#xA;&gt; SHA256(SHA256) over RIPEMD160(SHA256) versus the incremental increase in&#xA;&gt; security of having a simpler implementation of segwitness?&#xA;&gt; &#xA;&gt; I&#39;m going to claim that the difference in the first case is very, very,&#xA;&gt; very small-- the risk of an implementation error caused by having&#xA;&gt; multiple ways of interpreting the segwitness hash in the scriptPubKey is&#xA;&gt; much, much greater.&#xA;&gt; &#xA;&gt; And even if there IS some risk of collision attack now or at some point&#xA;&gt; in the future, I claim that it is easy for wallets to mitigate that&#xA;&gt; risk. In fact, the principle of security in depth means wallets that&#xA;&gt; don&#39;t completely control the scriptPubKeys they&#39;re creating on behalf of&#xA;&gt; users SHOULD be coded to mitigate that risk (e.g. not allowing arbitrary&#xA;&gt; data around a user&#39;s public key in a Script so targeted substring&#xA;&gt; attacks are eliminated entirely).&#xA;&gt; &#xA;&gt; Purely from a security point of view, I think a single 20-byte&#xA;&gt; segwitness in the scriptPubKey is the best design.&#xA;&gt; &#34;Keep the design as simple and small as possible&#34;&#xA;&gt; https://www.securecoding.cert.org/confluence/plugins/servlet/mobile#content/view/2426&#xA;&gt; &#xA;&gt; Add in the implied capacity increase of smaller scriptPubKeys and I&#xA;&gt; still think it is a no-brainer.&#xA;&gt; &#xA;&gt; &#xA;&gt; On Thu, Jan 7, 2016 at 5:56 PM, Ethan Heilman &lt;eth3rs at gmail.com&#xA;&gt; &lt;mailto:eth3rs at gmail.com&gt;&gt; wrote:&#xA;&gt; &#xA;&gt;     &gt;Ethan:  your algorithm will find two arbitrary values that collide. That isn&#39;t useful as an attack in the context we&#39;re talking about here (both of those values will be useless as coin destinations with overwhelming 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&#xA;&gt;     &lt;mailto:bitcoin-dev at lists.linuxfoundation.org&gt;&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&#xA;&gt;     broken&#xA;&gt;     &gt; before SHA256?&#xA;&gt;     &gt; And do you have some reason to think that they will be so broken&#xA;&gt;     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&#xA;&gt;     the 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&#xA;&gt;     collide. That&#xA;&gt;     &gt; isn&#39;t useful as an attack in the context we&#39;re talking about here&#xA;&gt;     (both 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&#xA;&gt;     time 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;     &lt;mailto:bitcoin-dev at lists.linuxfoundation.org&gt;&#xA;&gt;     &gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt;     &gt;&#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt; &#xA;&gt; -- &#xA;&gt; --&#xA;&gt; Gavin Andresen&#xA;&gt; &#xA;&gt; &#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&#xA;&gt;</html></oembed>