Bitcoin (BTC) is an open-source digital currency introduced in 2009 by the developer Satoshi Nakamoto. It’s the first decentralized cryptocurrency that enables peer-to-peer transactions without involving any intermediators, like agents, governments, brokers, or banks. 

Bitcoin mining is an important part of the operation of the Bitcoin protocol. This is the process of verifying and approving Bitcoin transactions by solving complex mathematical problems using high-performance mining computers like a bitcoin mining rig. So what math problems are bitcoin miners solving? Miners have to solve three difficult problems: the hashing problem, the byzantine generals problem, and the double-spending problem.

This “Proof of Work” method differs from Ethereum, which now uses a “Proof of Stake” method when verifying transactions. 

In exchange for finding the correct answer, they earn both transaction fees and a reward for mining a bitcoin block. The number of Bitcoins in that reward decreases over time, with the current block reward being 6.25 Bitcoin.

What Are the Math Problems in Bitcoin Mining?

What Is Blockchain Technology?

Blockchain is the technology that Bitcoin is based on. It’s a public digital ledger that records transactions chronologically. These transactions are secure from hacking because no one can delete or change data stored on the blockchain. The blockchain’s smallest unit is the block which contains all the details of the transaction. Every block has the following components:

  • Data – a combined set of transactions that were mined, confirmed, and incorporated in the block;
  • Nonce – Bitcoin uses a mining mechanism known as Proof of Work algorithm (the process of confirming transactions in the blockchain to prevent double spending), where a nonce is a random value that is used for variating the output value of the hash. Every block has to create a hash value, and in order to do that the block has to use nonce as a parameter.
  • Hash – The digital signature of the block is called hash value. It’s the value that the block gets when it combines the data, nonce, and previous hash value using the SHA-256 hash function. This function is used by the Bitcoin blockchain in particular and generates a 256 bit (64 character long) random hash output for every input.

Blockchain Concepts

Before we explain how Bitcoin mining works, you need to understand the following three crucial blockchain concepts:

  • A publicly shared ledger – A shared ledger is a file containing all transactions kept on the blockchain network across the world. The confirmation of Bitcoin transactions is done by Bitcoin miners.
  • SHA-256 hashing algorithm – This function is used by Bitcoin’s blockchain to prevent unapproved access and ensure the security of the blocks. All blocks are digitally signed and they each generate a hash value that cannot be changed. SHA-256 is a one-way function – every input string, no matter the size, transforms as a fixed 256 bit output, but the reverse is not possible. For example, using SHA-256 a 512-bit string would be transformed into a 256-bit string, but it would be impossible to convert the obtained 256-bit output back into the original 512-bit string.    
  • Proof of Work – This is a hard mathematical problem that Bitcoin miners have to solve in order to confirm the Bitcoin transactions during the mining. The primary goal of the miner is to find out the value of the nonce in order to get a hash that is smaller than the target determined by the network for a certain block.
Man wearing brown fedora hat facing big chalkboard with math problems written

What’s Bitcoin Mining and How Does One Mine Bitcoin?

As we said previously, Bitcoin mining is one of the three ways in which you can obtain Bitcoin. This process involves confirming Bitcoin transactions and filing them in the public blockchain record. Unlike fiat currency transactions, here, there is no central authority to confirm the transactions except for the mutual agreement between the computers that mine Bitcoin. What math problem is bitcoin solving?

In order to confirm the Bitcoin transaction, the miner has to solve a complex cryptographic puzzle, and by solving it, he/she proves mathematically whether the transaction is valid or not. The process of trying numerous solutions until you get the right one is known as Proof of Work (PoW). 

The Bitcoin protocol rewards the miners for their work with: 

  • Block reward – After the miner confirms the Bitcoin transactions, each solved block of transactions is added to the Bitcoin blockchain. For this action, the miner gets a reward known as a block reward. The reward gets slashed in half every four years in an event known as halving, which occurs every 210,000 blocks. Currently, the number of Bitcoins issued as a mining reward is 6.25 BTC per block.
  • Fee per confirmed transaction – In order to confirm their Bitcoin transactions, the users pay a certain fee to the Bitcoin miners to do the confirmation for them. This fee is a very small part of the mining reward, but because of the decreasing hash rate, the fees for the miners are going to get significantly higher in the future.

Mining Requirements

Here’s what you need if you ever decide to mine BTC yourself:

  • Mining hardware –  you can either use GPU (graphics processing unit) or an ASIC (application specific integrated circuit). It’s not cost efficient to use regular CPUs.
  • Bitcoin wallet – this is a software program which is used for trading and holding bitcoins.
  • Low-cost power supply –  in order to create a new Bitcoin you’ll need a high amount of electrical power so you have to obtain low-cost power supply.
  • Mining software – you need to choose a platform through which you can access the blockchain and control Bitcoin mining. 
  • Mining pool membership – if you want your mining to be more effective, you have to join a mining pool, i.e. a group of Bitcoin miners who fuse their computing power in order to mine more BTC and earn more income. 

The Most Common Bitcoin Math Problem

