How does Bitcoin Mining actually function?

Bitcoin Mining

Bitcoin mining refers to the Bitcoin protocol’s security method for reaching a consensus on the blockchain’s state in a decentralized manner. It is crucial to comprehend how this method prevents system abuse, so making the network not only more secure but also more robust.

Conceptually and technologically speaking, Bitcoin can be difficult to comprehend. It is distinctive in numerous ways, and its applications may not be immediately apparent. As a result, the Bitcoin community and the media came up with numerous analogies to help less tech-savvy individuals visualize Bitcoin. Among these analogies, you may be familiar with the digital gold story. This parallel occurred pretty early in Bitcoin’s history, in part to justify its existence and in part to help others understand it. As a result, the majority of early adopters began using the term bitcoin mining to compare it to gold mine.

In the Bitcoin White Paper, the terms ‘mining’ and ‘blockchain‘ are never mentioned.

However, the phrase is rather imprecise and does not adequately describe how mining occurs.

The purpose of this essay is to explain how bitcoin mining truly operates. We will define Proof Of Work (or POW), cryptographic puzzles, and hash functions, and explain how they all relate to the popular term “bitcoin mining.” Also explained will be the distinction between a transaction validation and a transaction confirmation. Technical terms will be emphasized in bold and discussed throughout the essay, and an infographic describing the entire procedure can be found below.

What exactly is bitcoin mining?

Bitcoin mining consists primarily of solving (or attempting to solve) a basic cryptographic puzzle that, when completed, mathematically verifies the validity of a sequence of bitcoin transactions. This cryptographic puzzle can be compared to deciphering a lock’s code. There are no conceivable shortcuts when searching for the unlocking code. You must attempt every conceivable combination until you stumble upon the solution by chance. This comparison is appealing because it accurately represents the properties of the Bitcoin cryptography challenge. Similar to trying to find the combination that unlocks the lock, locating the correct answer to the puzzle requires a great deal of time and effort. Moreover, just as it is really simple and rapid to verify that a lock combination is accurate (it either unlocks or it doesn’t), it is incredibly simple and quick for the miner and subsequent miners to verify that the proposed solution to the bitcoin puzzle is indeed the correct one.

Proof of Work (or POW) is the process of attempting multiple solutions until the correct one is found, and the cryptographic puzzle (or POW algorithm) in the Bitcoin protocol employs SHA256, which stands for “Secure Hash Algorithm.” Since miners expend so much time and effort to solve this problem and thereby validate Bitcoin blockchain transactions, the protocol compensates them with:

1. The brand-new bitcoin when a miner verifies a transaction, it is packaged into a block and added to the Bitcoin blockchain. And for each new block added to the network, the issuance rate specified by the protocol at the moment of block creation is applied to create new bitcoins. At the time of writing, new Bitcoins are being issued at a rate of 12.5 per block. This rate is expected to halve by May 2020.

Total transaction costs for transactions they validated when consumers use bitcoin, they pay a transaction fee to miners to encourage them to authenticate their transactions Thus, when a miner validates a set of transactions, he also collects all the transaction fees associated with that set. This constitutes a very little portion of the total mining reward at present, but if the issuance rate lowers, the fees will become a greater source of income for miners.

But how can solving a riddle demonstrate that a transaction is legitimate?

To answer this, we must refer back to the Proof-of-Work technique we stated before (SHA256) and explain what a hash is.

A hash is simply a string of characters. This string of characters represents the output of a function known as a hashing function. Hash functions are unique in that they may transform any (literally any) sequence of digital data (a text file, a video, an image, a song, etc.) into a single string of letters. What makes this function even more unique (and interesting in our use case) is that if you change even a single character in the input (or a single byte), the output string, or hash, will be entirely different, with no connection to the prior output.

It may still be unclear at this time how SHA256 operates and how it helps miners establish consensus on the Blockchains state. To comprehend this, it is necessary to recall what information Bitcoin blocks contain, and more importantly, how transactions are incorporated in Bitcoin blocks. The majority of information in a Bitcoin block on the blockchain is represented by a hash, and each block is associated with its own unique hash. Let’s enumerate a few of the fundamental components that are combined to form a Bitcoin block hash:

1. A hash of transactions

The hash of the entire list of transaction hashes contained in the block. A transaction hash is formed by merging the sender’s hash, the receiver’s hash, and the amount sent (i.e., the UTXOs, read more about them here) into a single hash.

2. Previous block’s hash value

Computed in a comparable manner. Only the very first block (called the genesis block) does not utilize the hash of the preceding block.

3. Nonce

The nonce is crucial to solving the riddle. It is a positive integer that, when added to the preceding two elements (transactions hash and the prior block’s hash), produces the final block’s hash.

In SHA256, the block’s hash must begin with a string of zeros in order to guarantee that the proper nonce was obtained. Thus, when we input the transaction hash, the previous block hash, and the nonce into the hashing function, the resulting hash should begin with a succession of zeros. The operation of the hashing function guarantees that there is only one viable answer (ie: only one nonce which leads to such a hash). Similar to our previous scenario, there is only one combination that will release the lock.

Therefore, the nonce is the solution to the cryptographic puzzle, but what makes this method truly elegant and secure is that it uses the hash of the previous block as an input to determine the solution. It is one of the three essential components that make up the final block hash. Recall that the feature of a hashing function is that any change to the input entirely modifies the output, with no link to the prior output. Therefore, even a minor modification to one of the inputs (such as a change in the amount sent in one of the transactions) modifies the final hash and renders the nonce incorrect.

