Gareth Johnson
Gareth Johnson
Updated on July 27, 2021

You have probably heard before that Bitcoin mining involves solving complex mathematical problems. “Complex mathematical problems” and “complex puzzles” have long been part of the Bitcoin ethos. But what are these math problems? Why are they so complex? Are these miners trying to solve the longest-standing math problems? Are they calculating the near-impossible quantum equations that leave mathematicians stumped like how we are baffled by calculus? 

Well, the short answer is a disappointing no. But the more interesting answer is that they are not actually solving any mathematical problems let alone complex math problems. How could that be? Well, the mining process definitely involves calculations, so that much is true, but, as always, the devil is in the details.

We prepared this guide to explore Bitcoin mining and the calculation process that lies at the heart of it. If you are looking to broaden your understanding of how Bitcoin mining really works, read on. This guide will help you comprehend the mysteries of Bitcoin creation without getting too technical about it all.

3D concept of bitcoin mining

What Is Bitcoin Mining?

Thanks to Bitcoin’s now-ubiquitous popularity, most people probably have heard of Bitcoin mining. Although the term sounds a bit odd at first since Bitcoin is a cryptocurrency, the reference to gold becomes more or less obvious as you get into Bitcoin culture and understand its underpinning ideology. 

Let’s start from the beginning and give a simple definition: Bitcoin mining is how new Bitcoin (BTC) is created. It is also how already existing Bitcoin and all-new Bitcoin transactions are kept secure without a central authority overseeing the whole process. If that sounds too complicated already, don’t worry. You will understand it better once we go over blockchains in the next section.

What Is the Relationship Between Cryptocurrencies, Blockchain, and Mining?

Bitcoin is not just the first and most popular cryptocurrency in the world; it is also the world’s first blockchain. That’s right, blockchain technology was launched into existence with the Bitcoin Whitepaper written by the pseudonymous Satoshi Nakamoto. The whitepaper offered an original solution to the double-spending problem, outlining a digital currency system that can operate without a central authority like a bank or a state. The simple yet groundbreaking system was blockchain. 

A blockchain is a simple concept at its core and it is often described as a public ledger. The Bitcoin blockchain is indeed like an open ledger, but all kinds of data (not just numbers) can be stored in a blockchain so it is essentially a form of public record keeping. 

The logic of a blockchain is astonishingly simple. It consists of blocks of data, with each block chronologically following the previous blocks. Each new block is bound by cryptography to the previous one, so falsifying a new block is pointless. The only way to tamper with data is to falsify all of the preceding blocks created before, which is quite unlikely—if not impossible—for the reasons we will explain later on. Basically, blockchain is a way of storing data collectively without an overseeing authority checking the system to validate its accuracy. 

You can think of blockchain as a very special program that comes with its own rules. Bitcoin blockchain has rules for how data regarding Bitcoin transactions will be recorded on the chain. Let’s take a closer look at the Bitcoin blockchain to understand those rules.

How Does the Bitcoin Blockchain Work?

Bitcoin Blockchain consists of a few layers. The first layer is the hard code of the blockchain which provides its rules, known as protocols. These protocols have several functions that secure the safety of operations on the blockchain.

The second layer is the data itself. In other words, this part is the ledger that shows all the Bitcoin transactions and the bitcoin addresses that correspond to them.

The third layer is the peer-to-peer network of the blockchain. This is known as the Bitcoin network and consists of several nodes. All the Bitcoin users can become nodes for the Bitcoin network by storing and broadcasting the blockchain data.

Since the ledger is stored and broadcasted by the whole network, a false data block can be recognized and rejected at the moment it is broadcasted.

The first layer protocols define Bitcoin properties and how data about Bitcoin transactions can be added to the ledger. There are two major protocols you need to know in order to understand how Bitcoin mining works.

How Do Bitcoin Protocols Work?

The first and arguably the most important rule of Bitcoin is that it is a limited supply. There can only be 21 million Bitcoin. This is known as a hard cap and it means no new Bitcoins can be mined once 21 million Bitcoin is created. (Hint: Bitcoin enthusiasts refer to Bitcoin as digital gold because the limited supply of gold ensures its value as an asset).

The second rule is the proof-of-work (PoF) protocol. This is the protocol that regulates how the data about Bitcoin transactions will be recorded on the blockchain. Technically, anyone on the Bitcoin network can do it as long as they have a full copy of the blockchain and they are able to broadcast it (this is called running a full node). But how do we know the person recording the data on the blockchain, which is called validating the transactions, doesn’t add a block with false information by sending themselves a ton of Bitcoin? 

What Is the SHA-256 Algorithm? 

