How Bitcoin Mining Works?

How Bitcoin Mining Works

If you’re a bitcoin enthusiast, chances are you must have heard the term bitcoin mining being the latest fad. There are many rags-to-riches stories doing the rounds on the internet about people who’ve profited a lot from it. This article attempts to help understand what bitcoin mining is and how the coins are ‘issued’. We are familiar with the concept of paper currency and how it is issued by the central bank. The supply of money is also controlled by the central bank in the economy. A Bitcoin is different insofar as there is no centralized authority to issue it. So where does it come from? What is the source of bitcoin? The answer is bitcoin mining.While this may sound simple yet, in its simplicity lies its ingenuity.

When we picture a mining operation, we instantly have a vision of a grime laden, sweating, heaving man with torchlight and a bunch of tools hammering away at an obstinate mineral block, separating the dirt from the ore. Well, Bitcoin mining is not much different from that crudely speaking (except a lot cleaner and much less sweatier).  Only, instead of the physical ore, there is a virtual treasure and instead of the stone blocks, there are math problems to be solved. (Yeah well who said this was going to be easy). Technically, however, it’s not you but your system that would be doing the math (you can breathe again). These math problems are technically known as algorithms. And they are way beyond an average human’s league. You couldn’t solve it even if you had an IQ of 220. Here’s a glimpse of a transaction which has been hashed:


Who makes these algorithms you may ask. Well it’s the Bitcoin network itself. The more of the algorithms one solves, the more coins one earns. The Bitcoin network however, is one step ahead and keeps on increasing the difficulty level of the problem with the increase in their mining rate.

Bitcoin Mining-Evolution:

Initially, bitcoin miners used simple processors and computers to solve math problems- CPU based. Next were the Graphics cards or GPU based systems which could solve the ‘rithms quicker. But the downside to this was the cards heated up and also used a lot of electricity. Next we had professional commercial bitcoin mining products, which had special in built chips programmed for bitcoin mining. These were a lot faster but still shot up your electricity bill. Then we had the Application Specific Integrated Circuit or ASIC which made bitcoin mining faster while using a lot less power. Nowadays we have a lot of sophisticated equipment to cater to the mining needs. Naturally, the hype and hoopla surrounding these coins attracted more and more miners. This in turn compelled the system to raise the difficulty level to balance the demand and supply. To counter this, instead of solving them individually, miners clubbed together and formed what came to be known as pooled mining to be more quick and efficient.

To understand bitcoin mining, it is essential to know about The Bitcoin network first. It is a network containing thousands of independent computers which are called nodes and located across the world. Hence, decentralization is the basic feature of this network. Just like in a private ledger, each node on the network maintains its own copy of the Blockchain. This distributed public ledger is the second major distinguishing feature of the network and has been touted as the biggest thing since the internet. Imagine it as one giant register that keeps an account of all transactions across the world. Also, each node can mathematically verify the accuracy of the ledger and ensure it is not altered. This a node does by verifying its copy of Blockchain with others nodes. Lastly, the ledger gets updated only on the consensus of the nodes in the network. For all the reasons mentioned above, the Blockchain has been called The TRUST MACHINE by the Economist.

Understanding the basics:

Before we get down to explaining the bitcoin mining process, a couple of terms need to be understood. These have been given a basic introduction below and elaborated later wherever required.

Hash: Hash is used extensively in cryptography. Think of this as an input crunching machine which takes in the data and converts it irrevocably into the output. Thus, it takes in a particular input and gobbles out a totally different fixed length hexadecimal output. The input can be anything ranging from a simple word to a crime thriller novel while the output would still have the same length (which is normally smaller than the input). Due to limitations on the current state of computing technology, it is a one-way road i.e. you cannot take the output and reverse engineer the input from it. It is this feature which makes it the celestial star of the cryptography universe. Also, even the tiniest change in the input changes the output entirely (reminds me of my math class). Lastly, there is no scope for Hash Collision- which is when two inputs produce the same output. Another important point to remember is that bitcoin uses the SHA256 or the Secure Hash Algorithm 256 bit. This algorithm is what makes the entire process secure (among other features) by making your computer work really hard to decipher it.

Nonce: It is a random number which is a part of the block header and has to be guessed to create a block successfully. It contains a number of zeroes and is a four byte field. A nonce which successfully leads to a value less than the target value is called a Golden Nonce.

Merkel root: this can be thought of as a tree with various branches splitting but containing nodes instead of leaves. Merkel root is what you get when the various split branches are hashed in pairs till the ‘main’ or root hash is got. It is this root which forms a part of the Block header.

