Consensus and Cryptography

Proof of Work

Beginner LevelBy Pratima Sharma

Proof-of-Work (PoW) is the original consensus mechanism used in Bitcoin. It relies on computational puzzles that require miners to find a hash below a certain target. This puzzle is solved using cryptographic hash functions (SHA-256 in Bitcoin).

How it works:

  1. A miner collects transactions into a block and creates a block header containing:
    • Previous block hash
    • Merkle Root of transactions
    • Timestamp
    • Nonce (variable number)
    • Difficulty target
  2. The miner computes the SHA-256 hash of the block header.
  3. If the hash meets the difficulty target (e.g., starts with a certain number of zeros), the block is valid.
  4. Otherwise, the miner increments the nonce and tries again.

Example:

  • Target: hash must start with 0000.
  • Miner tries nonce 0 → SHA-256 hash = a5f3... not valid.
  • Miner tries nonce 4721 → SHA-256 hash = 0000b3... valid → block accepted.

Role of Cryptography:

  • SHA-256 ensures unpredictable and verifiable outputs.
  • Hash puzzles enforce work, making it expensive to manipulate the blockchain.
  • The cryptographic property of pre-image resistance prevents attackers from easily finding a valid hash without performing the required work.

Continue Learning

Explore more topics in Cryptography in Blockchain or browse other tutorials.