<oembed><type>rich</type><version>1.0</version><author_name>npub1gaszwl7qd0tjmnwcaamgzzgsmzzjlvle6kz0td66pwa8z69vsxsqxgac47</author_name><author_url>https://nostr.ae/npub1gaszwl7qd0tjmnwcaamgzzgsmzzjlvle6kz0td66pwa8z69vsxsqxgac47</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2016-01-07&#xA;📝 Original message:Based on current GH/s count of 775,464,121 Bitcoin tests 2^80 every 19 days.&#xA;log2(775464121*(1000*1000*1000*60*60*24*19)) = ~80.07&#xA;&#xA;I don&#39;t fully understand the security model of segwit, so my analysis&#xA;will assume that any collision is bad.&#xA;&#xA;&gt;But it also requires O(2^80) storage, which is utterly infeasible&#xA;&#xA;You don&#39;t store all 2^80 previous hashes, instead you just hash a seed&#xA;value 2^80 times, then look for a cycle.&#xA;&#xA;seed = {0,1}^160&#xA;x = hash(seed)&#xA;&#xA;for i in 2^80:&#xA;....x = hash(x)&#xA;x_final = x&#xA;&#xA;y = hash(x_final)&#xA;&#xA;for j in 2^80:&#xA;....if y == x_final:&#xA;........print &#34;cycle len: &#34;+j&#xA;........break&#xA;....y = hash(y)&#xA;&#xA;If at any point x collides with a prior value of x it will form a&#xA;cycle. Thus y will also cycle and collide with x_final. j gives you&#xA;the cycle length, which allows you find the collision:&#xA;hash^(2^80-j)(seed) == hash^(j)(hash^(2^80-j)(seed)).&#xA;&#xA;Worst case:&#xA;First loop costs 2**80, second loop costs 2**80=j, finding the&#xA;colliding value is 2**80. Total cost 2**80+2**80+2**80 = 2**81.5 and&#xA;requires storing less than a kilobyte.&#xA;&#xA;This is a toy example, does not exploit parallelism, time memory trade&#xA;offs, can be easily made better, etc...&#xA;&#xA;On Thu, Jan 7, 2016 at 2:02 PM, Gavin Andresen via bitcoin-dev&#xA;&lt;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&gt; I&#39;m hoisting this from some private feedback I sent on the segregated&#xA;&gt; witness BIP:&#xA;&gt;&#xA;&gt; I said:&#xA;&gt;&#xA;&gt; &#34;I&#39;d also use RIPEMD160(SHA256()) as the hash function and save the 12&#xA;&gt; bytes-- a successful preimage attack against that ain&#39;t gonna happen before&#xA;&gt; we&#39;re all dead. I&#39;m probably being dense, but I just don&#39;t see how a&#xA;&gt; collision attack is relevant here.&#34;&#xA;&gt;&#xA;&gt; Pieter responded:&#xA;&gt;&#xA;&gt; &#34;The problem case is where someone in a contract setup shows you a script,&#xA;&gt; which you accept as being a payment to yourself. An attacker could use a&#xA;&gt; collision attack to construct scripts with identical hashes, only one of&#xA;&gt; which does have the property you want, and steal coins.&#xA;&gt;&#xA;&gt; So you really want collision security, and I don&#39;t think 80 bits is&#xA;&gt; something we should encourage for that. Normal pubkey hashes don&#39;t have that&#xA;&gt; problem, as they can&#39;t be constructed to pay to you.&#34;&#xA;&gt;&#xA;&gt; ... but I&#39;m unconvinced:&#xA;&gt;&#xA;&gt; &#34;But it is trivial for contract wallets to protect against collision&#xA;&gt; attacks-- if you give me a script that is &#34;gavin_pubkey CHECKSIG&#xA;&gt; arbitrary_data OP_DROP&#34; with &#34;I promise I&#39;m not trying to rip you off, just&#xA;&gt; ignore that arbitrary data&#34; a wallet can just refuse. Even more likely, a&#xA;&gt; contract wallet won&#39;t even recognize that as a pay-to-gavin transaction.&#xA;&gt;&#xA;&gt; I suppose it could be looking for some form of &#34;gavin_pubkey&#xA;&gt; somebody_else_pubkey CHECKMULTISIG ... with the attacker using&#xA;&gt; somebody_else_pubkey to force the collision, but, again, trivial contract&#xA;&gt; protocol tweaks (&#34;send along a proof you have the private key corresponding&#xA;&gt; to the public key&#34; or &#34;everybody pre-commits pubkeys they&#39;ll use at protocol&#xA;&gt; start&#34;) would protect against that.&#xA;&gt;&#xA;&gt; Adding an extra 12 bytes to every segwit to prevent an attack that takes&#xA;&gt; 2^80 computation and 2^80 storage, is unlikely to be a problem in practice,&#xA;&gt; and is trivial to protect against is the wrong tradeoff to make.&#34;&#xA;&gt;&#xA;&gt; 20 bytes instead of 32 bytes is a savings of almost 40%, which is&#xA;&gt; significant.&#xA;&gt;&#xA;&gt; The general question I&#39;d like to raise on this list is:&#xA;&gt;&#xA;&gt; Should we be worried, today, about collision attacks against RIPEMD160 (our&#xA;&gt; 160-bit hash)?&#xA;&gt;&#xA;&gt; Mounting a successful brute-force collision attack would require at least&#xA;&gt; O(2^80) CPU, which is kinda-sorta feasible (Pieter pointed out that Bitcoin&#xA;&gt; POW has computed more SHA256 hashes than that). But it also requires O(2^80)&#xA;&gt; storage, which is utterly infeasible (there is something on the order of&#xA;&gt; 2^35 bytes of storage in the entire world).  Even assuming doubling every&#xA;&gt; single year (faster than Moore&#39;s Law), we&#39;re four decades away from an&#xA;&gt; attacker with THE ENTIRE WORLD&#39;s storage capacity being able to mount a&#xA;&gt; collision attack.&#xA;&gt;&#xA;&gt;&#xA;&gt; References:&#xA;&gt;&#xA;&gt; https://en.wikipedia.org/wiki/Collision_attack&#xA;&gt;&#xA;&gt; https://vsatglobalseriesblog.wordpress.com/2013/06/21/in-2013-the-amount-of-data-generated-worldwide-will-reach-four-zettabytes/&#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>