CSE436Semester 7 • 4 CreditsElective Subjects

Blockchain

The course covers blockchain fundamentals, decentralization, symmetric and public-key cryptography, consensus algorithms, Bitcoin networks and transactions, alternative coins, smart contracts, Ethereum, Geth, Web3, and decentralized applications. It also includes practical work involving Solidity, MetaMask, Remix IDE, contract deployment, and Ethereum account and genesis-block management using Geth.

6 Units • Notes • Model Answers • MCQs
Select Course Unit (6 Units)
Active: Unit 1
Unit 1:Unit 1: Introduction to Blockchain and Decentralization
7 min read•High-Yield Unit Guide

Unit 1: Introduction to Blockchain and Decentralization

Unit 1 Exam Focus & Core Takeaways

Review the core definitions, standard architectures, and syntax patterns below. Pay special attention to sections highlighted with bullet points for your mid-term and end-term subjective questions.

Unit 1: Introduction to Blockchain and Decentralization

1. Foundations of Blockchain-Based Decentralization

1.1 Definition and Core Architectural Philosophy

A blockchain is an immutable, distributed, append-only state transition ledger maintained across a peer-to-peer (P2P) network using cryptographic primitives, economic incentives, and consensus algorithms. Unlike conventional centralized relational databases administered by a single trusted authority (e.g., banks or cloud providers), a blockchain operates without a central coordinator or single point of failure (SPOF).

The essential characteristics of a public blockchain architecture include:

  1. Shared Global State: Every full node in the network maintains or independently verifies an identical sequence of historically committed transactions.
  2. Cryptographic Integrity & Chaining: Blocks are cryptographically coupled via collision-resistant cryptographic hash functions. Modifying any historical record invalidates the subsequent block hash chain.
  3. Decentralized Distributed Agreement: A consensus engine guarantees that distributed, mutually untrusted participants agree on a singular, canonical ledger history.
  4. Append-Only Immutability: Historical state cannot be overwritten or deleted. Mutating historical records requires recalculating the consensus mechanism faster than the rest of the honest network (e.g., 51%51\% computational hash power or supermajority stake).
  5. Trust Minimization: Trust is relocated from fallible human institutions and intermediaries to deterministic cryptographic algorithms, open-source software, and incentive-aligned game theory ("Don't trust, verify").
CODE
Centralized Architecture               Decentralized Blockchain Architecture
      [ Client ]                                 [ Node A ] ────── [ Node B ]
          │                                         │ \             / │
          ▼                                         │  \           /  │
    [ Central DB ]                                  │   [ Node C ]    │
     (Single Point                                  │  /           \  │
       of Failure)                                  │ /             \ │
          ▲                                      [ Node D ] ────── [ Node E ]
          │                               (P2P Gossip Network, Shared Ledger)
      [ Client ]

2. Historical Evolution and Technical Predecessors

Bitcoin, invented by the pseudonymous Satoshi Nakamoto in October 2008 and launched on January 3, 2009, did not emerge in a vacuum. It was the synthesis of over three decades of research across asymmetric cryptography, distributed systems, and cypherpunk electronic cash designs.

2.1 Timeline of Foundational Technologies

