Interactive Blockchain Book

Master blockchain through progressive chapters with hands-on demos

Table of Contents

Chapter 1: Blockchain Basics
  • Linked List
  • Cryptographic Hashing
  • Merkle Tree
  • Data Formats
  • Chapter Quiz
Chapter 2: Cryptography
  • Symmetric Encryption
  • Asymmetric Encryption 🔒
  • Digital Signatures 🔒
  • Chapter Quiz
Chapter 3: Build a Blockchain
  • Blockchain Hash 🔒
  • Mining a Block 🔒
  • The Blockchain 🔒
  • Distributed Networks 🔒
  • Tokens 🔒
  • Chapter Quiz
Chapter 4: Bitcoin Deep Dive
  • Keys and Addresses 🔒
  • Bitcoin Wallet 🔒
  • Transactions 🔒
  • Bitcoin Blocks 🔒
  • Chapter Quiz

Chapter 1: Blockchain Basics

Foundational data structures and concepts that power blockchain technology

Linked List

A linked list is a fundamental data structure that forms the backbone of blockchain technology. Each block in a blockchain is like a node in a linked list, containing data and a reference to the previous block.

Foundational Concepts


What is a Linked List?

A linked list is a linear data structure where elements (called nodes) are stored in a sequence, but unlike arrays, they are not stored in contiguous memory locations. Each node contains two parts: the data and a pointer (or reference) to the next node in the sequence.

Types of Linked Lists

  • Singly Linked List: Each node points only to the next node
  • Doubly Linked List: Each node points to both next and previous nodes
  • Circular Linked List: The last node points back to the first node

Why Blockchain Uses Linked Lists

Blockchain is essentially a specialized singly linked list where each block contains a cryptographic hash of the previous block instead of a simple pointer. This creates an immutable chain - if any block is modified, all subsequent hashes become invalid.

Key Operations

  • Insert at Head: O(1) - Add a new node at the beginning
  • Insert at Tail: O(n) - Add a new node at the end
  • Delete: O(n) - Remove a node by finding it first
  • Search: O(n) - Find a node with specific data
🎯

Time to Practice!

Now that you understand linked lists, use the interactive tool below to visualize how nodes are added and removed. Try adding nodes at different positions and observe how the pointers update!

Loading...

Loading interactive tool...

  1. Enter a value (0-99) in the input field and click 'Add Node' to add a new node at the head of the list
  2. Click 'Remove Node' to remove the head node from the list
  3. Use 'Add Node at Index' to insert a node at a specific position
  4. Use 'Remove Node from Index' to delete a node at a specific position
  5. Observe how the arrows (pointers) connect each node to the next one

Cryptographic Hashing

Hashing is the process of converting any input data into a fixed-size string of characters. In blockchain, hash functions create unique digital fingerprints that ensure data integrity and link blocks together.

Foundational Concepts


What is a Hash Function?

A hash function takes an input (or 'message') of any size and produces a fixed-size output called a hash value, hash code, digest, or simply hash. The same input always produces the same output, but even a tiny change in input produces a completely different hash.

Properties of Cryptographic Hash Functions

  • Deterministic: Same input always yields the same output
  • Fast Computation: Quick to compute the hash for any given input
  • Pre-image Resistance: Infeasible to reverse the hash to find the original input
  • Collision Resistance: Extremely unlikely for two different inputs to produce the same hash
  • Avalanche Effect: A small change in input drastically changes the output

Common Hash Functions

  • SHA-256: Used in Bitcoin, produces 256-bit (64 hex characters) output
  • SHA-3: Latest SHA standard with different internal structure
  • RIPEMD-160: Used in Bitcoin for address generation
  • CRC32: Simple checksum (shown in demo), not cryptographically secure

Hashing in Blockchain

Blockchain uses hashing to: (1) Create unique block identifiers, (2) Link blocks together by including the previous block's hash, (3) Verify data integrity, and (4) Support the mining process through proof-of-work.

🎯

Time to Practice!

Experience the avalanche effect firsthand! Type any text below and watch how even a single character change produces a completely different hash. Try typing 'hello' and then 'Hello' to see the dramatic difference.

Loading...

Loading interactive tool...

  1. Type any text in the 'Data' input field
  2. The hash is calculated automatically as you type
  3. Try changing just one character and observe how the entire hash changes
  4. This demonstrates the 'avalanche effect' - a key property of hash functions
  5. Note: This demo uses CRC32 for simplicity. Real blockchains use SHA-256.

Merkle Tree

A Merkle tree is a hash-based data structure that efficiently summarizes and verifies the integrity of large sets of data. Bitcoin and other blockchains use Merkle trees to organize transactions within each block.

Foundational Concepts


What is a Merkle Tree?

A Merkle tree (named after Ralph Merkle) is a binary tree where every leaf node contains the hash of a data block, and every non-leaf node contains the hash of its child nodes. The root of the tree, called the Merkle root, represents a single hash that summarizes all the data.

How Merkle Trees Work

  • Step 1: Hash each piece of data (e.g., transaction) to create leaf nodes
  • Step 2: Pair adjacent hashes and hash them together
  • Step 3: Repeat until only one hash remains (the Merkle root)
  • Step 4: If odd number of nodes, duplicate the last one

