Proof-of-Work and Mining Difficulty are two criteria that are inter-related and relevant in the subject of bitcoin mining. First, let’s take a look at the hashcash proof-of-work that is the foundation of bitcoin mining.
Bitcoin uses the hashcash proof-of-work function in its mining core and validation of blockchain transaction log. In creating these hashcash proof-of-work, bitcoin miners deploy huge amount of resources in the form of mining hardware (capital investment) and electricity (operational investment), who are in turn rewarded with bitcoin with every successful block validated. This applies to bitcoin miners who use CPU, GPU, FPGA or ASIC based mining. Due to the nature of bitcoin mining being a highly competitive activity, the fastest and most efficient of the four – the ASIC chip – has rendered the other three forms of mining methods less viable at best, and completely obsolete at worst.
The hashcash proof-of-work function was invented in 1997 by Adam Back to serve as an anti-DoS (Denial of Service), used to prevent anonymous remailer, email spams and network abuse throttling. The principle behind this is hashcash proof-of-work requires expense of energy and resources, which taking the example of email spams, discourages the email spammer as mass email sending then becomes less viable.
The hashcash proof-of-work in preventing email spams and other uses mentioned above is based on the SHA1 (or Secure Hash Algorithm 1), which offers up to 160-bit encryption. Bitcoin uses SHA256 for 256-bit encryption for higher level of security and more resource-intensive hashcash proof-of-work. SHA256 also offers 128-bit security, which Bitcoin is built-upon. While SHA256 was used when Bitcoin first started in 2008 and 2009, these days Bitcoin is using two hash iterations known as SHA2562 or SHA256 function squared. By iterating it twice, SHA2562 becomes more robust against attacks.
There have been talks about utilising hashcash based upon the newer and more secure SHA3, but there are implications that make it unsuitable for bitcoin mining for now, one of which is the invalidation of all existing ASIC mining hardware. At least, SHA3 is not required at this moment, and will likely only be used in the advent of new security risks.
To understand how a hashcash algorithm works, it would be best to take a look at the following function:
n.b. Note that the example below has been simplified with arbitrary figures to facilitate easier understanding of the hashcash proof-of-work function. In reality, it is a whole lot more complicated. Let’s begin.
Consider the equation a x b = c
If a large arbitrary figure c was such that
c = 5,367,745,493
it would be extremely difficult to figure out the numeric values of a and b.
It can take practically an infinite number of attempts or guesses to derive the correct figures.
So, in bitcoin mining, amongst all the miners who are involved in validating a particular block of transactions, the first miner who successfully figures out that a = 64,951 and b = 82,643 will be rewarded with bitcoin for that particular block, which at this moment in 2017, is 12.5 bitcoin per block.
However, before the bitcoin are awarded to the successful miner, other miners will need to check and verify that the figures were correctly derived by that miner, and this is quickly and easily verifiable by the other miners simply by multiplying a and b to check if it equates to c.
This is similar to how the hashcash algorithm works, by laying an insurmountable problem such that given only c, it is extremely difficult to derive a and b, but easy to check out after making known a and b that any other miner can quickly verify.
- The mining hardware with the fastest hashrate, and therefore the one which can afford the most number of guesses in the shortest time possible, would thus be the one more likely to figure out the correct solution first.
- To add to that, the mining hardware which runs the most efficiently with as low a power consumption as possible, would be the one to retain more of the bitcoin in profit and expend less of it in electricity and cooling.
And so it is the hashcash proof-of-work and these factors that form the basis for bitcoin mining. Do note that the above is a simplified explanation of how the hashcash proof-of-work functions, and in reality, it involves guessing the correct number of prefix zeroes and is more complicated.
Here is a visual demo that describes the actual processes involved in bitcoin mining:
Bitcoin Mining Difficulty
Like a market with perfect competition, as long as there is profit to be made, new entrants will continually enter the market until profit opportunities are depleted. In Bitcoin space, this is similar but with a slight twist – an algorithm regulates matters to keep the “market” in equilibrium. The Bitcoin network sets and adjusts the mining difficulty, such that the work required by the miners to successfully find a block with the correct solution (as given in the example above) takes approximately 10 minutes.
As more miners participate in bitcoin mining, the network automatically adjusts the mining difficulty so as to keep the time it takes to successfully find a block consistently to roughly 10 minutes. Likewise, as miners pull out of the system for whatever reasons, the network throttles its difficulty down to ensure that a block is still found once every 10 minutes or so.
This rate at about 10 minutes per block, coupled with the halving (of bitcoin quantities per block) that takes place every 210,000 blocks (over every 4 years), is crucial and instrumental in the final total of 21 million bitcoin to be completely mined by the year 2140.
Watch the following video for a more detailed and technical explanation of what bitcoin mining is: