Ethereum Classic

How Does Bitcoin Mining Work?

One of the most surprising things people that are new to cryptocurrencies have trouble with is the notion of crypto mining. The idea that one can literally make money blows newbies’ minds and lend to the notion that crypto must be nothing but a scam.

Mining, however, is a complex concept. Most cryptocurrencies are arguing if this, the first consensus methodology to be tested, is viable or if a new method is needed. Mining offers both benefits and challenges to a crypto asset which could, in the long run, determine the efficiency and appeal of that asset. While the appeal of “free money” may be enough to get some would-be user through the door, the question is if it is enough to keep them here?

This article will look at bitcoin mining, ask how it works, and question its future viability.


Finding Consensus

To start, we should look at our terminology. “Mining” is a bit of a misnomer, as there is nothing physical being discovered or excavated. However, the term became popular because – for some – bitcoin is digital gold, and it makes sense to say that you “mined” bitcoin.

The technical term for “mining” is “proof-of-work” consensus finding. Satoshi Nakamoto, the founder of bitcoin, saw the need for proof-of-work like this: “To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof-of-work system similar to Adam Back’s Hashcash, rather than newspaper or Usenet posts. The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.”

“For our timestamp network, we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block’s hash the required zero bits. Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it.”

“The proof-of-work also solves the problem of determining representation in majority decision making. If the majority were based on one-IP-address-one-vote, it could be subverted by anyone able to allocate many IPs. Proof-of-work is essentially one-CPU-one-vote. The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it. If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes. We will show later that the probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added.”

“To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they’re generated too fast, the difficulty increases.”

A way to interpret this is to think of this as a workplace lunch carpool. Each day, you and a group of your coworkers decide where to go for lunch and drive their together. To avoid fights, everyone agrees that there will be a vote for where to go, with the consensus deciding. This is fine and good when you know everyone that will be in the car with you.

However, what happens when new people join the carpool? You have no reason to trust these new people and they have no reasons to trust you. Worse, since they may feel that everyone in the carpool are friends, they may feel that are being actively opposed and may have a reason to openly act against the wishes of the carpool. How exactly do you get a consensus in a group where there may be hostile actors?

In cryptography, this is known as a Byzantine Generals’ Problem. In its purest form, it’s a question of how a computer system could trust its components if it cannot guarantee that all its components are working or if any of its components could or would effectively diagnose its own failure.

“A reliable computer system must be able to cope with the failure of one or more of its components. A failed component may exhibit a type of behavior that is often overlooked–namely, sending conflicting information to different parts of the system.,” Leslie Lamport, Robert Shostak, and Marshall Pease of SRI International wrote explaining the Byzantine Generals Problem. “The problem of coping with this type of failure is expressed abstractly as the Byzantine Generals Problem. We devote the major part of the paper to a discussion of this abstract problem and conclude by indicating how our solutions can be used in implementing a reliable computer system.”

“We imagine that several divisions of the Byzantine army are camped outside an enemy city, each division commanded by its own general. The generals can communicate with one another only by messenger. After observing the enemy, they must decide upon a common plan of action. However, some of the generals may be traitors, trying to prevent the loyal generals from reaching agreement. The generals must have an algorithm to guarantee that A. All loyal generals decide upon the same plan of action. The loyal generals will all do what the algorithm says they should, but the traitors may do anything they wish. The algorithm must guarantee condition A regardless of what the traitors do.”

“The loyal generals should not only reach agreement, but should agree upon a reasonable plan. We therefore also want to insure that B. A small number of traitors cannot cause the loyal generals to adopt a bad plan.”

“Condition B is hard to formalize, since it requires saying precisely what a bad plan is, and we do not attempt to do so. Instead, we consider how the generals reach a decision. Each general observes the enemy and communicates his observations to the others. Let v(i) be the information communicated by the ith general. Each general uses some method for combining the values v (1) ….. v (n) into a single plan of action, where n is the number of generals. Condition A is achieved by having all generals use the same method for combining the information, and Condition B is achieved by using a robust method. For example, if the only decision to be made is whether to attack or retreat, then v(i) con be General i’s opinion of which option is best, and the final decision can be based upon a majority vote among them. A small number of traitors can affect the decision only if the loyal generals were almost equally divided between the two possibilities, in which case neither decision could be called bad.”

