Sem 7

Consensus Algorithms

Unit 2 Bitcoin consensus deck: how miners agree on blocks, flooding, Proof of Work and Hashcash, tamper resistance, double spending, Sybil and DoS attacks, the monopoly problem, power use, Proof of Stake and Proof of Burn.

Consensus in BitcoinSearch on YouTube

Consensus is how all nodes agree on one valid version of the ledger, even though no central authority exists and some nodes may be malicious.

The mining race (deck animation)Search on YouTube

The deck shows a chain of confirmed blocks (Tx1 to Tx5, Tx6 to Tx10, Tx11 to Tx14) and three miners building different candidate blocks:

  1. Each miner picks pending transactions into its own candidate block (one has Tx15, Tx16, Tx18, Tx19; another Tx15 to Tx17; another Tx15 to Tx18).
  2. One miner solves the puzzle first and announces "I have the solution" to the others.
  3. The others check the solution. Its block (Tx15, Tx16, Tx18, Tx19) is added to the chain.
  4. All miners drop their old candidates and start on new blocks with the remaining transactions (Tx17, Tx20 to Tx23).

Steps to run the networkSearch on YouTube

  1. New transactions are broadcast to all nodes.
  2. Each node collects new transactions into a block.
  3. Each node works on finding a difficult proof-of-work for its block.
  4. When a node finds a proof-of-work, it broadcasts the block to all nodes.
  5. Nodes accept the block only if all transactions in it are valid and not already spent.
  6. Nodes express their acceptance of the block by working on creating the next block in the chain. They use the hash of the accepted block as the previous hash.

These are the six steps from Section 5 of the Bitcoin white paper (L02).

FloodingSearch on YouTube

Bitcoin spreads data by flooding: each node forwards what it receives to its peers.

  • Flooding of transactions (from users).
  • Flooding of blocks (from the miners).
BroadcasttransactionsCollect intocandidate blockFind nonce(PoW)Broadcast block,nodes validateMine next blockon its hash

Proof of Work (PoW)Search on YouTube