Block header: Think of this as a box which contains the Merkel root, hash root of the previous block and the nonce. This header serves as the Block’s identity and is hashed using the SHA256. Every block contains the hash of the former block and hence forms a chain called Blockchain.

Blockchain: As explained above, it contains all the previous blocks’ headers. You can visualize this as the old pizza worm game where the worm keeps gulping down the pizzas and increasing in size. The same way, the headers keep on adding on to the previous ones. This system also makes it foolproof .

Bringing it all together:

After the pre-authorization stage- which deals with confirming the validity of the transaction details like the amount, user’s address, and recipients address etc- is over, the nodes send the transaction details to the miners. They collect a bunch of these pending transactions and then the race, to convert them successfully into valid blocks and added to the public ledger, commences. The input data contains the current transaction, output hash generated from the last block and other information. The aim is to get a hash value for the block that is less than the target value from the preceding block while following certain rules like ensuring the output begins with a certain amount of zeroes etc.

Deriving the hash root: First, each transaction is hashed individually and then in pairs. The aim is to organize them into a hash tree or a Merkel tree. The concept is very simple. Large lumps of data are broken down into silos. Thus, each silo contains only parts of the original data dump. Then each lump is hashed in pairs till we get only one final hash- the root hash- at the end.  This also serves the purpose of providing merkel proof. This allows you to verify the data contained in the entire branch- right from the root hash to the original bunch. Merkel roots make the verification process much easier as opposed to verifying the entire data together, which would lead to more time and system use.

Merkel Root

bitcoin mining

Working with nonce:  As explained above, a nonce is a random number and the key to block making. It can be solved by guesswork only. Currently the entire bitcoin network collectively makes about 2.14 quintillion guesses per second. Once a nonce is found that produces a hash output lower than the target, the successful miner showcases the information to the network and makes a new block. If, after finding the hash root and adding it to the previous hash and a nonce, the output is invalid, the nonce needs to be changed continuously till you get the right answer.

Finally, the root hash along with the previous hash and the nonce is put into a block ‘header’ and hashed. It is this hash that is also used as part of the next block forming a block chain.

Verification and Security:

Because the entire system is decentralized and public, once the solution Is found it can be verified at your will. The verification process is much simpler and the correctly guessed nonce needs to be plugged in and check the calculations. There is a consensus among all the nodes that the calculations add up to the correct answer. In fact, you can verify the results right up to the first block called the Genesis Block. Thus, users trust that the system is secure and functions as it is supposed to. This technique also makes it very secure. Nobody can tamper with a block without going to the previous blocks. The records cannot be altered. Any attempt to do so would require rehashing of the block as well as other subsequent blocks as well. Also new blocks would be getting added simultaneously faster than the attacker could possibly work on them. Not to mention the simply enormous amount of time, effort, electricity that would be spent. And that is if your computer is a powerful one otherwise you might end up frying your system and losing more than you gain. So, unless you’re willing to go the entire length, this really isn’t feasible.

Proof of work: The network makes use of a concept called ‘Proof of work’ to reach consensus about which block goes ahead to the Blockchain. Proof of work basically tells everybody that you worked really hard to solve the algorithm. The bitcoin miners take the bunch and start hashing. Since the output is random and thus virtually impossible to predict, they engage in a lot of guesswork. There is no mathematical formula involved. Have you ever forgotten the code to your three digit lock combination on your briefcase and to unlock it with the hit and trial method. This is basically what happens in hashing albeit on a much more complex scale. The proof of work is in the form of electricity, time and computing power that the miner spends. Typically, the Bitcoin network works in such a way that it takes about 10 minutes to come up with an output less than the target value set. The block so mined gets added to the blockchain and elongates it. The process then begins again with the next set of transactions.

The entire process is structured in such a way that it take about ten minutes for a miner to solve and create a new block. The level of difficulty auto regulates about every two weeks. The difficulty level of the next block depends on the output of the previous one. All of this is necessary to ensure a stable supply of bitcoin.

It is both the mining and the proof of work concept which keep bitcoin secure while also spending a lot of computing power and electricity.

Incentive for bitcoin miners: they are awarded some bitcoin for their efforts. Currently, it is about $12.5, along with some other small fees.  Thus it is by this system bitcoin is introduced in the network. Also, it needs to be remembered that the upper limit to the amount of bitcoins there can ever be is limited to 21 million. As of mid-2016, about 75% has been mined. As per a preset formula, the last bitcoin would be releases in around 2140.


The Latest

To Top