The way forward for our carpool is to find a trustless way to vote, or a way to vote where the fact that most of the people in the car are friends do not matter. Let’s say that the carpool’s rules are that you vote by paperclipping a $20-dollar bill – your share of the meal’s cost – to your vote. Suddenly, the prospect of attempting to sabotage the process have a real-world consequence. It would behoove you to choose a choice where both you can be happy and where the group is likely to choose to prevent the loss of your investment.


Bitcoin’s Proof-of-Work

In bitcoin, this is done through proof-of-work. The idea is to create a stake that is hard to reproduce but easy to verify. That stake is a computational solution of the current transaction records on the bitcoin blockchain.

Every computer running the Bitcoin Core software is broadcasted transactions to verify. When the transaction was made, it was encoded using an encoding algorithm called Secure Hash Algorithm (SHA)-256, a hashing algorithm originally designed for use by the NSA. The hash algorithm is run twice, making bitcoin’s hash algorithm “double SHA-256.” The computers or nodes receiving the transaction will verify that the encryption produced the correct hash and place it in the current transaction receptacle or block.

The key behind this algorithm is that it is significantly more difficult to solve the equation than to prove it. This makes it expensive resources-wise to fake a solution. This resource-imbalance is a key function of proof-of-work systems, which will be elaborated on later.

Due to this resource-imbalance, the process of verifying transactions and compressing blocks can be expensive energy- and timewise. To compensate, proof-of-work systems utilize a reward mechanism. The idea is this: computers can guess on what the address of the next block will be. The rules are simple:

  • The address must be based on the result of the double-SHA hash of the current block;
  • The address must utilize a nonce or a one-time use random number, that is multiplied into the double-SHA hash;
  • The prefix of the address must have the right number of leading zeroes;
  • The address must be greater than the previous one, but less than the current target;
  • The first one with a qualifying address win. In case of ties, the computer that came up with the answer by doing the most transactions win; and
  • Losing blocks are discarded. (In Ethereum, they are used to offload transactions and are called “uncles,” but that is a different cryptocurrency.)

The winning computer receives the coins attached to the block it just named, but only after a certain number of blocks have been mined first. This creates a resource burden for those seeking to “double-spend” coins. To achieve this, the would-be thief would have to solve the affected block so that his solution would be the winner. In doing this, he would have to solve every successive block, as blocks are connected via their encryptions.

So, the hacker would need to solve hundreds of blocks before just one new block is added and then gather enough network hash power to convince the network that his version of the is correct. This is why there has yet to be a “51 Percent Attack” on bitcoin; anyone that could do all of this is better served just mining the coin legitimately.

This system begs some obvious problems. One, for example, is the idea that every Bitcoin Core-serving computer is working the same energy-intensive calculations. Per one calculation, the energy cost of all of this is equal to the energy use of the Philippines.

As energy costs increase, many miners find themselves in the situation that the prospect of mining is a cost-leader. In most parts of the world, the energy cost of electricity per block exceeds the price of bitcoin. If one was to consider the true cost of a commodity the cost to make it, then the cost of bitcoin is the collective cost of all Bitcoin Core-running computers that attempted to mine a certain block divided by the number of coins in that block. By this estimate, bitcoin is grossly underpriced.

For this reason, many miners that mine bitcoin do not release them. The hope is to hold on to them until a time that their value will match their true commodity value. The problem with this is that this strangles the supply of the coin on the free market in a time of already strangling supplies due to most miners being unable to afford to mine. Currently, as much as one-quarter of the bitcoin supply is in storage.

Let’s say, theoretically, one hundred years have past and the last bitcoin has been mined. What happens now? There is no motivation for miners to continue to mine, as there is nothing to mine. Transaction fees only goes to the miners that discovered the blocks, so – if they are still alive – only those miners would have a motivation to process transactions. If they are not alive, however, there is no set precedent on how “block rights” should be transferred, creating “ownerless” blocks.

Due to energy costs, this theoretical assumption is closer to a realization than most think. While a resurgence of bitcoin’s price would temporarily resolve this issue, it will remain a Sword of Damocles over the head of the coin for the whole of its existence.

Therefore, many coins have moved away from proof-of-work towards other methodologies, such as proof-of-stake, where delegated transaction provers must verify their sincerity by staking a significant amount of the coin or token.

It is unknown if bitcoin can survive without changing its consensus protocol. However, for now, proof-of-work or “mining” is the system bitcoin users have available to them, for better or worse.

Leave A Reply

Your email address will not be published.