Du kannst diesen Artikel auch auf Deutsch lesen.
Puoi leggere questo articolo anche in italiano.

Bitcoin mining is one of the most widely known and yet controversial aspects of Bitcoin. What is a groundbreaking innovation in network security for some, is nothing more than a waste of energy and resources for others. But how does “mining bitcoin” actually work? 

Since Bitcoin is a decentralized network, where everyone can participate, there are no central authorities that control the creation of new blocks containing new transactions, and thus nobody to control the issuance of new coins.

Solving complex mathematical riddles

Breaking down complex technical concepts in simpler terms often calls for an analogy. The most common one is already included in the name itself: Mining, an expensive and exhausting process of acquiring rare elements, like gold, for example. Considering the depleting, limited supply of gold on planet earth, mining it gets even more difficult and expensive the more people are having a go at it. But how can the same apply to Bitcoin, which, strictly speaking, is nothing more than invisible numbers on a few thousand computers?

Every other newspaper article or TV documentary about Bitcoin attempts to explain Bitcoin mining by comparing the process to “complex mathematical riddles” that are being solved by powerful computers. This is not only slightly misleading from a technical perspective, it also sounds quite mysterious and probably opens even more questions than it answers. What exactly is being solved, and why would it be so difficult?

To answer these questions, let’s leave common analogies and technical explanations you may have heard in the past behind us. Bitcoin mining is not as complex as you might think – it’s actually quite simple to understand the basic mechanism behind it. 

Rolling the dice

Do you know the feeling of being stuck in jail in a game of Monopoly and having to roll doubles to get out? Well, this is essentially the same challenge Bitcoin miners are facing. They have to keep rolling the dice in hopes of getting a valid result, which is a matter of probability, because the dice results are effectively random and unpredictable. Let’s look a little closer, keeping this basic principle in mind.

Bitcoin mining is obviously a bit different to rolling doubles in Monopoly. The actual goal is to roll a number which is smaller than a target value. Using a classic die with faces from one to six, you might set this value to three, which means that whoever rolls a one or a two first, wins a round of the game. What’s cool about the target value is that we can change the difficulty of the game by adjusting it. For example, if the target was raised to six, it would be way easier to win, because rolling a one, two, three, four, or five would be good enough now. 

Now imagine playing this game with other people, everyone rolling their die as fast as they can in order to be the first with a valid result. In our previous example, the rounds would be rather short, since there are only six possible results to begin with. But of course, we can change that by adding more dice! If we used four dice, for instance, and keep the target at six, it would be more difficult to roll a four or a five, because the numbers now range up to 30.

If you understood this – admittedly rather strange – dice game, you are all set to get a good understanding of how Bitcoin mining works, as we will now apply the analogy to the technical reality in the Bitcoin network. 

The technical reality

Unsurprisingly, if you have ever taken a look at an ASIC miner before (the specialized hardware used for mining operations), you will notice there are no actual dice involved. What we use in the Bitcoin network are hash functions.

Hash functions

Cryptographic hash functions can take any piece of data you throw at them (e.g. a Bitcoin block), and compress them to a fixed length of effectively random data. Just like before you roll the dice, you cannot predict the result of a hash function before actually computing it. It’s like a digital fingerprint of the data that was entered.

If your friend tells you over the phone that they rolled a one, verifying this claim is very hard. Even if you were with them, the result may be manipulated if the die is loaded. However, verifying results of hash functions is easy, because the same input will always result in the same hash value, making the results verifiable. Because everyone can compute hash values on their own computer, any claims about hash values can be verified by computing them independently, using the same input value. You can try this yourself here and check if the below hash for “BitBox” is correct!

In essence, the hash function SHA-256 used in Bitcoin mining is like a technical representation of a die – with some added benefits and properties. It has an unbelievably large amount of faces (not just six), the results cannot be predicted (just like with casino grade dice) and, contrary to normal dice, we can verify results in retrospect. Meanwhile, it’s not possible to “reverse” a hash function. If you don’t know the original input, you cannot calculate it just by looking at the hash value. In simple terms, this means you cannot cheat the game by “turning the dice” manually the way you want them.