This is where it gets tricky. In order to make sure nobody falsifies these records Proof of Work protocol employs an algorithm. Do you remember how we said above Bitcoin secures itself by binding each block with cryptography? This is where that comes in. There is an algorithm called SHA-256 that produces and assigns a cryptographic hash to each and every Bitcoin transaction as well as to each Block. These hashes are all unique and they are all connected by the algorithm. If someone tries to tamper with the ledger by adding a false transaction this creates a unique hash that changes the block hash and the network rejects it on the spot.

The SHA256 algorithm spits out a target hash for each new block that is based on all the previous transactions on the blockchain. It is imperative to find this hash -or the closest smaller value than the hash in order to fill this block with transactions. Any falsified transaction with a made-up hash will mess up the final hash. Just like how the glass shoe only fits Cinderella among all the women in the kingdom, only the transactions backed up by the previous transactions will fit the block.

Basically, all of these mean that in order to be able to validate the next block of transactions a hash value equal to or less than the block hash value has to be calculated. 

Now for the final piece of the puzzle: The process of trying to find the right hash that will fit the block is what is called mining. When a block is validated on the blockchain, the system rewards the validating party with Bitcoin. Voila! New Bitcoins enter the market, transactions are working and the system is kept secure.

What Are the So-Called “Math Problems” In Bitcoin Mining?

As you might have guessed, when people talk or write about solving complex mathematical problems in order to mine Bitcoin they are actually referring to the process of trying to calculate the target hash necessary to validate a block. Calculate? Wait, isn’t that math? Yes, there is definitely math involved in hash calculations, but not any mathematical problems or problem-solving. Let’s elaborate.  

Bitcoin symbol made out of gold numbers on black background

What Is Hashing?

Hashing is a cryptographic function. This means that when you put data through a cryptographic algorithm like SHA-256 you receive a 256-bit hash represented by an alphanumeric string with 64 digits. This hashing function has certain properties that make sure data remains secure. 

Let’s simplify. Imagine you have a dataset you want to secure through cryptography. Dataset would be your input. You apply the SHA-256 algorithm which means you put it through a hash function. You get an alphanumeric string with 64 digits. This is the output. Now, if you change the original data by adding a word or subtracting a number and apply the hash function you will get a totally different output. But if somebody else uses the same input as you, they will get the same output, which means it is easy to verify if the two datasets match. Finally, nobody can obtain the dataset by reversing the hash, it is irreversible.

How Do Miners Find the Target Hash?

Each block header for the new block contains the hash of the block before and a target hash necessary to validate the block. Target hash can be a number anywhere from 0 to 67+ digit numbers depending on the difficulty level of the mining operation.

The miners have to take the block header hash and change it slightly in order to come up with a value equal to or less than the target hash. How do they change it? Remember that changing an input even slightly produces a unique output. So miners take the block header hash represented in numbers and hash them with other numbers. These numbers are called “number used only once” or nonces. If the hash done with a certain number isn’t giving an output less than the target hash you disregard it and try a new nonce to get a closer hash. This is a simple operation for any computer but as the difficulty rate increases so do the number of trials necessary to get the right hash. 

When a target hash is found, it can be easily verified by the other miners. It is hard to find the “lucky” nonce but once it is found it is easy to check because using the same nonce will give the same output to everyone.

So when Bitcoin miners mine they aren’t really solving any problems. They are simply trying to generate as many random answers as possible hoping that one of them will stick, so to speak. Think of the hopeful gold miners of the old days. They didn’t find gold by solving math problems. They had to work laboriously and depended on luck in order to strike gold. The same can be said for mining Bitcoin as well since there is a lot of labor (albeit done by computers) and luck involved in successfully mining BTC.

What Does It Mean to Adjust the Difficulty Rate?

So now you know what people mean when they talk about solving complex math problems to mine Bitcoin. Instead of actually solving problems, miners are actually applying the brute force of computational guessing to create as many hashes as possible. This is not a complex operation by itself and even a dust-ridden ancient computer can do it. The difficulty of mining lies in the sheer amount of guesses that must be done. Naturally, a faster device will generate more hashes than a slower one and increase the odds of “winning” the guessing race.

The speed of the device isn’t the only important factor when it comes to mining. There is also the difficulty rate which we mentioned above. This is the main variable when it comes to mining operations. The difficulty rate of the mining operation is calculated by one of those layer one protocols on the Bitcoin blockchain. It adjusts depending on the total computing power of the network.

Think about it this way: You are trying to come up with the right hash on your own and your computer is trying nonces one by one. When another miner joins the network they are also trying different nonces. Statistically, the time necessary to find the right nonce will be cut in half. The computing power of the network increases as more miners join you. Now a new block can be created much more quickly. And yet, with millions of miners it still takes 10 minutes on average to mine a new block. This is because the Bitcoin blockchain adjusts the difficulty of mining according to the processing power of the network.