Although it sounds alluring, you should be aware that the mining process is not as easy as it looks. What is the math problem in bitcoin mining? In order to be successful, miners have to solve three very difficult math problems: the hashing problem, the byzantine generals problem, and the double-spending problem.

Hashing

The first step in Bitcoin mining is to understand what hash is. A hash is taking an input that can have any length and afterward creating an apparently randomized output that has a predetermined length. The same output will be created every time you use the same input, but if you change only one character, the output will change drastically. This makes it impossible to guess the input based solely on the output.

Bitcoin Mining Math Problem Example

To show how Bitcoin uses the SHA 256 algorithm, take a look at this simplified bitcoin math problem example. Say, the previous hash block is 17975b97c18ed1f7e255adf297599b55330edab87803c8170100000000000000.

To solve the hash, the miner has to start with the data available in the block header, and in basics, it’s solving a complex math puzzle. Every block header consists of a time-stamp, version number, the previous block hash, the hash of all the previous transactions, the target hash, and the nonce. The miner must find a unique hash that begins with enough zeros to be successful.

The Bitcoin miners are focusing on the nonce which is a string of numbers. This string of numbers is attached to the hashed contents of the previous block, and afterward, it’s hashed. If the newly generated hash is equal to or less than the target hash, the new hash can be accepted as a solution to the math problem, and then the block can be attached to the Bitcoin blockchain, and of course, the Bitcoin miner can get the block reward.

The Byzantine Generals Problem

To understand the Byzantine Generals Problem (and its solution), you need to learn what a distributed timestamp server means. In Bitcoin mining, a distributed timestamp server is used to store minor coded data in each block, similar to a one-of-a-kind serial number, whose main function is to determine the precise time in which the block was mined and verified by the blockchain network.

Simply put, when you’re creating a chain of blocks they are linked to one another by incorporating the hash of the previous block into the next block. Moreover, this proves that the new block “knows” about the block that came before it. But the problem occurs when, for example, you, as a miner, try to put your newly mined block number 5 after block number 4, and at the same time, another miner tries to put their block 5 after block 4. It can get even worse if the two competing blocks, 5a, and 5b,  contain dissimilar transactions. Now the question is, which block is the real block of transactions to enter the blockchain? 

The miners are solving this problem using a Proof of Work system called Hashcash for verifying the transactions and connecting the blocks in the blockchain. This process has each node running a series of difficult math operations that require a lot of computing power in order to reveal the next block’s individual cryptographic hash value. Once a miner finds a solution, he/she broadcasts this solution to the rest of the network. At least 51% of the network miners need to accept the solution before that transaction is verified and enters the new block. You only need to hope that your block gets accepted by the majority of the miners first.

Double-Spending

Double-spending is a problem that occurs when the same digital currency is spent twice. This is a potential problem only for cryptocurrencies due to the fact that digital data can be reproduced quite simply by tech-savvy users who have the necessary computing power.

When you pay with fiat currencies, once you give the cashier $5 for that coffee, you can’t get the bill back and spend it again. However, things are different for digital money. Plus, Bitcoin is a decentralized cryptocurrency that has no central authority that can confirm whether or not it has been spent only once. 

Due to the fact that Bitcoin is based on blockchain technology, we can easily solve the double spend problem by broadcasting every Bitcoin transaction to the Bitcoin network of nodes and verifying the transaction by using a consensus mechanism, in our case, the Proof-of-Work mechanism.

Crucially, each BTC transaction is stored on the distributed public ledger, and they are grouped into sequential blocks that are internally connected making the blockchain. Therefore, the time-stamped record of every transaction can be seen by all of the participants of the network, and all the fraudulent transactions are inspected and then rejected.

51% Attack

It’s very difficult to copy or forge the Bitcoin blockchain. Hackers are trying to avoid the verification system of Bitcoin using methods like out-computing the security mechanism of the blockchain or double-spending method which involves sending a deceitful transaction log to the seller and a totally different one to the Bitcoin network.

How does a 51% Attack Occur?

Every outgoing transaction ends up in a mining pool like an unconfirmed transaction. Later on, the miners can choose transactions from the mining pool and make a block of transactions. Afterward, the miner has to find a solution for the complex math problem in order to be allowed to add a block to the blockchain.

The correct solution to the problem is broadcasted to the other miners, and it can be accepted only if all the transactions in the block are valid according to the preexisting record on the blockchain. On the other hand, the fraudulent miners don’t send the correct answer to the rest of the participants in the network, and by doing this, they form a second version of the blockchain which is used entirely by the fraudulent miner.

The fraudulent miner will continue working on the version of the blockchain that isn’t broadcasted to the rest of the network’s participants. This way, the second version will be isolated from the network, and the fraudulent miner will be able to spend his/hers assets on the original version of the blockchain.

Frequently Asked Questions

A Few Words Before You Go…

In our guide, we’ve briefly captured the essence of the Bitcoin blockchain, its main components, and features in order to make it easy for you to understand the basics of Bitcoin mining. Hopefully, we’ve achieved in presenting to you the three most common (and complex!) crypto math problems in Bitcoin mining as plainly as we could.  This way, you can see the complexity and seriousness of the mining job and understand the role of miners in blockchain.