Why does this algorithm safeguard the transaction and prevent alterations?

To illustrate how the algorithm introduces security and verifies the block’s transactions, consider the following example. Consider a scenario in which Alice sends Bob 1 BTC. Alice’s bitcoin wallet will broadcast this transaction to the network and add it to the miners’ pool of unconfirmed transactions after she signs it with her private key. After a period of time, a miner will retrieve it together with a set of other transactions and attempt to determine the correct nonce in order to generate the next block. The hash of the transaction is referred to as the transaction Hash. Then, this hash is combined with all other transaction hashes to form the transactions Hash, also known as the transactions Hash. The miner then combines the transaction Hash with the previous block’s hash and searches for the correct nonce that would produce a block hash consisting of a succession of 0s. The miner discovers the solution, shares it with the rest of the network, and adds the block to the blockchain after some time. So far so wonderful.

Suppose Alice wishes to deceive Bob, so instead of sending him 1 BTC, she attempts to change the record to 0.5 BTC. By doing so, she unavoidably modifies the transactions, which modifies the transactions Hash, which modifies the block hash. Now, the block hash does not begin with a succession of zeros, thus the nonce is invalid. If Alice desired to enforce this change, she would need to mine the block again and broadcast her solution. In the interim, though, other miners are already searching for the next block, using the previous block’s hash as a jigsaw piece. Importantly, miners always use the longest chain (blockchain with the most validated blocks) as the valid chain, per convention. If Alice want to alter the block, she must mine her block and the following block quicker than all other miners to establish the longest chain. However, she is already behind schedule because she attempted to change an existing block! She would have to use a great deal more energy to catch up to the other miners and then create the following blocks more quickly.

At present, such an assault would be exceedingly costly and would not justify any transactional changes. This is truer when the block advances further back in the history of blocks. In fact, if Alice wanted to modify a transaction that occurred 10 blocks in the past, she would have to mine all 10 blocks, as each one depends on the hash of the one before it. It is considerably more expensive when one considers the likelihood that a successful attack would be soon recognized and ruin the value of the asset they were attempting to increase. And this is how a combination of cryptography and properly aligned incentives produces an algorithm that is truly secure.

What if someone wants to destroy the network by attacking it?

We have demonstrated that the economic motivation for an assault is weak, but what if someone wants to attack Bitcoin simply to destroy it? Is that achievable? The technique described above is also known as a 51% attack, in which the attacker gathers 51% of all miners’ processing power. The attacker would be able to alter a block and generate a longer chain if he or she possessed more than fifty percent of the processing power. The total processing power of all mining operations, or hashrate, is 108,616,441 TH/s at the time of writing. Therefore, miners together attempt more than one hundred million trillion nonces each second. It is inconceivable, even for a nation, to obtain 51% of that hashrate. Such an attack would require immense resources and mobilization to be successful. And with each rise in hash rate, this probability decreases.

With such a high hash rate , shouldn’t it be possible to find the correct nonce quite quickly?

This is a question that frequently returns. We are aware that Bitcoin block times are approximately 10 minutes. How then does it remain at 10 minutes, and what prevents miners from discovering it within a few seconds after trying millions and millions of nonces? The Bitcoin protocol has a difficulty adjustment mechanism that prevents this from occurring. Adjusting the difficulty increases the pool of potential nonces, making it less likely to identify the correct one. Consider it as increasing the number of digits in the lock’s unlocking combination. If 1,000 individuals are searching for a five-digit combination, it is likely that they will find it relatively fast. If they are searching for a 100-digit combination, though, the process will take substantially longer. Consequently, based on the current hashrate, the difficulty adjustments compute the necessary difficulty to maintain block durations around 10 minutes and the Bitcoin issuance rate provided by the protocol.

What distinguishes a transaction validation from a transaction confirmation?

You may have noticed on exchanges that a transaction requires a minimum number of confirmations prior to your deposit being credited. Every time the block in which your transaction was originally confirmed advances in the blockchain, a transaction confirmation occurs. Therefore, transaction validation occurs when the transaction is added to a block, and transaction confirmations occur anytime a new block (based on the previous block) is mined. As stated above, it is more difficult to undo a block further down the chain. Therefore, a greater number of confirmations increases security.

Is “bitcoin mining” a suitable analogy?

Analogies are excellent at simplifying abstract or difficult notions, but they frequently fall short when it comes to describing the underlying processes. Therefore, as helpful as the phrase bitcoin mining is for comprehending its aim (i.e., to create new bitcoins and grow the circulating supply, similar to gold mining), it provides no information about the method. In actuality, it can cause a great deal of uncertainty about what bitcoin mining is and diminish the significance of mining as a crucial aspect of Bitcoin’s security, decentralization, and scalability. Considering that the overall amount of bitcoins is capped at 21 million, bitcoin mining will no longer generate new currencies, but it will continue to validate new transactions. People can only hypothesize about what will occur once all coins have been issued. Most likely, a fee market will form and self-regulate in order to keep miners motivated. However, this is still decades away, and if Bitcoin is still in existence by then, it will likely be a vastly more valuable asset. Let us conclude this piece with a little speculation of what such a future would entail:

Bitcoin will become the global currency standard, and network validation will be an issue of national security and sovereignty. Fees on the first layer will be significantly higher (not necessarily nominally, but in purchasing power), and transactions will consist of massive international settlements between 2nd layer liquidity providers (imagine bank settlements today), whereas small transactions will occur on 2nd and 3rd layer solutions with significantly lower fees.

Similar Posts

Leave a Reply