Re:Show HN: SHA-256 explained step-by-step visually
by colejohnson66 on Monday February 07, 2022 @09:55AM
(#30245642)
One could even feed the hash back into itself to get a different result each time
[ Parent
| on HN ]
Re:Show HN: SHA-256 explained step-by-step visually
by em3rgent0rdr on Monday February 07, 2022 @10:01AM
(#30245727)
how long would the cycle last before it starts repeating?
Re:Show HN: SHA-256 explained step-by-step visually
by tromp on Monday February 07, 2022 @10:13AM
(#30245879)
On the order of 2^256 steps, if SHA-256 behaves randomly, since the largest cycle in a random permutation on N elements has expected length ~ 0.62 * N.
Re:Show HN: SHA-256 explained step-by-step visually
by pbsd on Monday February 07, 2022 @04:13PM
(#30251253)
SHA-256 is not a permutation; the expected cycle length is ~2^128. It's how collisions are (generically) found.
Re:Show HN: SHA-256 explained step-by-step visually
by colejohnson66 on Monday February 07, 2022 @05:13PM
(#30252101)
Pigeonhole principle?
Re:Show HN: SHA-256 explained step-by-step visually
by pbsd on Monday February 07, 2022 @05:46PM
(#30252484)
Each new output value i can collide with output 1, 2, ..., i-1. So the collision probability of iteration i is (i-1)/2^256. Adding all of the iterations up you have 1/2^256 + 2/2^256 + ... + (i-1)/2^256 = 0.5 i (i-1)/2^256 which approaches 1/2 as you get to 2^128.
In reality you use some variant of Rho which does not store every previous value but uses something like Floyd's cycle detection or distinguished points and requires minimal storage, at the cost of some extra hash computations but still on the order of 2^128.
Re:Show HN: SHA-256 explained step-by-step visually
by dragontamer on Monday February 07, 2022 @05:47PM
(#30252500)
This situation calls for Birthday paradox, not pigeon hole.
Re:Show HN: SHA-256 explained step-by-step visually
by MayeulC on Monday February 07, 2022 @10:43AM
(#30246341)
Then wouldn't that be 0.62*2^256, closer to 2^255 ? Not that it makes a notable difference: at 1 fs per step (1000 GHz, or 1 TH/s), that would take about 4.5e65 years to happen. The universe is only about 1e10 years old...