Hashing, hashing, hashing…

… is all that miners do, they just keep rolling their dice as often and cost-efficient as possible, with modern hardware surpassing trillions of attempts per second. Working in parallel, entire mining farms can achieve even higher rates, with even higher operating costs, of course. The higher this hash rate gets, the higher the probability to eventually win a round in the game is. Sticking to the analogy, if you roll the dice twice as fast as your opponent, your chances of rolling a low enough number – before they do – increases.

Target values in the Bitcoin network are a lot more difficult to beat than in our previous example. Because hash values are so unfathomably large, there is plenty of wiggle room to adjust the difficulty of the game and keep it challenging, long into the future. The network adjusts the difficulty once every two weeks to keep the average time between new Bitcoin blocks around ten minutes, allowing the network to synchronize and grow in a controlled manner – and consistently issue new coins.

“To compensate for increasing hardware speed and varying interest in running nodes over time, the [...] difficulty is determined by a moving average targeting an average number of blocks per hour. If they're generated too fast, the difficulty increases.”
– Satoshi Nakamoto in the Bitcoin whitepaper

Building blocks

Of course, miners are not just rolling dice at whim. The input that goes into the hash function is carefully crafted and represents the Bitcoin block that is about to be mined; including new transactions, a reference to the previous block and more! By the way, this is also where the term “blockchain” comes from: The hash value of a block represents all its transactions and also its predecessor, effectively chaining them together.

Now, the miner continuously makes small changes to the input to “roll the dice again”, that is, to create a new hash value. If they get very lucky, this hash value is smaller than the current network target, and the miner just created a new Bitcoin block – receiving newly issued coins and the fees of the included transactions as a reward.

Everyone else in the network can verify the new block by computing the hash value, to see if it’s actually small enough, and check if the included transactions are valid as well. If it is, the game starts all over again, with miners building the next block and computing as many hash values as possible – you get the idea now!

Proof of work

The entire process we just outlined takes a lot of work. Miners have to rent property, buy expensive hardware and pay for electricity bills, just to keep hashing at a profitable level, while competing with other miners trying to be even more efficient. This is why people often refer to a valid block hash as a proof of work, because finding the right input value required either exactly that: time and energy – or an insane amount of luck. Proof of work mining is the best shot we have at making sure nobody cheats the system and, therefore, securing the Bitcoin network. Without it, Bitcoin would be nothing more than a boring and inefficient database.

Conclusion

By combining proof of work mining with digital signatures and a decentralized network architecture, Satoshi Nakamoto solved a fundamental problem in computer science: creating digital money with no central authority. The simple yet elegant mechanism behind Bitcoin mining stabilizes the network with consistent intervals between blocks, giving new blocks time to propagate across the network, and incentivizes participation with a fair reward system. While a BitBox hardware wallet secures your coins, proof of work mining secures everyone’s coins, making it arguably the most important innovation of the Bitcoin network.


Don’t own a BitBox yet?

Keeping your crypto secure doesn't have to be hard. The BitBox02 hardware wallet stores the private keys for your cryptocurrencies offline. So you can manage your coins safely.

The BitBox02 also comes in a Bitcoin-only version, featuring a radically focused firmware: less code means less attack surface, which further improves your security when only storing Bitcoin.

Grab one in our shop!


Shift Crypto is a privately-held company based in Zurich, Switzerland. Our team of Bitcoin contributors, crypto experts, and security engineers builds products that enable customers to enjoy a stress-free journey from novice to mastery level of cryptocurrency management. The BitBox02, our second generation hardware wallet, lets users store, protect, and transact Bitcoin and other cryptocurrencies with ease - along with its software companion, the BitBoxApp