Benefits of Merkle Trees

  • Efficient Verification: Verify any single piece of data with O(log n) hashes
  • Space Efficient: Only store the root to verify large datasets
  • Tamper Detection: Any change propagates up, changing the root
  • SPV Proofs: Light clients can verify transactions without downloading entire blocks

Merkle Trees in Bitcoin

Every Bitcoin block contains a Merkle root in its header, summarizing all transactions in that block. This allows lightweight wallets to verify if a transaction is included in a block by downloading only a small 'Merkle proof' instead of the entire block.

🎯

Time to Practice!

Build your own Merkle tree! Enter transaction data below and watch how each transaction gets hashed, then paired and hashed again, until reaching the final Merkle root. Try modifying one transaction to see how it affects the entire tree.

Loading...

Loading interactive tool...

  1. Enter transaction data in each input field (4 transactions shown)
  2. Each transaction is hashed individually (Level 0 - leaf nodes)
  3. Adjacent hashes are combined and hashed (Level 1)
  4. The process continues until a single root hash remains
  5. Try changing any transaction and observe how all hashes above it change

Data Formats

Blockchain systems use various data encoding formats to represent information efficiently. Understanding hexadecimal, binary, Base58, and other formats is essential for reading blockchain data.

Foundational Concepts


Binary (Base-2)

The fundamental language of computers. Uses only 0 and 1. Every piece of data, from text to images, is ultimately stored and processed as binary. Each binary digit is called a 'bit', and 8 bits make a 'byte'.

Hexadecimal (Base-16)

  • Uses digits 0-9 and letters A-F (representing 10-15)
  • More compact than binary: 1 hex digit = 4 binary bits
  • Common in blockchain: hashes, addresses, transaction IDs
  • Example: Binary 11111111 = Hex FF = Decimal 255

Base58 Encoding

  • Used for Bitcoin addresses and private keys (WIF format)
  • Similar to Base64 but removes confusing characters: 0, O, I, l
  • Designed to be human-readable and avoid transcription errors
  • Base58Check adds a checksum for error detection

Little Endian vs Big Endian

These describe the byte order when storing multi-byte values. Big Endian stores the most significant byte first (like reading left to right). Little Endian stores the least significant byte first. Bitcoin uses Little Endian for many internal values.

🎯

Time to Practice!

Convert between different data formats! Enter a value in one format and see its representation in others. This skill is crucial for reading raw blockchain data and understanding how addresses and hashes are encoded.

Loading...

Loading interactive tool...

  1. Enter a value in any input field (Decimal, Binary, Hex, or Text)
  2. The tool automatically converts to all other formats
  3. For text input, you'll see ASCII/UTF-8 byte values
  4. Try entering your name to see its hexadecimal representation
  5. This helps understand how blockchain stores and displays data
Loading quiz...

Loading quiz...

Chapter 2: Cryptography

Security foundations that protect blockchain networks and transactions

Symmetric Encryption

Symmetric encryption uses a single shared key for both encrypting and decrypting data. It's fast and efficient for encrypting large amounts of data, but requires secure key distribution.

Foundational Concepts


What is Symmetric Encryption?

Symmetric encryption uses the same secret key for both encryption (converting plaintext to ciphertext) and decryption (converting ciphertext back to plaintext). Both parties must have the same key and keep it secret.

AES (Advanced Encryption Standard)

  • Most widely used symmetric encryption algorithm
  • Adopted by U.S. government as standard in 2001
  • Key sizes: 128, 192, or 256 bits
  • Block cipher: encrypts data in 128-bit blocks
  • Considered secure against all known practical attacks

The Key Distribution Problem

The main challenge with symmetric encryption is securely sharing the key. If an attacker intercepts the key during transmission, they can decrypt all messages. This problem led to the development of asymmetric encryption.

Symmetric Encryption in Blockchain

While blockchain transactions use asymmetric cryptography, symmetric encryption is still used for: encrypting wallet files, securing communication channels, and protecting sensitive metadata.

🎯

Time to Practice!

Try encrypting and decrypting messages with AES! Enter a secret passphrase and your message, then encrypt it. Share the ciphertext - only someone with the same passphrase can decrypt it.

Loading...

Loading interactive tool...

  1. Enter a passphrase (shared secret key) in the password field
  2. Type your message in the 'Plain Text' field
  3. Click 'Encrypt' to generate the encrypted ciphertext
  4. To decrypt, paste ciphertext and enter the same passphrase
  5. Click 'Decrypt' to recover the original message
  6. Try decrypting with a wrong passphrase to see it fail

Asymmetric Encryption 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Digital Signatures 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Loading quiz...

Loading quiz...

Chapter 3: Build a Blockchain

Core blockchain mechanics from hashing to distributed consensus

Blockchain Hash 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Mining a Block 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

The Blockchain 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Distributed Networks 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Tokens 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Loading quiz...

Loading quiz...

Chapter 4: Bitcoin Deep Dive

Real-world Bitcoin implementation from keys to blocks

Keys and Addresses 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Bitcoin Wallet 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Transactions 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Bitcoin Blocks 🔒

🔒

Section Locked

Continue reading on HyperReads to access this section and more.

✓ All sections unlocked
✓ Track your progress
✓ Access 101ai + playwithml too
Try HyperReads Free →

No credit card required

Loading quiz...

Loading quiz...