BT Module 2
BT Module 2
DAWN OF BITCOIN
Bitcoin emerged as a response to the inefficiencies and limitations of centralized systems:
Trustless Transactions: It replaces intermediaries with cryptographic proof.
Decentralization: Transactions are validated by a distributed network, not a central authority.
Resilience: The system combines cryptography, game theory, and computer science to withstand
cyberattacks.
By leveraging technological advancements, Bitcoin provides a new era of currency—one backed not by trust
but by computing power and consensus. Since its launch in 2009, Bitcoin has become a global phenomenon,
showcasing the transformative potential of blockchain.
BITCOIN
Bitcoin is a decentralized cryptocurrency designed for peer-to-peer transactions without relying on
centralized intermediaries such as banks. Unlike traditional currencies, Bitcoin is global, not tied to any
nation, and operates independently in the following dimensions:
Technical: Uses blockchain technology for secure, transparent transactions.
Logical: Built on cryptographic proof rather than trust in intermediaries.
Political: Free from governmental or institutional control.
Key Features of Bitcoin:
Supply Cap: A maximum of 21 million Bitcoins can ever be produced, with mining continuing until
approximately 2140.
Divisibility: Each Bitcoin can be divided into 100,000,000 units, the smallest unit being called a
Satoshi (0.00000001 BTC).
Decentralized Mining: Individuals with sufficient computing power can mine new Bitcoins and
validate transactions.
Value Determinants: Influenced by trust, adoption, supply, and demand.
Data Integrity
Any modification to a block changes its hash, which would ripple through all subsequent blocks.
Tampering becomes impractical due to the decentralized nature of the network: hacking 51% of
nodes simultaneously is infeasible.
Block Structure
A Bitcoin block consists of several components:
Fields in the Block:
Merkle Trees
Merkle trees organize transaction hashes into a binary tree structure.
The root hash (Merkle root) ensures data integrity for all transactions in the block.
Efficiently verifies if a transaction belongs to a block using the Merkle path, reducing computational
overhead.
BITCOIN NETWORK
The Bitcoin network operates as a decentralized, peer-to-peer network with no central authority or
hierarchy.
The above diagram shows how Bitcoin networks coexist on the same Internet stack.
Nodes can join or leave the network freely, ensuring its robustness and flexibility.
Nodes are categorized as:
o Full Nodes: Download and store the entire blockchain, perform all functions (e.g., mining,
transaction validation).
o Lightweight Nodes (SPVs): Use Simplified Payment Verification for transactions and rely
on full nodes for complete blockchain details.
Node Discovery
When a new node joins the Bitcoin network, it uses methods like:
o DNS Seeds: Predefined DNS addresses to discover active Bitcoin nodes.
o Hardcoded IPs: A built-in list of stable nodes in Bitcoin client software.
Nodes connect to peers through a handshake process and exchange essential information, such as
version numbers and blockchain height.
Bitcoin Transactions
Transactions are categorized into:
o Coinbase Transactions: Newly mined coins added to a block by miners.
o Regular Transactions: Transfer of Bitcoin ownership via digital signatures.
The transaction lives until it has been executed till the time another transaction is done out of that
UTXO. UTXO stands for Unspent Transaction Output.
o It is the amount of digital currency someone has left remaining after executing a transaction.
o When a transaction is completed, the unspent output is deposited back into the database as
input which can be used later for another transaction.
Transactions link previous unspent outputs (UTXOs) to new outputs, ensuring no "closing balance"
but a traceable chain of ownership.
Preventing double-spending is achieved through network-wide transaction broadcasting and
validation.
Double-Spend Scenarios
In cases where the same input is used in multiple transactions:
o The first valid transaction received is accepted.
o Conflicting transactions are discarded once a block containing the accepted transaction is
mined.
Bitcoin Transactions
1. Structure:
o A transaction comprises inputs (references to previous transaction outputs) and outputs
(newly created outputs with locking conditions).
o Includes fields such as version, input/output counters, and optional lock time.
2. Key Concepts:
o UTXO (Unspent Transaction Output): The spendable output from a prior transaction.
o ScriptPubKey (Output Script): Locks the Bitcoin to the recipient's address.
o ScriptSig (Input Script): Unlocks a previous UTXO, allowing it to be spent.
3. Validation Process:
o Miners combine the ScriptSig of the current transaction with the ScriptPubKey of the
referenced transaction to form a validation script.
o This combined script executes in a stack-based virtual machine.
Remember that both the inputs and outputs of transactions are equipped with relevant scripts to make it
possible. It is only through the scripts that it can be ensured that you are the authorized user to make a
transaction and you have the necessary amount that you have received from a previous transaction. This
means that both the inputs and outputs are equally important.
SCRIPT EXECUTION
1. Components:
o Data Instructions: Push values (e.g., public keys, signatures) onto the stack.
o Opcodes: Perform operations on the stack (e.g., duplicate values, hash data, verify
signatures).
2. Common Opcodes:
o OP_DUP: Duplicates the top stack item.
o OP_HASH160: Applies SHA-256 followed by RIPEMD-160 hashing.
o OP_EQUALVERIFY: Verifies equality between the top two stack items.
o OP_CHECKSIG: Validates the signature using the public key for the given data.
3. Stack Workflow:
o Instructions are sequentially processed.
o Example for Bob spending Bitcoins:
1. Push Bob's signature and public key onto the stack.
2. Duplicate and hash the public key, matching it against the Bitcoin address.
3. Verify the signature using OP_CHECKSIG.
Mechanism:
o Use Bloom filters to query relevant transactions without revealing specific addresses or keys.
o Peers respond with a merkleblock message, including the Merkle root and path for the
transaction of interest.
Efficiency: Require minimal storage (a few MBs for block headers) and bandwidth, making them
suitable for devices with limited resources.
BITCOIN WALLET
A Bitcoin wallet is a digital tool used to store, manage, and transact Bitcoin securely. It functions as a
repository for your private/public key pair, enabling you to send, receive, and verify Bitcoin transactions.
Wallet Features:
Store and protect the private key.
Generate a public key and Bitcoin address for transactions.
Retrieve and display UTXOs (Unspent Transaction Outputs).
Sign transactions using the private key to authorize Bitcoin spending.
Broadcast signed transactions to the Bitcoin network.
Types of Wallets:
1. Full Node Wallets:
o Connected directly to a Bitcoin full node for maximum security and privacy.
o Requires significant storage and bandwidth to maintain the entire blockchain.
2. SPV Wallets (Lightweight Wallets):
o Do not store the entire blockchain; rely on SPV mechanisms to verify transactions.
o Query full nodes for information, introducing potential privacy risks as the node becomes
aware of your public addresses.
o Example: BitcoinJ (a library for SPV-based wallet creation and interaction).
3. Third-Party Wallet Services:
o Managed by external providers, often offering user-friendly interfaces.
o Centralized services introduce risks of hacking or fraud, potentially leading to the loss of
funds.