YearPioneer(s) / SystemContribution to Blockchain Architecture
1976Whitfield Diffie & Martin HellmanAsymmetric (Public-Key) Cryptography: Introduced public-private keypairs for digital signatures and encryption.
1979Ralph MerkleMerkle Trees (Hash Trees): Efficient cryptographic authentication of large datasets via recursive hashing, enabling O(log⁡N)O(\log N) audit paths.
1982David ChaumDigiCash / Blind Signatures: Cryptographic untraceable digital cash, although reliant on a centralized clearing bank.
1991Stuart Haber & W. Scott StornettaCryptographic Timestamping: Chained digital certificates and Merkle trees to prevent backdating or tampering with digital documents.
1997Adam BackHashcash: Introduced Proof of Work (PoW) computational cost-function using SHA-1 partial hash collisions to combat email spam and DoS attacks.
1998Wei Daib-money: Proposed an anonymous, distributed electronic cash protocol using PoW and decentralized ledgers.
1998Nick SzaboBit Gold & Smart Contracts: Defined digital collectibles using chained PoW proofs and conceptualized self-executing computerized contracts.
2008Satoshi NakamotoBitcoin Whitepaper: Unified PoW, P2P gossip networks, Merkle trees, and Nakamoto consensus into a secure Byzantine Fault Tolerant digital cash system.
2009Satoshi NakamotoGenesis Block (Block 0): Mined on Jan 3, 2009, embedding the Times headline: "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks".
2015Vitalik Buterin & Ethereum TeamEthereum: Generalized blockchain into a Turing-complete decentralized world computer executing smart contracts via the EVM.

3. Distributed Systems Foundations and Fault Tolerance

A blockchain network is fundamentally a distributed system comprising autonomous computational nodes communicating over an asynchronous, unreliable network (the Internet).

3.1 Failure Modes in Distributed Computing

  1. Crash-Stop Failures (Fail-Stop): A node simply ceases operation and halts all message transmission. It never emits erroneous or deceptive data.
  2. Crash-Recovery Failures: A node halts temporarily, recovers, and attempts to re-synchronize state with the active network.
  3. Byzantine Failures (Arbitrary / Malicious Failures): Formulated by Leslie Lamport, Robert Shostak, and Marshall Pease in 1982 (The Byzantine Generals Problem). Nodes may maliciously forge messages, transmit conflicting data to different peers (equivocation), collude with adversaries, or silently drop packets.

3.2 The CAP Theorem and FLP Impossibility

  • FLP Impossibility Theorem (Fischer, Lynch, Paterson, 1985): In a purely asynchronous distributed network, no deterministic consensus algorithm can guarantee both safety (nothing bad happens) and liveness (good things eventually happen) in the presence of even a single unannounced crash failure.
  • Eric Brewer's CAP Theorem: A distributed data store can simultaneously provide at most two of the following three guarantees:
    • Consistency (C): Every read receives the most recent write or an error.
    • Availability (A): Every non-failing node returns a non-error response without guarantee of the latest write.
    • Partition Tolerance (P): The system continues operating despite arbitrary dropped or delayed network messages.

Because physical networks inevitably partition (PP), distributed architectures must choose between Consistency under Partition (CP) (e.g., Tendermint, Raft) or Availability under Partition (AP) (e.g., Bitcoin Nakamoto consensus, which permits temporary forks and provides eventual consistency).

3.3 Byzantine Fault Tolerance (BFT) Thresholds

In classical state-machine replication (PBFT - Practical Byzantine Fault Tolerance by Castro & Liskov, 1999):
n≥3f+1n \ge 3f + 1
Where:

  • nn is the total number of replica nodes.
  • ff is the maximum number of Byzantine (malicious or faulty) nodes tolerated.

To tolerate ff Byzantine actors, the system requires strictly more than 3f3f nodes (meaning Byzantine nodes must represent less than 13≈33.3%\frac{1}{3} \approx 33.3\% of voting power).

In contrast, Nakamoto consensus shifts from static IP-based voting (vulnerable to Sybil attacks) to resource-weighted voting (Proof of Work / "One-CPU-One-Vote"), tolerating up to 50%50\% dishonest computing power under synchronous network assumptions (f<0.5f < 0.5).


4. Blockchain Core Architecture and Cryptographic Foundations

