Proof of work, often abbreviated as PoW, is a system for preventing double spends. It is a consensus algorithm for blockchain, which is the underlying consensus model for bitcoin. Proof of work also forms the basis of other cryptocurrencies. It describes a specific system that needs a significant but feasible level of effort to prevent malicious or frivolous use of computing power like distributing spam emails or launching denial of service attacks. PoW remains the dominant consensus algorithm to date.
A brief History about PoW
Did you know that Bitcoin is the cryptocurrency behind the invention of PoW? The concept was founded in 2004 by Hal Finney through the idea of ‘reusable proof of work’ but was adopted and implemented in 2009 following the introduction of bitcoin by Satoshi Nakamoto. Hash cash by Adam Back is also an early example of a proof of work algorithm before cryptocurrency came to the picture. Senders are required to conduct a small amount of computing before sending emails so that receivers can mitigate spam.
This kind of computation is virtually free for any legitimate sender, but can quickly add up for anyone sending emails to en masse. Legitimate emails will do the work of generating proof quickly, especially if it is a single email. Spammers, however, will have a difficult time producing the needed proof, which requires extensive computational resources. Hash cash proof of work is used for block generation in bitcoin. Miners have to complete a PoW that covers the entire data in the block for a block to be allowed in by new network participants. The Difficulty here will need to be slightly adjusted to limit the rate in which the network can create a new block to one in every 10 minutes. However, there is a very low probability of a successful generation; it makes it difficult to determine which worker computer in the network will generate the block first.
For any acceptable block, it must hash to a value that is less than the present target. What does that mean? That will mean that each block indicates that work has already been done generating it. Every block comes with the hash of the preceding block. Hence, each block has a chain of blocks that contain a tremendous amount of work. To change the current block, which can only be done by generating a new one with the same predecessor, requires the regeneration of all successors and redoing the work there. This protects the blockchain from being tampered with.
Why is it necessary?
Is proof of work necessary? Well, if you have an idea of how blockchain technology works, then you have a good idea of how proof of work comes into play and why it is necessary. Users have to broadcast their transactions to the network. These transactions take time to be considered valid when added to the blockchain network. A blockchain is a massive database that is available and viewable by every user so that they can check whether the capital has been spent before or not. It acts as the medium between users by alerting them every action taking place in the database. Here is a good example: Job, Jane, and Bob have a notepad( in this case the notepad is the blockchain) Anytime the three friends want to make a transaction, they need to write it down –Bob paid ten tokens to Jane, Jane paid ten tokens to Shem, etc. Every time any of the three friends make a transaction, they refer to the previous transaction where the funds came from.
So if Jane were paying ten tokens to Shem, the notepad would indicate that Jane paid the ten tokens to Shem after an earlier transaction with Bob, and that’s how the tokens are tracked. That means that if Jane tries to make another transaction with the same tokens, he sent Shem, everybody else will know immediately, and the members will not allow the transaction to be added to the notepad. Well, this sounds easier and manageable for a small group. The members know each other and can decide to play a little out of the notepad. The real challenge is when you have over 20 000 participants from all over the world. How do you ensure that transactions are not repeated? That is where proof of work comes in. It regulates the platform and ensures that users don’t spend what they are not allowed to spend. By using a combination of cryptography and game theory, the PoW algorithm helps keep everyone up to date in the chain using the rules of the system.
How does it work?
In our notepad example, the transactions can be added one by one, but when it comes to blockchain, transactions are lumped into blocks. The transactions are announced to the network, and every user generating a block will include them in a candidate block. Once the candidate block becomes a confirmed block, the transaction is considered valid, meaning that it has been added to the blockchain. Adding a block is not easy nor cheap. Proof of work requires the miner to use some of their individual resources in order to enjoy the privilege. That particular resource is the computing power that can hash the block’s data until the solution to the puzzle has been found. Hashing a block’s data is achieved by passing it through a hashing function to create a block hash. The block hash functions like a ‘fingerprint’ where it acts as an identity for your input data. It is specific to each block.
However, it is essential to keep in mind that it’s virtually impossible to reverse a block hash to acquire the input data. If you know the input, it’s also essential to make sure that you have confirmed that the hash is correct. It is as simple as running the input through the function to check whether they match. For PoW to be efficient, you are required to provide data whose hash meets specific conditions, but you don’t have to know how to get there. Your primary focus should be the data that you pass through the hash function to see if it matches the conditions. You will need to change the data a bit if the data you passed gets rejected. Any slight change gives you a totally different hash. Therefore, there is really no way of predicting or determining the outcome of an input. In simple terms, you are playing a guessing game by typically combining the information from all the transactions that you wish to add and some magical data and then hash it all together. However, since your dataset won’t change, you will need to add one extra variable piece of information. Failure to do this, you will always get the same hash as output every time. The variable data we are talking about here is called a nonce. It is the number that you will adjust with every attempt you make to ensure that you get a different hash. And that’s what we refer to as mining.
To sum up, mining is the process of combining blockchain data and hashing it with nonce until a certain number is found. If your hash satisfies the set conditions, you earn the right to broadcast the new block to the system. At this stage, miners and groups of miners of the network also update their blockchains to accommodate the new block.
If you have been mining for some time, you may have noticed that mining major cryptocurrencies like bitcoins is getting incredibly complex. The conditions to be met are more challenging to satisfy. Remember, higher hash rates mean that it will be more challenging to generate a valid hash. This is done to ensure that users don’t create blocks easily and quickly. As more and more people join the bitcoin mining industry, so will the mining become difficult, as we should expect the hash rates to increase. Trying to guess such massive amounts of hashes can be costly, particularly to your internet, power, and hardware. You may end up wasting lots of electricity and computational power, but the end result will be a fat reward of bitcoin or any other cryptocurrency you decided to mine
While bitcoin mining is a competitive process, it is more of luck than a race. Generally, every ten minutes, someone will create an acceptable proof of work. That’s why miners come together to work faster and increase their chances of mining blocks that generate transaction faster and share the reward that comes in bitcoins. PoW has proved to be secure and reliable, and bitcoin proved to us that we do not need centralized entities in order to prevent funds from being spent twice. Proof of work ensures that it is extremely difficult to interfere with any aspect of the blockchain as such a disruption will only lead to re-mining the subsequent blocks. PoW also ensures that users do not monopolize the network’s computing power as the power and machinery required to generate the hash functions are pretty expensive.