What is Cryptocurrency Mining

Breaking down the components of the term known as Mining

Jerry Qi
Coinmonks
Published in
9 min readNov 15, 2020

--

Source: btcwires

When I was a 7th Grader, I have been sucked into the world of Cryptocurrencies. At first I though it was literally a free money generator where it would just give me free cryptocurrency if I just kept my laptop whirring like a wind turbine running the Crypto-mining software.

In the end, my laptop did produce crypto, however, very very little crypto.

What I was doing with my laptop was essentially “Cryptomining”.

“Mining”

You probably have heard of the cryptocurrency Bitcoin and a term called “mining” being associated with such cryptocurrencies.

Cryptocurrency mining, in simple words, is the process in which miners or individuals use their devices to engage in “work” that supports the blockchain network to receive cryptocurrency rewards.

Sketch of a Small P2P network on onenote

If you are unfamiliar with blockchain: its a network distributed record or ledger that records the actions of those that are connected to the network. Thus, for cryptocurrencies’ blockchain networks, the blockchain would be functioning to record the transactions of individuals on the network. You can also check out my previous article on blockchain structure.

For this article, I will be using Bitcoin as the example cryptocurrency to deconstruct the meaning behind mining.

Coming back to the topic of miner’s “work”. In order for a miner to receive the bitcoin rewards, the simple part of the “work” that miners have to do is the verification of transactions on the bitcoin blockchain.

In verifying, the miner would execute a series of checking to make sure that transactions assigned are legitimate, and the transaction participants are not trying to spend the same amount of cryptocurrency twice. For example, when Joe sends Brandon 12 Bitcoins, and Brandon tries to send Tony 7 Bitcoins and Max 8 Bitcoins, it would be considered a fraudulent transaction since 7 + 8 > 12. The situation I just gave is an example of the “Double Spending Problem” : Brandon is trying to spend same Bitcoins twice.

After a miner has verified somewhere between 0–4 Megabytes of Bitcoin Transactions (Around 1,500–3,000 transactions), equating to the approximate maximum size of a block. They have completed the easier half of the work in order to earn the Bitcoin rewards. However, the tasks that come before the verification is the most complex and makes the miner eligible to verify the transactions.

The Luck Part of Mining

By being the first to solve the calculation for a string sequence, also referred to as creating the proof of work. Creating the proof of work is the most computational effort demanding process for miners. (I will explain why it is called proof of work in the later section below)

In order to understand the proof of work algorithm, you will have to first familiarize yourself with the term “hashes” in blockchains.

The way in which the network detects tampering in a block of the blockchain is through its hash ; A long String of numbers and characters that is defined by the information in the block. By putting data through a hash function such as the SHA-256 used by Bitcoin uses, it generates a sequence that is specific for that certain input. Meaning that if the input data were to even change in one character, the output hash would change entirely. Additionally, the hash is an encryptable but not decryptable result, thus, it cannot be used to obtain the original data, but only as a way to verify that the input data of hashes are the same.

Creating proof of work requires miners to run hashing algorithms to “guess” the suitable answer to question. For the Bitcoin Blockchain network, miners have to be the first to create a hash that meets a certain set of requirements, which is called the “target hash”.

The necessary information to guessing the target hash resides in the block header of the new block. Containing: Block version Number, Timestamp, Hash of Previous block, and the Target Hash.

Sketch of the guessing process on onenote

The answer to the target hash is generated by taking the hash of the previous block, present block transaction data, and adding an integer from 0–4,294,967,296 (referred to as the nonce), to be put into the hash algorithm.

If the answer meets the requirements of the target hash, the block is added to the blockchain, and the miner that first verifies the transactions and figures out that nonce that is added to the hash of the block, gets rewarded in Bitcoin. Otherwise, they keep trying to find the nonce that works.

Determining what the nonce that satisfies the target hash requires LOTS of random guessing because of the randomness of the hash algorithms.

Source: Investopedia

Even though trying to find the nonce by itself is already quite hard, there are also ≥ millions of other individuals competing with you on the same network, making the chance that one individual device obtaining the Bitcoin rewards similar to that of winning the lottery. However, you may resort to raising processing power or using multiple devices in order to get a faster Hash Rate (Units Include: KH/s, MH/s, GH/s, etc).

The term Hash-rate can be interpreted as how fast one or a group of devices are guessing numbers and verifying transactions (Is a Measure of Computational Power).

Consensus Mechanisms

A decentralized P2P network like the Bitcoin blockchain with no authoritative figure can only make decisions based on different consensus mechanisms. Consensus mechanisms lay at the purpose of mining along with transaction verification.

Source: Wikipedia

There are many variations of consensus mechanisms, but they all serve a single goal: “To verify and ensure that records are true and honest” (Source: Tech in Asia).