CODE
+-------------------------------------------------------------------------+
|                              BLOCK N                                    |
| +---------------------------------------------------------------------+ |
| | Block Header:                                                       | |
| |  - Version: 4 bytes                                                 | |
| |  - Previous Block Hash: SHA256(SHA256(BlockHeader_{N-1})) (32 bytes)| |
| |  - Merkle Root Hash: 32 bytes                                       | |
| |  - Timestamp: 4 bytes (Unix epoch)                                  | |
| |  - Difficulty Target (nBits): 4 bytes                               | |
| |  - Nonce: 4 bytes (32-bit counter)                                  | |
| +---------------------------------------------------------------------+ |
| | Transaction Counter: varInt                                          | |
| | Transactions: [ Tx0 (Coinbase), Tx1, Tx2, ..., TxK ]                 | |
| +-------------------------------------------------------------------------+

4.1 Cryptographic Hash Functions

A cryptographic hash function H:{0,1}∗→{0,1}kH: \{0, 1\}^* \to \{0, 1\}^k (e.g., SHA-256 where k=256k=256) maps an arbitrary-length input string to a fixed-size bit string satisfying three core properties:

  1. Pre-image Resistance (One-Wayness): Given yy, it is computationally infeasible to find xx such that H(x)=yH(x) = y. Expected brute-force complexity: O(2k)O(2^k).
  2. Second Pre-image Resistance (Weak Collision Resistance): Given xx, it is computationally infeasible to find x′≠xx' \ne x such that H(x)=H(x′)H(x) = H(x').
  3. Collision Resistance (Strong Collision Resistance): It is computationally infeasible to find any pair (x1,x2)(x_1, x_2) with x1≠x2x_1 \ne x_2 such that H(x1)=H(x2)H(x_1) = H(x_2). Due to the Birthday Paradox, search complexity is O(2k/2)O(2^{k/2}) (for SHA-256, 21282^{128} operations).
  4. Avalanche Effect: Flipping a single bit in the input randomly flips approximately 50%50\% of the output bits.

4.2 Merkle Trees and SPV Proofs

Transactions within a block are organized into a binary Merkle Tree.

  • Leaves represent the double-SHA-256 hashes of individual transactions: HA=SHA256(SHA256(TxA))H_A = \text{SHA256}(\text{SHA256}(Tx_A)).
  • Internal parent nodes represent the hash of concatenated child hashes:
    HAB=SHA256(SHA256(HA∥HB))H_{AB} = \text{SHA256}(\text{SHA256}(H_A \mathbin{\Vert} H_B))
  • The root of the tree (Merkle Root) is committed to the 80-byte block header.
CODE
                  [ Merkle Root: H_ABCD ]
                        /         \
              [ H_AB ]               [ H_CD ]
              /      \               /      \
          [ H_A ]   [ H_B ]      [ H_C ]   [ H_D ]
             │         │            │         │
          [ Tx_A ]  [ Tx_B ]     [ Tx_C ]  [ Tx_D ]

Simplified Payment Verification (SPV)

Lightweight clients (defined in Satoshi's Whitepaper Section 8) do not store the multi-gigabyte blockchain body. They only download 80-byte block headers. To prove that transaction TxCTx_C exists in block NN, an SPV client only requires an Audit Path of length O(log⁡2M)O(\log_2 M):
Audit Path for TxC={HD,HAB}\text{Audit Path for } Tx_C = \{ H_D, H_{AB} \}
The client computes:

  1. HC=Hash(TxC)H_C = \text{Hash}(Tx_C)
  2. HCD=Hash(HC∥HD)H_{CD} = \text{Hash}(H_C \mathbin{\Vert} H_D)
  3. HABCD=Hash(HAB∥HCD)H_{ABCD} = \text{Hash}(H_{AB} \mathbin{\Vert} H_{CD})
  4. Checks if HABCD==Merkle Root in HeaderH_{ABCD} == \text{Merkle Root in Header}.

4.3 Ledger Accounting Models: UTXO vs. Account/Balance

Blockchains track asset ownership using two distinct state models:

DimensionUTXO Model (Bitcoin, Cardano)Account / Balance Model (Ethereum, Solana)
State PrimitiveDiscrete unspent transaction outputs (UTXOs).Global world state mapping addresses to balances and storage.
Transaction StructureConsumes existing UTXOs as inputs; generates brand-new UTXOs as outputs.Modifies balances via credit/debit instructions; increments account nonce.
Replay ProtectionInherent: a UTXO can only be spent once; double-spend attempts refer to already consumed outputs.Explicit: sequential account nonce prevents replaying signed transactions.
Concurrency & ParallelismHigh: Independent UTXOs can be processed in parallel across multiple CPU cores without race conditions.Complex: Multiple transactions touching the same account require sequential serialization or optimistic STM.
PrivacyHigh: Encourages single-use change addresses for every transaction.Lower: Encourages address reuse because contract states cluster around fixed accounts.
Smart Contract ExpressivenessScript-based, stateless, intentionally non-Turing complete (Bitcoin Script).Rich stateful Turing-complete programs (Solidity on EVM).

5. Consensus Paradigms: Proof of Work vs. Proof of Stake

Distributed consensus solves the double-spending problem without a trusted clearinghouse.

5.1 Nakamoto Proof of Work (PoW)

Miners compete to discover a 32-bit nonce such that the SHA-256 double-hash of the block header is strictly less than a dynamically adjusted 256-bit target value TT:
SHA256(SHA256(BlockHeader))<T\text{SHA256}(\text{SHA256}(\text{BlockHeader})) < T

  • The difficulty DD is inversely proportional to TT: D=TmaxTD = \frac{T_{\text{max}}}{T}.
  • In Bitcoin, difficulty adjusts every 2016 blocks (≈2 weeks\approx 2\text{ weeks}) to maintain an average block creation time of 10 minutes:
    Dnew=Dold×20160 minutesActual time taken to mine last 2016 blocksD_{\text{new}} = D_{\text{old}} \times \frac{20160\text{ minutes}}{\text{Actual time taken to mine last 2016 blocks}}
  • Fork Choice Rule: Nodes adhere to the Longest Chain Rule (strictly speaking, the chain with the greatest cumulative proof of work).
  • Sybil Resistance: An attacker cannot forge influence through cheap virtual identities because voting weight is strictly bound to thermodynamic energy expenditure and ASIC hardware hashing capacity.

5.2 Proof of Stake (PoS)

In Proof of Stake, block proposers and attestors are selected pseudo-randomly in proportion to their committed economic capital (staked coins).

  • Elimination of Energy Waste: PoS reduces electricity consumption by >99.95%>99.95\% (e.g., Ethereum's Merge in Sept 2022).
  • Economic Penalties (Slashing): If a validator equivocates (proposes two competing blocks at the same height) or signs off on invalid state transitions, the protocol programmatically destroys a portion of their staked assets.
  • Nothing-at-Stake Problem: In early naive PoS models, generating blocks on multiple competing forks cost zero computational energy. Modern PoS protocols (e.g., Casper FFG, Tendermint) neutralize this via slashing penalties and deterministic checkpoints.

6. Decentralization Dimensions and Vitalik's Tripartite Taxonomy

Decentralization is not a binary switch; it is a multi-dimensional spectrum. In 2017, Vitalik Buterin formalized a taxonomy categorizing software systems along three independent axes:

CODE
                          [ Architectural ]
                       /                    \
                      /                      \
          (Distributed Nodes)           (Single Server)
                    /                          \
          [ Political ]                    [ Logical ]
     /                     \            /               \
(No Single Entity)     (One CEO)   (Single Global)   (Fragmented Swarm)
                                       State
  1. Architectural Decentralization: How many physical computers make up the system? How many computer crashes can the network tolerate without failing?
    • Blockchain: Architecturally decentralized (thousands of autonomous nodes worldwide).
  2. Political Decentralization: How many individuals or corporate organizations control the computers that make up the system?
    • Blockchain: Politically decentralized (ideally no single organization can censor transactions or alter consensus).
  3. Logical Decentralization: Does the interface and data structure look like a single monolithic system, or an amorphous swarm?
    • Blockchain: Logically Centralized. The network maintains a single, uniform global state (one canonical balance for every account).

6.1 The Blockchain Scalability Trilemma

Formulated by Vitalik Buterin, a base-layer blockchain can optimize for at most two out of three properties simultaneously:

  • Decentralization: Low hardware requirements allowing everyday users to run validating full nodes.
  • Security: Resistance to large-scale network takeovers (51%51\% attacks or validator collusion).
  • Scalability: High transaction throughput (Transactions Per Second - TPS) and low latency.
CODE
                         [ Scalability ]
                            /       \
                           /         \
                 Layer-2  /           \  Solana, High-Spec
                 Rollups /             \ Consortia
                        /               \
            [ Decentralization ] ─────── [ Security ]
                        Bitcoin, Ethereum Base Layer

7. Ecosystem Layers, Governance, and Forks

A comprehensive blockchain ecosystem encompasses seven interconnected technical layers:

CODE
Layer 7: Governance Layer    - EIPs, BIPs, DAOs, hard/soft fork coordination
Layer 6: Application Layer   - Smart contracts, DeFi protocols, NFT marketplaces
Layer 5: Tooling & RPC Layer - MetaMask, Ethers.js, Infura, Alchemy, Graph Protocol
Layer 4: Execution Layer     - EVM, eBPF, WebAssembly, smart contract execution
Layer 3: Consensus Layer     - PoW (Nakamoto), PoS (Casper), PBFT, Tendermint
Layer 2: Network / P2P Layer - libp2p, devp2p, gossip protocols, node discovery
Layer 1: Cryptographic Layer - SHA-256, Keccak-256, Secp256k1 (ECDSA), BLS signatures

7.1 Protocol Evolution: Soft Forks vs. Hard Forks

Protocol rule modifications fall into two architectural categories:

FeatureSoft Fork (Backward Compatible)Hard Fork (Non-Backward Compatible)
Rule ModificationRestricts valid block space (tightening existing rules). Valid new blocks are recognized by old software.Expands or fundamentally changes block rules. Valid new blocks are rejected as invalid by old software.
Node UpgradesOnly miners/validators must upgrade to enforce the new constraint. Non-upgraded full nodes continue validating blocks without splitting.All network participants (miners, full nodes, exchanges, wallets) must upgrade software binaries.
Chain Split RiskLow: Un-upgraded nodes accept blocks mined under the newer, tighter rules.High: If community consensus fractures, the chain permanently splits into two distinct blockchains (e.g., BTC vs. BCH; ETH vs. ETC).
Historical ExampleBitcoin Segregated Witness (SegWit, BIP 141) in 2017.Ethereum DAO Fork (2016); Bitcoin Cash split (2017).

8. Emerging Frontiers and Next-Generation Architectures

  1. Layer-2 Rollups:
    • Optimistic Rollups (Arbitrum, Optimism): Assume state transitions are valid by default; permit a 7-day challenge window where verifiers can submit Fraud Proofs to revert invalid state roots.
    • Zero-Knowledge Rollups (zkSync, Starknet, Scroll): Execute computation off-chain and submit succinct cryptographic Validity Proofs (zk-SNARKs / zk-STARKs) to Layer-1 for instantaneous mathematical verification.
  2. Modular Blockchains: Unbundling the monolithic blockchain stack into specialized independent layers:
    • Execution: Arbitrum, Starknet.
    • Settlement: Ethereum.
    • Consensus & Data Availability (DA): Celestia, EigenDA, Avail.
  3. Account Abstraction (ERC-4337): Replaces traditional Externally Owned Accounts (EOAs) with smart contract wallets, enabling social recovery, gas sponsorship (paymasters), automated batch transactions, and biometric security.
  4. Real-World Assets (RWA) & DePIN: Tokenizing off-chain financial instruments (treasuries, real estate) and incentivizing decentralized physical hardware infrastructure (Helium, Filecoin) using token economics.