How Bitcoin’s Consensus Mechanism got inspired by Adam Back’s HashCash ?

post image

If you are someone, who used to think , Bitcoin’s consensus mechanism i.e Proof Of Work (PoW) came into existence in late 2000s along with bitcoin , you are not alone!

Preview:

Bitcoin is a decentralized digital currency harnessing the core principles of blockchain technology. Its decentralized nature gives rise to various questions such as:

a. How bitcoin transactions are validated?

b. How to tackle double spending attack in a decentralized system?

c. Who will validate the transactional records and ensure their integrity?

Well, that’s what Proof of Work(PoW) is meant for and it’s meant for a lot more than that !

When the system is managed by a central authority, the monitoring of which inputs are used in a transaction and their spent/unspent status is managed simply on a first seen basis.

What is Proof of Work (PoW)?

post image
  • In Bitcoin network, the system has no such means for centralised decision making so each network participant must operate as a self-contained mint.

  • Nodes race to expend their computational resources to find solve a complex mathematical puzzle so that their work is honoured by the network earning reward in the form of bitcoin, a.k.a Proof Of Work (PoW).

PoW, being a consensus mechanism is a system that validates a transaction and marks it as authentic. It is a protocol that brings all nodes of a distributed blockchain network into agreement on a single data set. They act as verification standards through which each blockchain transaction gets approved.

Important Elements of PoW Consensum Mechanism:

  1. Hash:

Process of hashing mechanism
Process of hashing mechanism

1. Hash

  • The hash is a 64-digit encrypted hexadecimal number. With moderntechnology, a hash can be generated in milliseconds for a large amount of data.

  • In the realm of blockchain technology, hashing is a critical component that guarantees the integrity of data stored within each block.

  • Each block in a blockchain holds information such as transaction amounts, wallet addresses, time, and date are recorded and encrypted into a block header.

  • In blockchain, whenever a transaction occurs, that transaction’s data is taken as input to the hash function, which then produces a unique output.

  • Each block consists of multiple transactions, and each transaction is represented by its hash.

2. Nonce

A portmanteau of ‘number used only once’,it is a 32-bit number that miners use to generate a valid hash to produce a new block in the Bitcoin.

Nonce value is iteratively changed to until a desired hash is found
Nonce value is iteratively changed to until a desired hash is found

Nonce value is iteratively changed to until a desired hash is found

  • The Proof-of-Work (PoW) consensus algorithm works by requiring each miner to overcome a difficulty level to prove the validity of a block.A block is marked as “valid” only if the hash value of the entire block is lower than the difficulty hash i.e Block Hash < Hash Difficulty .

  • This process is completely based on chance. So the miner’s job is to change the nonce value until the total hash of the block is lower than the difficulty hash.

If the hash is lower than the current network target, the miner has successfully solved the hash.The miner who solves the problem first gets an appropriate amount of Bitcoin as a block reward.

What Exactly is HashCash ?

post image
  • Hashcash is a proof-of-work algorithm, intended to be a countermeasure for email spamming and denial-of-service attack.The Objective is to require computer work on a mathematical problem to be verified before sending an email.

  • For an email sender, the process involves preparing a special email header appended with a numeric value a.k.a counter. It then computes the 160-bit SHA-1 hash of the header.

  • If the first 20 bits of the generated hash are all zeros, then this is an acceptable header. If not, then the sender increments the counter and tries the hash again (similar to nonce in PoW). The process is carried out for each e-mail to be sent.

HashCash proves to be a major blow for email spammers whose businesses are based around sending huge number of emails thanks to its mandatory computation.Imagine doing a 5 second job for each and every email to execute a spam attack involving millions of spammed emails !

HashCash, An Inspiration?

Well, HashCash paved the way for the foundation of very first consensus mechanism i.e PoW such that it is the mining function used in bitcoin. The idea of, incrementing a nonce until a desired hash of block is found, is similar to that of incrementing a counter inside an email header.

But PoW differs from Hashcash in some of the aspects.

  • HashCash uses SHA-1 algorithm to generate a hash while bitcoin uses SHA-256.

  • Bitcoin’s protocol adjusts the difficulty level of target hash to prevent over/under production of new coins. The only current mechanism to upgrade hashcash default (20 bits) is via a sofware update.

  • HashCash difficulty can only double or halve, bitcoin uses more fine grained difficulty adjustment

Although HashCash did not succeed in the long run, it played a pivotal role in shaping Bitcoin, which emerged as the first truly global, borderless, and censorship-resistant form of currency.