Proof of Work is an economic measure to deter service abuse by requiring some work from the service requester, usually processing time on a computer.

  • The idea came from Dwork and Naor (1992) to combat junk email ("Pricing via Processing, or Combatting Junk Mail", CRYPTO '92).
  • You must do some work to send a valid email.
  • An attacker is discouraged from sending junk email in bulk, since each one costs work.

PoW features: asymmetrySearch on YouTube

  • The work must be moderately hard, but feasible for the service requester.
  • The work must be easy to check for the service provider.

Service requesters are discouraged from forging the work, but service providers can easily check its validity.

Hashcash PoWSearch on YouTube

Hashcash (Adam Back, "Hashcash: A Denial of Service Counter-Measure", 2002) is a proof of work added to an email as a "good-will" token.

  • A textual encoding of a hashcash stamp is included in the email header.
  • It proves the sender spent a modest amount of CPU time calculating the stamp before sending.
  • The receiver can verify the stamp very easily.
  • Any change in the header requires a new hashcash. Brute force is the only way to find one.

Stamp formatSearch on YouTube

X-Hashcash: 1:20:081022:panchmam036@iiitkottayam.ac.in::0000000267674b591257b67:6078
FieldExampleMeaning
Version1Stamp format version
Bits20Number of zero bits required in the hash
Date081022Date in YYMMDD
Resourceemail addressRecipient the stamp is for
Extension(empty)Optional extension
Random string0000000267674b591257b67Random characters
Counter6078Value the sender increments until the hash qualifies

Recipient side checksSearch on YouTube

  • The date must be within two days.
  • The email address must match.
  • The random string must not be reused within a certain duration. This prevents replay.
  • Compute the 160-bit SHA-1 hash of the whole stamp string. If the first 20 bits are not zero, the stamp is invalid.

Bitcoin mining is Hashcash applied to block headers. The sender's counter becomes the nonce, the 20 zero bits become the difficulty target, and SHA-1 becomes double SHA-256.

Bitcoin Proof of Work systemSearch on YouTube

Each block has a previous block hash (PH), transactions, and a nonce (N).

  • BH: block hash
  • PH: previous block hash
  • MR: Merkle root
  • N: nonce
BH=Hash(PH:MR:N),N=?BH = \text{Hash}(PH : MR : N), \quad N = ?

BH must have a certain number of zeros at the beginning. This number is the difficulty. Miners search for the nonce N that achieves it.

Tampering a Proof of Work blockchainSearch on YouTube

Each block (Block 22, 23, 24) stores Prev_Hash, Timestamp, Tx_Root, Nonce and Curr_Hash. Each block's Prev_Hash equals the previous block's Curr_Hash.

  • The blockchain together contains a large amount of work.
  • To tamper with it, an attacker must perform more work than the chain holds: re-mine the changed block and every block after it.
  • This is difficult with current hardware.

Solving the double spending problemSearch on YouTube

The attack: successful use of the same funds twice. Example: a transaction sends BTC 10 to both Bob and Carol at the same time.

The solution:

  • Transactions are irreversible (computationally impractical to modify once buried in the chain).
  • Every transaction can be validated against the existing blockchain, so a second spend of the same coins is rejected.

Sybil attacksSearch on YouTube

The attack: the attacker fills the network with clients under its control. These clients can:

  • Refuse to relay valid blocks.
  • Relay only attacker blocks, which can lead to double spending.

The solution: diversify the connections, so a node is not surrounded only by attacker peers.

Denial of Service (DoS) attacksSearch on YouTube

The attack: send a lot of data to a node so it cannot process normal Bitcoin transactions.

  • No forwarding of orphaned blocks.
  • No forwarding of double-spend transactions.
  • No forwarding of the same block or transaction twice.
  • Disconnect a peer that sends too many messages.
  • Restrict the block size to 1 MB.
  • Limit the size of each script to 10,000 bytes.

Breaking Bitcoin PoWSearch on YouTube

  • Bitcoin PoW is computationally difficult to break, but not impossible.
  • An attacker can deploy high-power servers to do more work than the total work of the blockchain (a majority or 51% attack).

The monopoly problemSearch on YouTube

PoW depends on the computing resources available to a miner. A miner with more resources has a higher probability of completing the work.

Monopoly can increase over time (Tragedy of the Commons):

  • Miners get less reward over time (halving).
  • Users get discouraged from joining as miners.
  • A few miners with large computing resources may get control over the network.

PoW power consumptionSearch on YouTube

The deck's chart shows Bitcoin's estimated energy use rising from about 10 TWh per year (April 2017) to over 50 TWh per year (early 2018). PoW is power hungry.

Proof of Stake (PoS)Search on YouTube

PoS handles both monopoly and power consumption.

  • Proposed in 2011 by a member of the Bitcoin Forum: move from PoW to PoS once bitcoins are widely distributed.
Chance of mining a block depends on
PoWThe work done by the miner
PoSThe amount of coin the miner holds. A miner holding 1% of the bitcoin can mine 1% of the PoS blocks

Why PoS helpsSearch on YouTube

  • Increased protection: executing an attack is expensive, because you need to hold more coins.
  • Miners get less reward over time.

Variants of stakeSearch on YouTube

  • Randomization combined with stake: used in Nxt and BlackCoin.
  • Coin-age: number of coins multiplied by the number of days they have been held. Used in Peercoin.
coin-age=coins×days held\text{coin-age} = \text{coins} \times \text{days held}

Ethereum now uses PoS with validators who stake ETH (L06).

Proof of Burn (PoB)Search on YouTube

  • Miners must show proof that they burned some coins: sent them to a verifiably unspendable address.
  • It is expensive, like PoW, but uses no external resources other than the burned coins.
  • PoW uses real resources; PoB uses virtual or digital resources.
  • PoB works by burning PoW-mined cryptocurrencies.

The November 2025 end sem asked which consensus fits a storage platform that uses a "burn-based mechanism to prevent spam uploads". The answer is Proof of Burn: burning makes each participant pay a real, permanent cost, which discourages spam and long-term misbehaviour.

PoW vs PoS vs PoBSearch on YouTube

PoWPoSPoB
To mine a new blockDo some workAcquire sufficient stakeBurn some wealth
Resource usedPhysical resources, like CPU power and timeNo external resource, but participates in transactionsVirtual or digital resources, like the coins
PowerPower hungryPower efficientPower efficient

Work, Stake, Burn: PoW spends electricity, PoS locks coins, PoB destroys coins.

Quick self-testSearch on YouTube

Which consensus algorithm does Bitcoin use and what are its six steps?

Proof of Work. Broadcast transactions; each node collects them into a block; nodes find a PoW; the winner broadcasts the block; nodes accept it only if all transactions are valid and unspent; nodes mine the next block using its hash as the previous hash.

Who proposed proof of work and for what?

Dwork and Naor in 1992, to combat junk email by making each email cost some computation.

What is the asymmetry property of PoW?

The work is moderately hard but feasible for the requester, and easy to check for the provider.

What checks does a Hashcash recipient perform?

Date within two days, matching email address, random string not reused (prevents replay), and the SHA-1 hash of the stamp must start with 20 zero bits.

How does Bitcoin prevent double spending?

Transactions are irreversible once in the chain, and every new transaction is validated against the existing blockchain, so a second spend of the same coins is rejected.

What is a Sybil attack and its defence?

The attacker fills the network with nodes it controls, which refuse to relay valid blocks or relay only attacker blocks. Defence: diversify connections.

List four DoS defences in Bitcoin.

No forwarding of orphaned blocks, double-spend transactions or duplicates; disconnect peers sending too many messages; 1 MB block size; 10,000-byte script limit.

Explain the monopoly problem of PoW.

Miners with more computing power win more blocks. Rewards fall over time and new miners are discouraged, so a few large miners may control the network (Tragedy of the Commons).

What is coin-age and which coin uses it?

Number of coins times the number of days they have been held. Peercoin uses it.

How does Proof of Burn differ from PoW?

PoB burns coins by sending them to an unspendable address. It is costly like PoW but uses digital resources instead of electricity, so it is power efficient.

  • Bitcoin reaches consensus with PoW: miners race to find a nonce, the winner broadcasts, nodes validate and build on the longest chain.
  • Transactions and blocks spread by flooding.
  • PoW came from Dwork and Naor (1992) and Hashcash (Adam Back); its key property is asymmetry.
  • Tampering requires redoing all later work; double spending is stopped by irreversibility and validation.
  • Sybil defence: diverse connections. DoS defences: no forwarding of orphans or duplicates, 1 MB blocks, 10,000-byte scripts.
  • PoW problems: monopoly and high power use.
  • PoS: chance proportional to stake (Nxt, BlackCoin, Peercoin coin-age). PoB: burn coins to an unspendable address.