HomeArticlesCryptography

Blockchain Consensus — Proof of Work, Difficulty and the 51% Attack

Every node verifies the same hash puzzle independently to agree on a single transaction history — no trust required, just brute-force arithmetic.

mysimulator teamUpdated July 2026≈ 8 min read▶ Open the simulation

Proof of work: expensive to make, trivial to check

A block header bundles the previous block's hash, a Merkle root committing to every transaction, a timestamp, a difficulty target, and a 32-bit nonce. A block is valid only if double-SHA-256 of that header falls below the target — and there is no shortcut to finding a qualifying nonce beyond brute-force guessing, with expected trials equal to 2²⁵⁶ divided by the target. This asymmetry — hard to produce, instant to verify — is the entire foundation of proof-of-work security: the current Bitcoin network runs at roughly 700 EH/s (7×10²⁰ hashes per second) and consumes on the order of 100 TWh a year purely to keep that puzzle expensive to solve.

Difficulty adjustment: a self-correcting clock

Bitcoin targets a 10-minute average block interval. Every 2,016 blocks — about two weeks — the protocol rescales the target by the ratio of actual elapsed time to the expected 20,160 minutes, capped at a factor of 4 up or 0.25 down per retarget: blocks arriving faster than expected shrink the target (harder puzzle), blocks arriving slower grow it (easier puzzle). This negative feedback loop is remarkably robust — when China banned mining in 2021 and network hash rate dropped 50% overnight, difficulty adjusted down over three retargets and block times stabilised again within about six weeks, with no coordination required beyond the protocol rule itself.

Block valid iff:  SHA256(SHA256(header)) < target
new_target = old_target × (actual_time / expected_time)   [capped ×4 / ×0.25]
P(attacker with fraction q catches up from z blocks) = (q/p)^z   if q < p
  z=6, q=0.10 → P ≈ 0.10^6 ≈ 0.0001%
live demo · miners racing to extend the longest chain● LIVE

Byzantine fault tolerance without knowing who's honest

The Byzantine Generals Problem (Lamport, 1982) asks how N distributed parties reach agreement when up to f of them might lie — classical theory needs N ≥ 3f+1 honest participants, which assumes you can count identities. Bitcoin's 2008 breakthrough sidesteps identity entirely: instead of counting votes, it attaches a real computational cost to each one. A block is a "vote" that cost genuine energy to produce, so an attacker needs to control more than 50% of total network hash power to reliably out-race the honest chain — the 51% attack. Nodes follow the longest-chain rule, always treating the chain with the most cumulative proof of work as valid, and this probabilistic consensus converges exponentially fast: the probability an attacker with hash-power fraction q catches up from z blocks behind is (q/p)^z when q < p, so at q = 0.10 and the conventional z = 6 confirmations, the chance of reversal is roughly 0.0001%.

Why honest mining is the rational choice

Mining is ultimately a game-theoretic equilibrium, not just cryptography. Miners earn a block reward (3.125 BTC post-2024 halving, halving again every 210,000 blocks toward a 21-million-coin cap) plus transaction fees, which become the dominant incentive as rewards shrink over time. Sustaining 51% of hash power would cost on the order of $10 billion in hardware and roughly $20 million a day in electricity — far more than any realistic double-spend payoff — so the Nash equilibrium is honest mining: cheating is strictly less profitable than cooperating, which is what lets a trustless, permissionless network run without any central authority. (Not every chain uses this exact mechanism — Ethereum switched to proof-of-stake in 2022, replacing computational cost with staked collateral that gets slashed for misbehaviour, cutting energy use by roughly 99.95% while keeping the same "expensive to attack" logic.)

Frequently asked questions

What makes proof-of-work mining hard to fake?

A block is only valid if double-SHA-256 of its header is below a target value, and there is no shortcut to finding a qualifying nonce other than brute-force guessing — expected trials equal 2^256 divided by the target. Producing a valid block is deliberately expensive, but any node can verify a found hash in microseconds, an asymmetry that is the foundation of proof-of-work security.

How does Bitcoin's difficulty adjustment keep block time near 10 minutes?

Every 2,016 blocks (about two weeks), the protocol rescales the target by the ratio of actual to expected elapsed time, capped at a factor of 4 up or 0.25 down per retarget. This negative feedback loop restored stable 10-minute blocks within about six weeks after China's 2021 mining ban cut hash rate in half overnight.

What is a 51% attack and how likely is it to succeed?

Bitcoin's longest-chain rule means nodes always follow the chain with the most cumulative proof of work, so an attacker needs more than half the network's total hash power to reliably outpace the honest chain. At attacker fraction q = 0.10 and z = 6 confirmations, the probability of catching up is roughly 0.0001%, which is why six confirmations is the conventional finality threshold.

Try it live

Everything above runs in your browser — open Blockchain Consensus, adjust hash rate, difficulty and attacker share, and watch miners race to beat the target while forks resolve into a single longest chain. Nothing is installed, nothing is uploaded.

▶ Open Blockchain Consensus simulation

What did you find?

Add reproduction steps (optional)