Current block number bitcoin mining How “mining” works is at the very heart of Bitcoin. It is often brushed over and simply referred to as “complicated math” in the media, but it’s actually quite simple to understand even if it is computationally intensive to solve. Disclaimer Most of the content in this post comes from a post on Reddit that I have edited, reformatted, and elaborated on.
Feel free to read the original post if you prefer. Hashes Understanding hashes is the first step in understanding mining. A hash will take an input of any length, and generate is seemingly randomised output of a specific length. The same input will always generate the same output, but changing just one character will drastically change the output. This behaviour makes it very difficult to predict what input gives a particular output. For example, what input gives aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa as a hash?
It’s effectively impossible to work it out. People will often build lookup tables that map these inputs to outputs in order to perform quick reversals later. These tables are called rainbow tables and rely on the input already having been hashed. The second step is to get the idea of a proof of work. It might be impossible to find a hash specifically with a string consisting of nothing but the letter “a” but what if we asked for a hash with a single zero at the front? Because it creates a puzzle whose difficulty is measurable and which it’s impossible to perform better than blind guessing.
That second property is important because it’s the only way to create a fair “mining” system. Miners solve such puzzles as above but which are far more difficult. Each hash is can be considered to be just a number. So in mining, the miners have to achieve a hash with a numeric value lower than a specified number.