# Can future Bitcoin hashes be considered a good source to generate random numbers?

There are a lot of miners trying to calculate the next valid SHA-256 hash using random strings, so can I consider that generated hashes have good randomness? How can I prove it?

For example, use the bitcoin hash as a entropy or seed to generate random numbers. How would you solve this problem? What algorithm would you use to generate random numbers with the bitcoin hash as a input seed? but the algorithm should be secure and have a good entropy

• They don't have to try random strings. Any input is as likely as every other input to create a SHA-256 output with a desired prefix. A miner can try to win Bitcoin's high-carbon-footprint lottery using only inputs that were a multiple of 5, for example, or only inputs that end with the ASCII bytes for the string "cat". They would find a winning input in the same expected number of tries, even though they aren't using random inputs, because SHA-2 behaves somewhat like a random oracle. So they could bias the result and succeed with a probability equal to them first winning the Bitcoin race. Jun 22, 2019 at 0:46
• @FutureSecurity I suppose each miner use a different strategy to get the right hash, otherwise everyone would be calculating the same hashes and it would always win the fastest. So if we have a group of people that uses strategies and another group that uses random strings (I pretty sure this group exists, specially if you can't rival with the most powerful), we can consider the next hash is completely random and unpredictable. Jun 22, 2019 at 11:48
• I've not looked into details of mining hardware and this is over-simplified, but I've read that miners basically pick a random r to start with; then each subsequent hash uses ++r. Everyone can use this one strategy without miners repeating work that's already failed for someone else. If you ignore the fact that a miner might not have hardware that's designed for this, the initial r can be rounded to a multiple of 5 and ++r can be replaced with r += 5. That wouldn't effect the probability of success or required number of hashes. Nor does it have the redundant mining issue. Jun 22, 2019 at 15:40
• (Using a counter is actually slightly cheaper and faster than using a new random number every time. Again, with no negative side effects. Real mining hardware might use some other form of "counting", eg. using a hardware LFSR, to save a little more energy. This is also very theoretical. Someone succeeding in biasing results has to win the mining race, which probably wouldn't be likely or worth the expense. At least while bitcoin is popular.) Jun 22, 2019 at 15:53
• @JonHutton Hex is just a representation of a hash output. The output itself is binary.
– forest
Jun 23, 2019 at 3:15