There are three main mechanisms: Proof of Work, Proof of Stake and Proof of Authority. In this article, I will focus on the Proof of work method of consensus.

We have talked about mining, which sums up how the proof of work model works : Where individuals first has to create a proof of work, then they verify the BTC transactions and makes sure the records in the blockchain are true. However, lets dive down into the purpose of the proof of work that comes before the verification of transactions.

History and Purpose of Proof of Work

This idea of proof of work had emerged in 1993, brought to light by Cynthia Dward and Moni Naor on a paper (On Memory-Bound Functions For Fighting Spam), explaining different methods to stop spam emailing. The paper focused on the idea of sending emails by computing power.

For example, if you want to send a message via email to me, then you will have to prove that you had spent, say, 30 Seconds of computing power just for this message to me.

Because of the rapid speed of modern computers, spamming messages/emails/transactions in this case becomes a big problem. But, by reducing the spam by setting a “price of work” on each action, spam is greatly reduced.

Door key example for verifying hardwork on onenote

In short, a “prover” demonstrates to a “verifier” that they have invested certain computational power in a certain time interval.

As times evolved, the creator of Bitcoin, “Satoshi Nakamoto”, modified the idea for the miner to produce the piece of data/nonce, which is the hard part. And it would be easy for others on the network to verify that it actually satisfies the target hash, as they would just put the data needed through the SHA-256 algorithm.

Through this proof of work system, Blockchain systems such as blockchain are able to ensure security and establish a verified consensus, as the one that actually verifies the block would be a device that has invested great computational power to do so. This gives the network a economic reason to stay fair and honest.

How?
For example, if a fraudulent transaction happens and gets approved, users become “hesitant” and switch to another cryptocurrency, reducing the price. Economically, miners, the ones doing the “production” of bitcoin would get unhappy because of the price drop. And, at the same time, only the controlling miners have enough computing power to trigger fraudulent verification. So, the miners’ incentive shifts toward protecting the transaction to ensure the price of the coin does not drop.

Disadvantages of the Proof of work mechanism

Although proof of work is being used on some of the largest cryptocurrencies (BTC, ETH, etc) it does not mean its the most efficient and secure system.

Source: BBC

Power Consumption

Going through the Proof of work process requires high amounts of processing, as the computer is just guessing the right answer through brute forcing all the possibilities. Wasting lots of electricity and resources. On a bigger scale, imagine all of the miners around the world that are trying to “mine” for the bitcoin rewards, wasting resources and not even contributing to the network if they do not guess the nonce first.

Going against the idea of decentralization

Because of the enormous electricity cost in mining, miners have established central mining farms that take control of large parts of block verification. This almost renders the P2P decentralization idea useless because it means that only the controlling miners would agree to attack the network.

The electricity costs also encouraged miners to gather where electricity costs are less and more profitable for them to operate their mining. Centralizing the “power” of decision.

Alternatives to Proof of Work

As talked about above, there are other consensus mechanisms that are able to replace PoW. Proof of Stake, Proof of Authority and Proof of Capacity.

Proof of Stake determines the transaction verifier through the amount of cryptocurrency the verifier has in their wallet.

For example, Picture a group of people buying a lottery. The person that buys the most tickets would have a bigger chance of winning. This is similar to Proof of Stake, as if you have the most cryptocurrency in your wallet, you would have the biggest chance of being the verifier and getting the rewards.

Proof of Authority determines the transaction verifier through the individual’s “trustworthiness”

Imagine a group of people choosing a few people that would be the most trustworthy and have the best reputation to verify the transactions’ validity.

Proof of Capacity determines the verifier through the individual’s contribution to the memory space of the network.

This mechanism allows for the sharing of memory space among contributing nodes on the network, so the more memory the contributing device has, the more possibility it has to become the verifier and of getting rewarded.

These methods stated above require significantly less computational effort and can be much more power efficient in the verification of the transactions.

Summary

  • The act of Mining is the process of verification and generating proof of work
  • Generating Proof of work allows the miner to verify the transactions
  • Generating proof of work is a number guessing and brute forcing process
  • Proof of Work wastes electricity and there are other ways to go than proof of work such as Proof of Stake, Proof of Capacity, Proof of Authority

Ending note: Despite Proof of Work’s current popularity, I feel it will soon be replaced by other consensus mechanisms that provide better efficiency while ensuring security for the blockchain. Current projects including the Proof of Stake Ethereum2 development, of which you can get involved in the early development of before Dec 23, 2020.

Thank you for reading this article. I’m Jerry, a Grade 10 student who is passionate for Blockchain, Bio Technologies and Computer Science.
If you want to further connect or give me some feedback, feel free to add me on Linkedin.

Also, Read

Get Best Software Deals Directly In Your Inbox

--

--