Why Does It Take 10 Minutes to Mine A Block?

Mining difficulty is measured by hash rates. A hash rate defines how many hashes per second need to be generated to find the target hash in 10 minutes. The hash rate is adjusted for every 2016 blocks mined for approximately two weeks in order to keep the mining rate stable. When computing power increases or decreases due to more miners coming or leaving the pool during these two weeks, the time to mine one block can decrease or increase but the average stays 10 minutes.

You might be wondering why the system necessitates 10 minutes on average between blocks, while it takes much less time to mine blocks on other blockchains like Ethereum (it takes 10 to 15 seconds to mine an Ethereum block). Well, in reality, there is no definite answer to why exactly 10 minutes was decided as the time period is hard-coded to the Bitcoin’s structure by Satoshi Nakamoto. That said, we can still surmise a couple of reasons through the Bitcoin White Paper and what we know about blockchains. 

First of all, a certain amount of time between blocks is necessary to enable all the nodes in the network to access the information on the blockchain for verifying the results. Another important factor is storage and bandwidth. The size of the blockchain increases with each new block. If new blocks are mined more frequently the blockchain will grow much faster and it will be harder for the nodes to store and broadcast the blockchain due to storage and bandwidth capabilities available. This has already started to impact Ethereum to a degree and could impact Bitcoin as well if scalability solutions are not developed.

There is another benefit to the timing rule. It makes it possible for everyone to foresee how much longer Bitcoin will be mined for since Bitcoin has a limited supply and a definite mining time. 

Miniature worker holding mattock beside Bitcoin on top of circuit board

Why Is It Hard to Mine Bitcoin? 

Finally, we are at the heart of it all; the question that troubles all of us and the Earth to a certain degree: why is it so hard to mine Bitcoin?

As we put in the beginning, mining is the most crucial part of Bitcoin. As long as miners continue to validate transactions, the blockchain can grow safely. Miners are awarded Bitcoin (and the transaction fees attached to the validated transactions) as block rewards and new Bitcoin enters the market through this system. So far so good. But as anyone who has given a try to Bitcoin mining can tell you, mining Bitcoin is not easy. 

Mining is the only way to make new Bitcoins but mining rewards decrease in half roughly every four years, due to another layer one protocol that is known as halving. As Bitcoin became more and more popular, so did Bitcoin mining. People started to realize that Bitcoin has a finite supply and this created a huge influx in the network causing the difficulty rate to shoot through the metaphorical roof of the blockchain.

The really hard part of mining Bitcoin is not the time it takes (10 minutes on average for each block) or the quality of the work necessary (even an old computer can do it). The real problem at the heart of Bitcoin is energy. 

The adjusting difficulty rate of mining Bitcoin means that it gets harder and harder to mine a block every time a new miner motivated to make some BTC joins the network. This means that the total computational power necessary to mine a block increases with every miner and what is computational power if not energy?

How Is Bitcoin Mined?

When Bitcoin was first launched there were only a few miners on the network. For the first few years of Bitcoin, you could simply mine using your computer’s Central Processing Unit (CPU). As the difficulty rating increased people moved onto GPU mining using gaming laptops with Graphics Processing Units.

In 2013 ASIC miners entered the market leaving mining computers in the dust. ASIC or Application Specific Integrated Circuit is a piece of hardware that is designed solely for mining Bitcoin. They are now widely used for mining operations.

Entrepreneurs among the miners soon realized mining can be done on a larger scale. They bought mining equipment and established mining farms that run 24/7 in order to gain more Bitcoin. The miner machines in the farm pool their resources in order to guess the right nonce.

Mining difficulty significantly increased with the introduction of mining farms. Regular users started to pool their computing power through “mining pools” in order to beat the odds. Most successful mining is done through mining farms or mining pools these days. 

Running these farms requires enormous amounts of electricity and as you might have surmised, as more farms are established the difficulty rating increases and so does the amount of electricity necessary to calculate the hash. 

A Few Words Before You Go…

Hopefully, this guide helped you gain a better understanding of Bitcoin mining and how math functions into the process. Bitcoin Mining is based on the proof of work protocol and it is administered by the SHA-256 hashing algorithm. Miners can earn Bitcoin if their computing equipment manages to find the right hash. The increasing popularity of Bitcoin mining resulted in inefficient individual mining efforts for the most part due to the increased difficulty. Mining is mostly done through mining farms or mining pools where the computational power of multiple miners’ equipment is pooled in order to strike digital gold.