0Pricing
Cryptology Academy · Lesson

Hash Chains & Block Linking

Build a minimal blockchain with hash pointers to understand immutability.

Hash Chains & Block Linking is a free Cryptology Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is a Hash Chain?

A hash chain links data blocks so that each block contains the hash of the previous block. Modifying any block changes its hash, which invalidates all subsequent blocks. This creates a tamper-evident, append-only ledger.

Block Structure

Each block contains: (1) data payload (transactions), (2) previous block hash (pointer to prior block), (3) timestamp, (4) nonce (for PoW), (5) Merkle root of transactions. The first block (genesis) has previous_hash = "0"*64.

Python Minimal Blockchain

import hashlib, json class Block: def __init__(self, data, prev_hash): self.data = data self.prev_hash = prev_hash self.hash = hashlib.sha256( json.dumps({'data':data,'prev':prev_hash}).encode() ).hexdigest()

Why Hash Pointers Ensure Integrity

If an attacker modifies block 3's data, block 3's hash changes. Block 4 references block 3's old hash — the chain breaks at block 4. The attacker must recompute hashes for blocks 3, 4, 5, ... all the way to the tip. With PoW, this is computationally infeasible.

Immutability vs Tamper Evidence

Hash chains provide tamper evidence, not immutability by themselves. Without additional mechanisms (PoW, digital signatures, distribution), an attacker who controls the chain can rewrite it. Distributed consensus is what makes blockchain tamper-resistant in practice.

Longest Chain Rule

Bitcoin's longest chain rule: the valid chain with the most accumulated proof-of-work is canonical. If an attacker forks the chain, honest miners extend the honest chain faster (51% assumption). The attacker's fork is shorter and discarded.

Header vs Full Block

Bitcoin's SPV (Simple Payment Verification) clients download only 80-byte block headers (containing previous hash, Merkle root, nonce, timestamp, bits). Full nodes store all transactions. SPV clients verify a transaction by Merkle proof against the header Merkle root.

Genesis Block

Bitcoin's genesis block (block 0, Jan 3 2009) has prev_hash = 0x000...0. Satoshi embedded the headline "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks" in the coinbase transaction as proof of timestamp.

Chain of Custody

Hash chains predate blockchain. Uses: certificate revocation lists (linked by hash), log integrity (hash of previous log entry), DNSSEC chain of trust. The concept generalizes: any append-only structure where each entry commits to all previous entries.

Checkpointing

To speed up initial sync, Bitcoin Core hardcodes checkpoints: known-valid block hashes at certain heights. A client starting sync can skip PoW verification for blocks before the checkpoint, trusting the hardcoded hash. Trade-off: reduces trust-minimization.

Content Addressing

Git uses the same principle: each commit is identified by SHA-1/SHA-256 of its content + parent commit hash. Checking out a specific commit hash gives exactly that state. Git's entire history is a hash-linked tree of objects.

Quick Check

Why must an attacker recompute all subsequent block hashes after modifying one block?

Recap

Hash chains link blocks via cryptographic pointers. Modification cascades to all subsequent blocks. Combined with PoW and distributed consensus, this makes blockchain immutable in practice. Next: Merkle trees for efficient transaction integrity.

Frequently asked questions

Is the “Hash Chains & Block Linking” lesson free?

Yes — the full text of “Hash Chains & Block Linking” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.

What will I learn in “Hash Chains & Block Linking”?

Build a minimal blockchain with hash pointers to understand immutability. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cryptology Academy?

No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Hash Chains & Block Linking” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cryptology Academy lesson?

Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Hash Chains & Block Linking
  2. Merkle Trees: Transaction Integrity at Scale
  3. Proof of Work: Mining & Difficulty Adjustment
  4. Bitcoin Script & UTXO Signature Verification
← Back to Cryptology Academy