L02: Blockchain Fundamentals
Master the technical architecture of blockchain: blocks, chains, hashes, distributed ledgers, and immutability.
Learning Objectives
By the end of this study session, you will be able to:
- Describe the structure and components of a blockchain block
- Explain how blocks are linked together using cryptographic hashes
- Calculate simple hash values and understand hash properties
- Understand Merkle trees and their role in efficient verification
- Explain the concept of immutability and why rewriting history is costly
- Compare distributed ledgers to traditional centralized databases
- Analyze the trade-offs between different blockchain architectures
Study Path
Read Summary Slides
Start with the summary slides (PDF). Pay special attention to block structure diagrams and Merkle tree illustrations.
Interactive Exploration
Use the Anders Brownworth blockchain demo to see blocks and chains in action. Try modifying data to see how hashes change.
Complete Practice Problems
Work through all 10 practice problems below. Several involve hash calculations and Merkle tree construction.
Take the Quiz
Test your knowledge with Quiz 2. Aim for at least 80% correct.
Build a Block (Optional)
Try the Block Building assignment for hands-on practice.
Key Concepts Summary
Block Structure
Block Header:
- Previous block hash - Links to parent block
- Timestamp - When block was created
- Merkle root - Summary of all transactions
- Nonce - Number used in proof-of-work
Block Body: Contains all transactions in the block
Cryptographic Linking
Each block contains the hash of the previous block, creating a chain:
Block N → hash(Block N-1) → hash(Block N-2) → ... → Genesis Block
Why this matters: Changing any historical block invalidates all subsequent blocks, making tampering detectable and costly.
Hash Function Properties
- Deterministic: Same input always produces same output
- Fast: Quick to compute
- Avalanche effect: Tiny input change → completely different output
- One-way: Cannot reverse (find input from output)
- Collision-resistant: Extremely hard to find two inputs with same hash
Merkle Trees
A tree of hashes where:
- Leaf nodes = transaction hashes
- Parent nodes = hash of concatenated child hashes
- Root = single hash summarizing all transactions
Benefits: Verify specific transaction inclusion with O(log n) hashes instead of downloading entire block.
Distributed vs. Centralized Ledgers
Centralized: Single database, fast, trusted operator, single point of failure
Distributed: Many copies, slower, trustless verification, censorship-resistant
Key difference: Blockchain replaces trust in operator with trust in cryptography and consensus.
Immutability
Why blockchain is "append-only":
- Changing block N requires recalculating all hashes from N onward
- Requires redoing all proof-of-work (expensive!)
- Must outpace honest chain (51% attack)
- Cost typically exceeds any potential gain
Practice Problems
1. Previous block hash: Creates the chain linkage; changing any past block breaks this link
2. Timestamp: Records when block was created; ensures chronological ordering
3. Merkle root: Single hash summarizing all transactions; enables efficient verification
4. Nonce: Number varied during mining to find valid proof-of-work; proves computational effort
- Changing transaction #3 changes its hash
- This changes the Merkle root of Block 100
- This changes Block 100's header hash
- Block 101 contains Block 100's hash, so Block 101's hash becomes invalid
- Block 102 contains Block 101's hash, so Block 102 becomes invalid
- The cascade continues to the latest block
This is the core of immutability - you can't secretly change history because it breaks the entire chain forward.
Root
/ \
H1 H2
/ \ / \
H3 H4 H5 H6
/\ /\ /\ /\
T1T2T3T4T5T6T7T8
To verify T5 is included, you need:1. Hash of T5 (you calculate this yourself)
2. Hash of T6 (to compute H5)
3. H4 (to compute H2)
4. H1 (to compute Root)
Total: 3 additional hashes needed vs. downloading all 8 transactions. This is O(log n) efficiency - for 1000 transactions, you'd need only ~10 hashes.
Example: hash("Block 100") vs hash("Block 101") → entirely different hashes
Critical for security because:
1. Makes tampering obvious - you can't make small changes unnoticed
2. Prevents targeted manipulation - can't predict how to modify data to get desired hash
3. Enables proof-of-work - must try many nonces to find hash meeting difficulty target
4. Protects against forgery - can't construct valid-looking blocks without proper inputs
1. More orphan blocks: With slow network propagation, miners often work on outdated chains, wasting work
2. Reduced security per block: Same total hash power spread over more blocks = less work per block
3. Favors centralization: Well-connected miners with fast propagation have advantage
4. Storage overhead: More blocks = more headers to store and validate
The 10-minute interval balances speed vs. security. Faster confirmation needs come from Layer 2 solutions (Lightning Network) rather than faster base-layer blocks.
Blocks to rewrite: 500,000 - 250,000 = 250,000 blocks
Time per block (with 50% of network): 20 minutes
Total time: 250,000 × 20 minutes = 5,000,000 minutes = ~9.5 years
BUT: During those 9.5 years, the honest network continues adding new blocks, so the attacker must catch up to a moving target. With equal hash power, the attacker never catches up - they need >50% to eventually overtake the honest chain. This makes deep reorgs economically infeasible.
1. Performance: SQL databases handle 10,000+ transactions/sec; blockchains do 7-50 tx/sec due to consensus overhead
2. Privacy: Banks need confidential transactions; public blockchains are transparent by design
3. Flexibility: Banks need to reverse fraud, comply with regulations, correct errors - blockchain's immutability makes this difficult
Banks don't need decentralization (they're the central authority) so blockchain's benefits don't outweigh costs. They might use private/permissioned blockchains for specific inter-bank settlement use cases.
1. Extremely expensive: Requires redoing all proof-of-work from that point onward
2. Requires majority control: Need 51%+ hash power to outpace honest chain
3. Publicly visible: Deep reorganizations are obvious to network participants
4. Economically irrational: Cost typically exceeds any gain
More accurate statement: "Blockchain makes data economically impractical to change without majority control, and any change is detectable." The security comes from incentive alignment, not technical impossibility.
The genesis block is also special because:
- It's hardcoded into the software (every node has the same genesis block)
- Often contains a message (Bitcoin's references a newspaper headline from Jan 3, 2009)
- Its timestamp establishes the blockchain's beginning
- It's the common ancestor of all blocks, making it the ultimate trust anchor
1. Download all block headers (~80 bytes each = 40 MB for 500k blocks) - contains Merkle roots
2. Request Merkle proof from full node for specific transaction in block #500,000
3. Receive: Transaction + sibling hashes needed to reconstruct path to Merkle root
4. Verify: Hash transaction, combine with siblings, hash up the tree
5. Check: Does computed root match the Merkle root in block header #500,000?
6. Confirm: Block #500,000 is in the main chain (has most proof-of-work)
Security assumption: Light client trusts that most hash power is honest, but doesn't trust individual full nodes (can verify proofs independently).
External Resources
Interactive Tools
-
Blockchain Demo - Anders Brownworth
INTERACTIVE
Essential hands-on tool for understanding hashing and blockchain structure
-
Merkle Tree Visualizer
INTERACTIVE
Build and explore Merkle trees interactively
Videos
-
How does a blockchain work - Simply Explained
VIDEO
5 min - Clear visualization of block structure and linking
-
But how does bitcoin actually work? - 3Blue1Brown
VIDEO
26 min - Deep dive into cryptographic linking and distributed ledgers
Articles
-
How Bitcoin Works - Bitcoin.org
ARTICLE
Official Bitcoin documentation on blockchain basics
-
Merkle Trees Explained
ARTICLE
Comprehensive guide to Merkle trees and SPV proofs
Documentation
-
Bitcoin Developer Reference - Block Chain
DOCS
Technical specification of Bitcoin's blockchain structure
Self-Check Questions
Before moving to Lesson 3, ensure you can confidently answer these questions:
- Can you draw and label the components of a blockchain block?
- Can you explain why changing historical data breaks the chain?
- Can you construct a simple Merkle tree and verify transaction inclusion?
- Can you list and explain three properties of cryptographic hash functions?
- Can you explain the difference between distributed and centralized ledgers?
- Can you calculate the cost of rewriting blockchain history?
If you answered "yes" to all, you're ready for Lesson 3: Cryptographic Foundations!