4 ms·
This is the exact type of bad intuition that the article is trying to warn against. A purely random number - including the output of SHA2 - is going to have lon
by Taek 6y ago
This is the exact type of bad intuition that the article is trying to warn against. A purely random number - including the output of SHA2 - is going to have long consecutive strings of 1's or 0's.
Here's a simulation: https://play.golang.org/p/_eNAI3inGyQ https://play.golang.org/p/_eNAI3inGyQ
The results show that ~0.35% of all SHA2 outputs have >=15 zeroes in a row! Which means that ~0.7% of all SHA2 outputs have >=15 runs of the same binary digit in a row. As stated in the blog post, it's uncommon but it's not so uncommon that it should serve as a red flag.
If you change the code to look for runs of 9 in a row or greater, you'll see that ~40% of all SHA2 outputs have runs of ones or zeros that are greater than 9 in length.
Uniform randomness means that you will get long strings of ones or zeros on occasion. And it's more common than most human intuition would suggest.
- john_alan 6y agoOk thanks for advice. Will aim for non uniform key material going forward.