If you are involved with Bitcoin, then you must have heard about “cryptography” or “hash algorithms”.
But what do these things have to do with your BTCs?
Cryptography or hash algorithms are what keep Bitcoin’s blockchain secure. They are the building blocks of the present-day cryptocurrency industry.
In this article, we are going to talk about cryptographic hash algorithms in detail.
To start with, it is important to have a general idea of what a hash function is and what it does.
What is a Hash?
A hash algorithm takes data of any arbitrary size (numbers, alphabets, media files) and transforms it into a fixed alphanumeric string. The fixed bit size can vary (like 64-bit or 128-bit or 256-bit) depending on what hash function is being used.
And this fixed size output is what is called a hash. In other words, a hash is the cryptographic byproduct of a hash algorithm.
The hash algorithm has certain unique properties:
- It produces a unique output (or hash).
- It is a one-way function.
The mathematics behind the hash algorithm ensures that there is no way to generate the original data from its generated hash. This means the hash only functions in a linear progression. A simple analogy would be that you can’t produce a real human thumb from a thumbprint.
This is why a hash can be treated as a “digital fingerprint” of the data processed through the hash function.
To logically conclude, the same hash will only be generated from the same input data. But if you modify the data with something miniscule, like a single space or a comma, it will completely change the hash output.
And Bitcoin’s blockchain uses this cryptographic hash function’s properties in its consensus mechanism.
What is a Bitcoin Hash?
Bitcoin’s blockchain uses SHA-256 (Secure Hash Algorithm). In 2001, SHA-256 was developed by the National Security Agency (NSA) in the USA.
Bitcoin’s proof of work algorithm is based on SHA-256. Using this, Bitcoin miners solve computationally difficult math problems to add blocks into the blockchain.
Bitcoin blocks are added by verifying the hashes on a lottery basis. Yes, a lottery!!
Let see how a miner wins the lottery…
To successfully mine a block, a miner needs to hash the block’s header in such a way that it is less than or equal to the “target.”
The target, at the time of writing this article, is that the SHA-256 hash of a block’s header must be a 256-bit alphanumeric string, and must start with 18 zeros. The target changes as the difficulty changes every 2016 blocks.
And the miners arrive at this particular hash (or target) by varying a small portion of the block’s headers, which is called a “nonce.” A nonce always starts with “0” and is incremented every time for obtaining the required hash (or target).
Since the varying of the nonce is hit and miss, the chances of getting this particular hash (or target), which starts with these many zeros, is very low. Therefore, many attempts must be made by a miner by varying the nonce.
And this requires an enormous amount of computational power and hardware resources which proves that a large amount of work is carried out before mining any individual block. That’s why this is called “proof-of-work“.
And in this way, whichever miner first obtains the correct Bitcoin Hash will win the lottery and get the block reward of 12.5 BTC.
I am sure that after reading this you want to participate in this lottery. But let me tell you, Bitcoin mining is a costly and energy-intensive affair. It requires you to make expensive hardware investments, pay for huge electricity bills, and demands that you have a good amount of computer knowledge.
And until you are ready to become a miner, keep working hard in your current profession and stay tuned to basilpuglisi to keep learning about the Bitcoin Revolution.
Like this post? Don’t forget to share it!
For further reading: