Introduction
Blockchain is a decentralized public ledger that enables peer-to-peer transactions without trusted intermediaries. Originally created for Bitcoin, it can transfer any kind of information securely.
Blockchain: A distributed database that maintains a continuously growing list of records (blocks) linked together using cryptography.
Key Characteristics
- Decentralized: No single authority controls the network
- Distributed: Copies exist across many nodes
- Immutable: Once written, data cannot be easily changed
- Transparent: Transactions are visible to all participants
- Secure: Cryptographically protected
How Blockchain Works
Block Structure
- Block Header: Version, previous block hash, Merkle root, timestamp, difficulty target, nonce
- Block Body: Transaction data
Hashing
Each block contains the hash of the previous block, creating a chain:
Block 1: Hash(Header) → "0000a1b2..."
Block 2: Hash(Header + PrevHash) → "0000c3d4..."
Block 3: Hash(Header + PrevHash) → "0000e5f6..."
Merkle Trees
Transactions are organized in a Merkle tree for efficient verification:
- Hash pairs of transactions
- Continue until single root hash
- Enables quick verification of transactions
Key Insight: Changing any past transaction would change the Merkle root, which changes the block hash, breaking the chain. This makes blockchain immutable!
Consensus Mechanisms
Consensus mechanisms allow all nodes to agree on the state of the blockchain.
Proof of Work (PoW)
- Miners solve cryptographic puzzles
- First to solve gets to add block
- Used by Bitcoin, Ethereum (was)
- High energy consumption
Proof of Stake (PoS)
- Validators stake cryptocurrency
- Selected based on stake amount
- Less energy intensive
- Used by Ethereum (now), Cardano
Other Consensus Mechanisms
- Proof of Authority: Validated by identity
- Delegated PoS: Representative validators
- Proof of Importance: Based on transaction activity
- Byzantine Fault Tolerance: Tolerates faulty nodes
| Mechanism | Energy | Examples |
|---|---|---|
| Proof of Work | High | Bitcoin |
| Proof of Stake | Low | Ethereum |
| Delegated PoS | Low | EOS |
Cryptocurrency
Cryptocurrency is a digital currency that uses cryptography for security and operates on blockchain technology.
Bitcoin
- Introduced in 2008 by "Satoshi Nakamoto"
- First decentralized cryptocurrency
- Peer-to-peer electronic cash system
- Limited supply: 21 million coins
Key Concepts
- Wallet: Stores private keys
- Address: Public key hash (like account number)
- Private Key: Authorizes transactions
- Transaction: Transfer of value
- Mining: Process of adding blocks
Altcoins
Alternative cryptocurrencies based on Bitcoin's principles:
- Litecoin: Faster transactions
- Ethereum: Smart contracts
- Ripple: Banking focus
- Cardano: Research-based
Smart Contracts
Smart contracts are self-executing contracts with terms directly written into code. They automatically enforce and execute agreements when conditions are met.
How Smart Contracts Work
- Parties agree on terms
- Code is written and deployed to blockchain
- Conditions are met (or not)
- Contract automatically executes
Use Cases
- DeFi: Decentralized finance applications
- Supply Chain: Track products
- Real Estate: Property transfers
- Insurance: Automatic claims
- Voting: Secure elections
Ethereum
- Blockchain platform designed for smart contracts
- Uses Solidity programming language
- Most popular smart contract platform
Blockchain Security
Security Strengths
- Immutability: Computationally difficult to modify blocks
- Decentralization: No single point of failure
- Cryptographic Verification: Prevents double-spending
- Transparency: All transactions visible
- Privacy: No personal information required
Security Weaknesses
- 51% Attack: If one entity controls majority of mining power
- Smart Contract Bugs: Code vulnerabilities
- Exchange Hacks: Centralized service vulnerabilities
- Key Management: Lost keys mean lost funds
- Regulatory Uncertainty: Legal risks
Exam Tip: The blockchain itself (Bitcoin, Ethereum) has never been compromised. Attacks have targeted exchanges, wallets, and smart contracts, not the underlying blockchain.