Blockchain, Cryptocurrency, Mining, Hash Rate! How Does it All Fit Together?
As the co-founder of a small cryptocurrency mining operation I am often asked by people from outside the industry questions regarding the nature of blockchain, mining, and how cryptocurrency really works! While my verbal answers are usually fairly brief, I think these questions warrant a more encompassing explanation that can be understood by those, like me, who do not have a background in computer science. Outlined below are explanations of what I believe to be the key concepts behind how cryptocurrency and public blockchain technology work.
Cryptographic Hash Functions
Cryptographic hash functions can be somewhat tricky to understand for laymen but they are utilized in almost all aspects of cryptocurrency and public blockchain networks. As a fundamental building block of the technology, and a common industry term, it is important to have a basic understanding of what they do.
First let me define a general hash function as a mathematical algorithm used to map data of any size to data of a fixed size. For example:
School history essay (1000 words) => Hash Function => cf23df2207d99a74fbe169e3eba035e633b65d94 (40 character data string)
The word “Cat” => Hash Function => rx0bb5654a6F5e05932f73f102CfC570585c3B4f (40 character data string)
The returned data string is known as a hash value, digest, or hash. As the output hash is generally much smaller than the input data, it’s easiest to think of a hash function as compressing the original data much like a zip file on your PC. Hash functions are often used within computer software for data indexing and swift data lookup.
Public blockchain technology uses a specific type of hash function known as a cryptographic hash function. As with the general algorithm, the cryptographic hash functions maps data of any size to data of a fixed size and it also makes this process infeasible to invert.
For example, it is not possible to look at cf23df2207d99a74fbe169e3eba035e633b65d94 and recreate your old 1000 word history essay. In fact, reconstruction of the original input data from the cryptographic hash is only possible via what is known as a brute-force search through all the possible input combinations until a matching hash is outputted.
A cryptographic hash function has several key characteristics:
· The same input data always produces the same output hash
· A small change to the input data alters the output hash comprehensively
· Hashes are “collision-free” (i.e. it is not feasible for two different data inputs to have the same output hash)
· Given any input data string the hash function computation is relatively fast
· It is not feasible to recreate the input data from its output hash except by a brute-force search through all the possible data inputs
It is important to understand that public blockchain networks are literally built on cryptographic hash algorithms. They are used to increase efficiency and security in almost all basic network processes. But what are the basic network steps when dealing with public blockchain technology?
Blockchain Network Basics
The use of blockchain technology has enabled the creation of decentralized systems that do not rely on a central authority to hold those acting within the system accountable. For example, Bitcoin is a peer-to-peer digital payment system that functions without the traditional banking system keeping track of debits and credits in a centralized ledger.
To understand how public blockchain technology accomplishes this it is best to look at how transactions occur and are recorded via a public blockchain. The key steps in this process can be seen here and I will elaborate below:
1. Transactions are initiated on the public blockchain network
2. The transaction details are verified by public blockchain node software
3. These verified transactions are bundled into a block of data
4. Information from the preceding block is entered into the new block
5. The PoW protocol is successfully completed
6. The new approved block is added to the blockchain and broadcast to other network nodes
So what really is a cryptocurrency “coin” anyway? A digital coin should be thought of as a chain of digitally signed files. A digital signature encrypts a file with digital codes that are extremely difficult to duplicate thus proving its authenticity. In the case of cryptocurrency technology a public-private key encryption system is used to verify that a “coin’s file” has not been altered.
Coin holders transact coins with others by digitally signing a hash of the preceding transaction information and the public key of the new owner, and adding this to the “coin’s file”. The person receiving the coin can therefore verify the preceding signatures to confirm that a change in ownership did take place. This record of ownership is traditionally done by a bank and held on their centralized internal ledger.
In order to maintain trust in this process via a decentralized computer network certain precautions must be taken. For example, what stops a bad actor from duplicating a previously transacted coin and using it again? This is known as a double-spend attack. To safe guard against such an attack transactions must be timestamped (i.e. recorded sequentially), publicly broadcast to the network, and the network must agree on a single history of transaction order. Rather than do this process on individual transactions, the network nodes (i.e. computers) group transactions into data blocks to increase network efficiency.
Blocks contain several pieces of important information. Firstly, they contain the details of a group of recent transactions on the network. Secondly, they contain a hash reference (i.e. a pointer) to the previous block that was added (i.e saved) to the public blockchain. This is in fact where the term “blockchain” comes from as each block is linked to the next by its hash. Thirdly, on the majority of public blockchain networks they contain a random target hash which is an answer to a mathematical puzzle. This puzzle must be solved for the block to be added to the blockchain.
These last two items are what provide most public blockchain networks with security. As each block contains a hash reference to the previous, if a bad actor wanted to change a previously added block they would also need to alter every single block in the chain after that so that the hash references would match. The key process used by the majority of public blockchain networks to make this infeasible is the third item which is known as a Proof-of-Work (PoW) protocol.
In general, a PoW protocol contains a mathematical puzzle that a network requester must solve by expending “work” in order to receive a specified service from the network provider. It therefore creates an economic deterrent for network service abuses such as spam and Denial-of-Service attacks by the requester. An important property of this type of protocol is that the “work” must be difficult but feasible for the requester but easy to validate for the provider.
The PoW protocol is where cryptocurrency miners come into the picture and it relates to the public blockchain in the following way. For a new block of transactions to be added to the blockchain, miners (i.e. network requesters) must expend large amounts of costly computing power to solve for the random target hash set by the blockchain network nodes (i.e. network providers). This process involves the brute-force search mentioned before through all possible input data until a matching hash is found.
This difficult and costly process is a competition between miners, with the first to solve the puzzle receiving a reward. Once completed, the PoW solution is easily verified by the public blockchain nodes. The block is then added to the blockchain and this fact is broadcast to other network nodes. The individual blockchain with the greatest number of miners participating (i.e. forming consensus) is taken as the official record of all previous transactions.
The PoW protocol makes it extremely expensive for a bad actor to try and alter previous blocks as they would then need to “re-mine” all subsequent blocks and do so while controlling over half of the total network “mining power”. This is because they would need to outpace all the honest network miners working to authenticate the original blockchain. Due to the expensive nature of mining (i.e. equipment and electrical costs) this is infeasible!
When a miner successfully completes the PoW protocol they are rewarded for their efforts in that public blockchain network’s cryptocurrency. This new block creation reward scheme is supplied by network transactions fees and the creation of new coins (i.e. where the term “mining” actually comes from). This process of gradually introducing new coins into circulation reduces the risk of inflation.
But hold on! Surely as more miners join the network, and the networks total processing power increases, this process will take less time increasing the rate of new coin dissemination? Therefore, in order to keep the rate of new block creation consistent with a predetermined timeline, the speed at which the PoW protocol can be solved adjusts in relation to the total number of network miners working. This feature is known as network difficulty and the network nodes control this by varying the length (i.e. number of characters) of the required PoW target hash value (a.k.a. the nonce).
For example, it is much harder to find a specific hash via a brute-force search if the target hash is 60 characters vs. only 40. Unfortunately, network difficulty and miner profitability have a negative relationship. To put it simply, the more network miners there are, the more network difficulty increases, and the less likely an individual miner is to achieve a mining reward.
I think hash rate is fairly straightforward. It is the unit of measurement for the processing power of a public blockchain network. For example, if an entire network is said to have a hash rate of 50 TH/s its miners are processing 50 trillion calculations per second. A greater total network hash rate ensures the public blockchain network runs smoothly but it results in an increase in the mining difficulty level (i.e. each miner is likely to earn less).
For an individual cryptocurrency mining farm, the higher the hash rate of the mining equipment in operation the higher the chance of solving the PoW hash algorithm first and the more profitable it will be. For a cryptocurrency mining farm to achieve a higher hash rate it must invest in, and operate, the most advanced mining Application Specific Integrated Circuits (ASICs) and Graphics Processing Units (GPUs) available.
I hope this overview will assist laymen in grasping a better understanding of what is involved in the day-to-day workings of public blockchain technology and cryptocurrency mining. Please feel free to comment with any additional suggestions or complaints regarding this piece.