Blockchain Fundamentals
Master the core concepts of blockchain technology, cryptography, and distributed systems.
Course Navigation
Cryptography Fundamentals
Hash Functions and Digital Fingerprints
Understanding Hash Functions
Hash functions are mathematical algorithms that convert input data of any size into a fixed-size string of characters.
Key Properties:
- Deterministic: Same input always produces same output
- Fixed Output Size: Always produces same length hash
- Avalanche Effect: Small input change = drastically different output
- One-way Function: Easy to compute forward, impossible to reverse
- Collision Resistant: Extremely difficult to find two inputs with same hash
Common Hash Functions:
- SHA-256: Used in Bitcoin, produces 256-bit hash
- Keccak-256: Used in Ethereum
- Blake2: Fast and secure, used in various blockchains
Blockchain Applications:
- Block identification and linking
- Transaction verification
- Merkle tree construction
- Proof of Work mining
- Digital signatures
Digital Signatures and Authentication
Digital Signature Cryptography
Digital signatures provide authentication, integrity, and non-repudiation for digital messages.
How Digital Signatures Work:
- Key Generation: Create public/private key pair
- Signing: Use private key to sign message hash
- Verification: Use public key to verify signature
Elliptic Curve Cryptography (ECC):
Most blockchains use ECC for efficient digital signatures:
- secp256k1: Used by Bitcoin and Ethereum
- Ed25519: Used by Solana for faster verification
- Smaller keys: 256-bit keys vs 2048-bit RSA
- Faster operations: Efficient signing and verification
Blockchain Applications:
- Transaction authorization
- Wallet authentication
- Smart contract execution
- Multi-signature schemes
Consensus Mechanisms
Proof of Work (PoW)
Proof of Work Consensus
PoW requires miners to solve computationally expensive puzzles to validate transactions and create new blocks.
How PoW Works:
- Transaction Collection: Miners gather pending transactions
- Block Creation: Form a block with transactions and metadata
- Nonce Search: Find a nonce that makes block hash meet difficulty target
- Block Broadcast: Share valid block with network
- Verification: Other nodes verify and accept the block
Mining Process:
Block Hash = SHA256(
Previous Block Hash +
Merkle Root +
Timestamp +
Difficulty Target +
Nonce
)
// Goal: Find nonce where hash starts with required zeros
// Example: 0000a1b2c3d4e5f6... (4 leading zeros = difficulty)
Advantages:
- Proven security model
- Decentralized and permissionless
- Resistant to attacks
- Simple to understand and verify
Disadvantages:
- High energy consumption
- Slow transaction throughput
- Mining centralization risks
- Environmental concerns
Proof of Stake (PoS)
Proof of Stake Consensus
PoS selects validators to create new blocks based on their stake (ownership) in the network.
How PoS Works:
- Staking: Validators lock up tokens as collateral
- Selection: Algorithm chooses validator based on stake and randomness
- Block Creation: Selected validator creates and proposes block
- Attestation: Other validators vote on block validity
- Finalization: Block becomes final after sufficient attestations
Validator Selection Methods:
- Randomized Block Selection: Higher stake = higher probability
- Coin Age Selection: Considers how long tokens have been staked
- Delegated Proof of Stake: Token holders vote for delegates
Slashing Conditions:
Validators lose staked tokens for malicious behavior:
- Double signing (creating two blocks at same height)
- Surround voting (contradictory attestations)
- Offline penalties for extended downtime
Advantages:
- Energy efficient (99% less than PoW)
- Faster finality
- Economic security through slashing
- Scalable to higher throughput
Distributed Systems Concepts
CAP Theorem and Trade-offs
CAP Theorem
The CAP theorem states that distributed systems can only guarantee two of three properties simultaneously.
The Three Properties:
- Consistency (C): All nodes see the same data simultaneously
- Availability (A): System remains operational and responsive
- Partition Tolerance (P): System continues despite network failures
Blockchain Trade-offs:
- Bitcoin (CP): Prioritizes consistency and partition tolerance over availability
- Ethereum (CP): Similar to Bitcoin, eventual consistency model
- Some DeFi protocols (AP): May sacrifice consistency for availability
Network Partitions in Blockchain:
When network splits occur:
- Different parts of network may have different views
- Consensus mechanisms handle partition recovery
- Longest chain rule resolves conflicts
- Some transactions may be reversed (reorganization)
Practical Implications:
- Transaction finality takes time
- Higher confirmation counts = higher security
- Network upgrades require careful coordination
- Emergency procedures for major partitions
Blockchain Economics and Tokenomics
Token Economics and Incentive Design
Tokenomics Fundamentals
Tokenomics combines token design with economic incentives to create sustainable blockchain ecosystems.
Token Types:
- Utility Tokens: Access to network services (ETH for gas)
- Governance Tokens: Voting rights in protocol decisions
- Security Tokens: Represent ownership or debt
- Stablecoins: Price-stable cryptocurrencies
- NFTs: Non-fungible tokens for unique assets
Supply Mechanisms:
- Fixed Supply: Bitcoin's 21M cap creates scarcity
- Inflationary: New tokens minted for rewards
- Deflationary: Token burning reduces supply
- Elastic: Supply adjusts based on demand
Incentive Alignment:
- Staking Rewards: Encourage network security
- Transaction Fees: Prevent spam and reward validators
- Liquidity Mining: Bootstrap DeFi protocols
- Governance Participation: Reward active community members
Economic Security:
The cost of attacking the network must exceed potential gains:
- PoW: Cost of 51% hash power
- PoS: Cost of 33% stake + slashing penalties
- Economic finality through stake at risk