Whether you are new to Bitcoin and want to dive deeper into its concept or you are an experienced user and looking into building your first mining rig, you need to know about how mining is performed and what are the requirements for doing it.
The terminology used in describing the mining process can be confusing for some. Hence, there are many misconceptions about this process, especially when it comes to inexperienced users. Today we will explain the simple logic behind mining and tell you about the only way of how new Bitcoins get into the network. Let’s kick it off!
The essence of Proof-of-Work
Many of the technologies that Bitcoin utilizes weren’t new or revolutionary at the time of its launch. Before 2008 there were several attempts of creating internet money, like Flooz.com and E-gold. However, they either required a centralized party to control the process or were vulnerable to double spending – a situation when a malicious actor performs two transactions to a different address on the same amount of money at the same time. In case of a double-spending attack, a true peer-to-peer network wouldn’t be able to distinguish which transaction came in first and would approve both. As a consequence, there were no sustainable means of transferring money on the Internet in a decentralized manner.
The beauty of Bitcoin was in that it offered a mechanism that applied the Timestamp mechanism to make double-spending impossible. Finally, the world was presented with an automated system that puts all the transactions in the ledger in chronological order, so the first transaction that made it to the network is considered valid and all other for the same funds are discarded. To secure the list of transactions from being altered by attackers, a Proof-of-Work (PoW) mechanism was introduced. PoW requires users to spend some time and processing power on creating new blocks for the network so that no attacker (or a group of attackers) could make a chain of blocks that is longer than the original one. As only the longest chain is accepted by the network, users can be sure that their money is safe.
PoW and mining
In simple terms, PoW is the way of ensuring that every new block took some time and effort (computing power) for its creation. This prevents people from creating as many blocks as they wish, as there is only so much computing power in the world (even if we would suddenly make a giant technological leap and the processing power of CPUs would surge, more on that later). As a result, the fastest and therefore valid chain is only the one that used the majority of the processing power, meaning the largest number of CPUs.
PoW is based on Bitcoin’s hash. Hash is a one-way cryptographic function (meaning that it’s extremely difficult to reverse the result) that converts an input into a string with a fixed number of symbols. In the case of Bitcoin, the SHA-256 hashing algorithm is used. After a block is created and filled, all of the transactions there are ran through SHA-256 and the result is put at the beginning of the next block. This chaining mechanism ensures that previous blocks in the chain are intact, as changing a single transaction will produce an entirely different string of symbols that will make a block invalid.
Mining and mining difficulty
Mining Bitcoin basically means creating a new block and getting a reward for it, which is currently 12.5 BTC per each block that is mined roughly every 10 minutes. Anyone can join and abandon the process at any time. Only one miner (node) can generate a single block and despite the popular misconception, who is going to mine a block depends greatly on chance, rather than on the amount of computational power that users possess.
A block header is a crucial part of the mining process. It includes a version of Bitcoin core, a timestamp (time of creation), a previous block’s hash, a Merkle root (hash of the hashes of the transactions within the previous block), a difficulty target and a nonce. A difficulty target is a number written 256-bit format to match the length of the SHA-256 hash. Together with the nonce, it is used by miners for generating new blocks.
To mine a block, miners run hash function through the block header of an existing block and compare it to the difficulty target. Should the hash be lower than or equal to the difficulty target, a block is created and the miner that produced the appropriate hash gets the reward. Hashing is deterministic, meaning that a hash would not be different for the same set of data. This is where the nonce comes into play. Miners keep increasing the nonce to get the appropriate hash. The lower the target number is, the more difficult it is to get a hash that fits into the requirement.
Mining difficulty and hashrate
At this point in reading, you are probably wondering who is changing the difficulty of the network and why. To understand the reasons behind difficulty adjustment, we first need to figure out the concept of hashrate.
We already know that in order to create a block, a miner must be hashing a latest block’s header until they get a value lower than the target number. To do so, a miner needs a machine with a CPU(s) capable of doing so. A number of hashing operations that a computer is able to do in a second is called hashrate.
Remember that mining is more of a lottery than a race, so the higher hashrate doesn’t mean that a given miner is going to create every block. However, the more operations a miner can do, the better are their chances of finding an appropriate hash faster than others. The hashrate is denominated in hashes per second. Most commonly, miner rigs’ processing power is measured in Mega Hashes (MH, one million hashes), Giga Hashes (GH, one billion hashes), and Tera Hashes (TH, one trillion hashes).
These days, mining has become a profitable business for large companies with enormous numbers of high-performance CPUs and cheap electricity. Such giants are using thousands of Tera hashes every day, fighting for the privilege of making new blocks and therefore getting new Bitcoins. However, at the dawn of Bitcoin users used their home computers and laptops and still managed to mine Bitcoins for quite some time. How was that possible?
Bitcoin is designed to maintain certain mining difficulty so that it takes on average 10 minutes to produce a block. If miners are struggling with a target difficulty set too low, the network raises it and vice versa. The protocol for this is called difficulty retargeting. Once 2016 blocks are mined (which takes roughly two weeks), the network goes through their headers to analyze the timestamps. If the network was moving too fast, the difficulty target number in the very next block will be lower, if the network took more time than expected, the number will be higher. This is why even if Intel or AMD suddenly start producing CPUs with exuberant throughput, it will take Bitcoin very little amount of time to adjust to the pace and return to the classic formula of producing one block in ten minutes. A new difficulty is a multiplier of the old difficulty and a quotient of 20160 minutes & number of minutes spent on the last 2016 blocks.
All in all, Bitcoin mining is not difficult to get around, but certain casual and technical terms along with the novel notion of internet money can seem daunting at first glance. To understand what mining difficulty and hashrate are, you need to keep in mind only a handful of things:
Mining is required by the network to function securely.
Mining Bitcoin means creating new blocks and being rewarded in the form of new coins.
To mine is to use CPU power (hashrate) to a run block header through the SHA-256 function with different nonces until a difficulty target is met.
A difficulty target is a number in 256-bit format, and this format ensures that the length of such a number is the same as SHA-256 hash.
We hope that our article made Bitcoin mining clear for you. This will be a great help in explaining cryptocurrency principles to your friends and relatives, avoiding fraud and making some side income by mining. Enjoy!
Subscribe to U.Today on Twitter and get involved in all top daily crypto news, stories and price predictions!