Core Principles of Crypto Mining

Crypto mining on the surface may seem fairly straightforward, but under the surface lies many technical intricacies.

Cryptocurrency Mining is a record-keeping process performed using computer processing power. The process involves adding transaction records to a cryptocurrency’s public ledger of transactions. This public ledger of past transactions comprises a chain of blocks known collectively as the blockchain.

Miners maintain the blockchain’s consistency, completeness, and immutability by grouping new transactions into a block and then broadcasting them to the network to be verified by recipient nodes.

Nodes use the blockchain to separate valid transactions from attempts to spend coins again after they have already been spent somewhere else. They keep a protocol running by downloading and verifying the blockchain.

Mining is intentionally made to be resource-intensive and difficult to keep the number of blocks discovered by miners daily consistent. For a block to be valid, it needs to have a proof-of-work. Bitcoin, which pioneered this consensus mechanism employs the hashcash proof-of-work function. Each time a block is broadcasted on the Bitcoin network, other nodes must verify this “proof of work.”

Other popular proof-of-work cryptocurrencies include Litecoin, Dogecoin, and Ethereum 1.0.  Ethereum switched from a proof-of-work consensus mechanism to proof-of-stake as a less energy-intensive alternative in mid-September 2022.

The primary goal of mining is to create a computationally unalterable transaction history. In this article, we’ll use the Bitcoin protocol to explore how crypto mining works.

Cryptographic Hashing

Cryptographic hashing is the core technology that underpins Bitcoin’s security and immutability. A cryptographic hash function is a mathematical algorithm that maps random-size input to a fixed-size string. It relies on the following set of characteristics to validate transactions:

1. Deterministic: The resulting output for any input into the cryptographic hash function is always the same.

2. Convenient: Computing the hash function’s output is a relatively quick process that doesn’t require heavy computation.

3. Unique: Each input to the function should yield a wholly random and distinct output.

4. Irreversible: A hash function’s output cannot be reversed to yield the original input.

The SHA-256 hash function, used as the foundation for Bitcoin mining, satisfies the above properties.

The SHA-256 hash function produces a 256-bit number, the most fundamental computation unit, typically displayed using 64 characters in the hexadecimal number system for human readability. The SHA-256 function’s output is referred to as the hash value.

In the Bitcoin network, double hashing is used as a safeguard against birthday attacks— a kind of cryptographic attack that takes place when an attacker manages to create the same hash as another input by using an entirely different input, or collision.  Double hashing involves using the output of the original SHA-256 function to feed right back into the SHA-256 function and produce a second output.

Birthday attacks violate the uniqueness property, without which two different Bitcoin blocks could be represented by the same hash, implying a larger security issue— attackers can potentially switch out blocks. By hashing the hash, the chance of a collision is cut in half, further enhancing the protocol’s security.

Components of a Block

A Bitcoin block is made up primarily of 2 components:

1. Transactions, as a Merkle tree.

2. The block header

Transactions

Mining computers gather enough transactions to fill a block and organize them into a Merkle tree. In a Merkle tree, transactions are hashed with the SHA-256 function and placed as leaves at the tree’s base. Two leaf transactions are combined and hashed once more using the SHA-256 function to create the parent of the leaves. Until a single root is formed, this parent is repeatedly hashed upwards along with the parents of other hashed transactions.

The root of the Merkle tree hash serves as an immutable summary of all the transactions in that particular block. Therefore, if a malicious actor attempted to make changes in a block, its hash would be altered. This hash change would spread up the transaction’s Merkle tree until it affected the root hash. Any node can quickly detect this malicious act by comparing the root of the modified block’s Merkle tree to the root of a valid block’s Merkle tree.

The Merkle root is stored in the block header.

The Block Header

The block header is a summary of the block’s contents. It consists of the following six elements:

• The software version that the client is using

• The block’s timestamp

• The Merkle root (root hash)

• The previous block’s hash

• A cryptographic nonce

• The target

Miners use this information to solve the hash puzzle and add new blocks to the blockchain.

Solving the Hash Puzzle

Miners must solve the hash puzzle by finding a hash value less than the network’s difficulty target. The target, which is stored in the header, is expressed as a 2²²⁴ (a 67+ digit number) value that determines the mining difficulty based on the number of miners competing to solve this problem.

This difficulty is recalculated after every 2,016 blocks based on how long it took miners to solve an equation in the previous 2,016 blocks. This contributes to keeping the blockchain’s transaction appending rate at 10 minutes.

To solve the hash puzzle, miners attempt to calculate the hash of a block by adding a number (beginning with 0) called the nonce to the block header and hashing that value. If the hash value is greater than the target, the miner will increment the nonce by one, add it to the block header again, and hash the new value. This procedure is repeated until the hash value produced is less than the target.

The Miner Reward

The fastest miner to successfully add a new block to the Bitcoin network is rewarded with freshly created Bitcoins. Before mining the block, each miner adds a new output transaction to their block that assigns 6.25 Bitcoins to themselves. When the network receives a newly validated block, it will recognize this additional transaction as valid.

This process is referred to as a generation transaction. In addition, the miner receives the fees paid by users transacting as an incentive to include the transaction in their block.

Bitcoin Halving

The block reward given to miners is cut in half every 210,000 blocks mined (roughly every four years) in an event known as halving. Halving aims to maintain a stable price for Bitcoin by reducing inflation and the rate at which new Bitcoins are released into circulation.

When Bitcoin first debuted in 2009, the reward for each block mined began at 50 Bitcoins. The first block is known as the genesis block, and the first transaction recorded in it was a single transaction that paid the creator, Satoshi Nakamoto, a reward of 50 Bitcoins. To date, three halving events have occurred, and the block reward has gone from 50 BTC in 2009 to the current 6.25 BTC.

The next Bitcoin halving event is scheduled for around May 1st, 2024. Bitcoin halving should continue until all blocks have been mined and the 21 million supply cap has been reached, which should happen around 2140. Following that, Bitcoin miners will only earn money from transaction fees.

Proof-of-Work Validation

When a miner finds a hash value less than the target, they then send the mined block’s components to any connected nodes. The node that receives the block will first check the transaction set to ensure that all transactions are properly signed and that no coins are being double-spent.

After that, it will double-hash the block header to ensure the value is less than the block’s included target value. The node will then continue to distribute the block across the network once it has been determined to be valid so that every node can update its copy of the ledger.

Key Takeaways

  • Cryptocurrency mining is the method used in a decentralized cryptocurrency protocol to validate transactions and create new coins.
  • Solving the hash puzzle requires miners to identify and add a number known as a nonce to the block header, such that when the block header is hashed, the resulting value is less than the target based on the difficulty requirement.
  • Because of the proof-of-work mechanism and cryptographic hashing, an attacker can’t alter a block on the blockchain without altering all subsequent blocks. With each new block that is added to the network, this difficulty keeps rising.

History of Cryptocurrency
What is a Crypto Wallet?
What is a DAO?

Author:
Ken Melendez
✍️ Head of Content @ Cindicator
📊 Certified Bitcoin Professional
🔐 Blockchain Chamber - Chapter President

Who is Cindicator?

Cindicator is a world-wide team of individuals with expertise in math, data science, quant trading, and finances, working together with one collective mind. Founded in 2015, Cindicator builds predictive analytics by merging collective intelligence and machine learning models. Stoic AI is the company’s flagship product that offers automated trading strategies for cryptocurrency investors. Join us on Telegram or Twitter to stay in touch.

Disclaimer

Information in the article does not, nor does it purport to, constitute any form of professional investment advice, recommendation, or independent analysis.