Comprehensive Guide to Blockchain Systems, CAP Theorem, and Cryptography
1. Centralized, Decentralized, and Distributed Systems
1. Centralized System
A centralized system is a system where a single central authority or server controls the entire system. All operations and data are managed by this central authority.
Example: Traditional banking system.
Client
v
+--------------+
| Central |
| Server |
+--------------+
/ | \
v v v
Client Client Client
Features:
- Single authority controls the system.
- Data is mainly maintained at a central server.
- Easy to manage and control.
- Failure of the central server can affect the entire system.
2. Decentralized System
A decentralized system distributes decision-making among multiple nodes or participants instead of having one central authority.
Node
/ \
Node --- Node
| \ / |
| \ / |
Node --- Node
Features:
- No single authority has complete control.
- Decision-making is distributed among participants.
- Provides better security and fault tolerance.
- Blockchain networks commonly use decentralization.
3. Distributed System
A distributed system consists of multiple interconnected nodes, where data and computation are spread across the network. The nodes work together to achieve a common outcome.
Node A -------- Node B
| \ / |
| \ / |
| \ / |
Node C -------- Node D
Each node can communicate with other nodes and participate in processing and validating information.
Features:
- Data and computation are distributed across multiple nodes.
- Nodes communicate with each other.
- The system can continue functioning even if some nodes fail.
- Coordination and fault tolerance are important challenges.
2. CAP Theorem and Methods of Decentralization
CAP Theorem
CAP theorem, also known as Brewer’s theorem, states that a distributed system cannot guarantee Consistency, Availability, and Partition Tolerance simultaneously.
The three properties are:
1. Consistency (C)
Consistency ensures that all nodes in a distributed system have a single, current, and identical copy of the data.
2. Availability (A)
Availability means that the nodes in the system are accessible for use and respond to incoming requests without failure.
3. Partition Tolerance (P)
Partition tolerance is the ability of the system to continue operating despite network failures, such as dropped connections, slow network connections, or loss of communication between nodes.
CAP Trade-off
When a network partition occurs, a distributed system must make a choice between Consistency and Availability.
- High Consistency → Lower Availability
- High Availability → Lower Consistency
Partition tolerance is necessary for reliable distributed systems because network failures can occur.
Methods of Decentralization
The notes describe two methods of achieving decentralization:
1. Disintermediation
Disintermediation removes the need for a central intermediary between parties.
For example, in a blockchain network, users can transact directly with each other without requiring a bank or other third party to validate every transaction.
2. Competition
In this method, different service providers compete with each other to provide a service. Smart contracts can make a choice based on predefined criteria.
This does not necessarily provide complete decentralization, but it allows smart contracts to make decisions based on the specified criteria.
3. Asymmetric Cryptography in Blockchain
Asymmetric cryptography, also called public-key cryptography, is a cryptographic technique that uses a pair of keys: a public key and a private key. It is widely used in blockchain to provide security, authentication, and digital signatures.
1. Public Key
The public key can be freely shared with others. It is generally used to identify an account or verify a digital signature.
2. Private Key
The private key must be kept secret by the owner. It is used to create digital signatures and authorize transactions.
Working in Blockchain
User
+------+------+
| |
Public Key Private Key
| |
v v
Shared with Kept Secret
Network |
v
Sign Transaction
v
Blockchain
v
Verify using
Public Key
Digital Signature Process
- The user creates a Bitcoin transaction.
- The transaction is signed using the user’s private key.
- The signed transaction is broadcast to the blockchain network.
- Other nodes use the corresponding public key to verify the signature.
- If the signature is valid, the transaction can be accepted and processed.
Advantages
- Provides authentication of the transaction sender.
- Ensures integrity of the transaction.
- The private key allows only the owner to authorize transactions.
- The public key allows others to verify the authorization.
4. Types of Wallets in Bitcoin
A Bitcoin wallet is a software program or hardware device that allows users to store, manage, send, and receive Bitcoin. It primarily manages the private keys required to access and spend the user’s Bitcoin.
Types of Bitcoin Wallets
1. Desktop Wallet
A desktop wallet is a wallet application installed on a computer.
Example: Bitcoin Core.
Features:
- Provides control over private keys.
- Can provide good security when the computer is secure.
- Vulnerable if the computer is infected with malware.
2. Mobile Wallet
A mobile wallet is an application installed on a smartphone.
Example: Electrum Mobile.
Features:
- Convenient for everyday transactions.
- Easy to carry and use.
- Security depends on the security of the mobile device.
3. Web Wallet
A web wallet is accessed through a web browser and is generally managed by an online service.
Example: Blockchain.com wallet.
Features:
- Can be accessed from different devices.
- Easy to use.
- Users must trust the service and protect their account credentials.
4. Hardware Wallet
A hardware wallet is a physical device designed to securely store private keys.
Example: Ledger or Trezor.
Features:
- Provides strong protection against online attacks.
- Private keys are kept in the hardware device.
- Suitable for storing Bitcoin for longer periods.
5. Paper Wallet
A paper wallet stores the private key and/or public address on paper, usually in printed or QR-code form.
Features:
- Not connected to the internet.
- Protected from online attacks.
- Can be lost, damaged, or physically stolen.
5. Structure of a Bitcoin Transaction
A Bitcoin transaction is a digitally signed message that transfers Bitcoin from one owner to another. The transaction is recorded on the Bitcoin blockchain after it is validated by the network.
Structure of a Bitcoin Transaction
A Bitcoin transaction mainly consists of the following components:
1. Transaction Input
The input specifies the source of the Bitcoin being spent. It refers to a previous transaction output that contains the Bitcoin available to the user.
2. Transaction Output
The output specifies where the Bitcoin is being sent. It contains the amount of Bitcoin and the conditions that must be satisfied to spend it.
3. Transaction ID
Each transaction is identified by a unique Transaction ID (TXID), which is generated using cryptographic hashing.
4. Digital Signature
The transaction is authorized using the sender’s private key. The digital signature proves that the owner has authorized the transaction.
5. Public Key / Address
The recipient’s Bitcoin address or corresponding public-key information identifies where the Bitcoin should be transferred.
Basic Structure
Previous Transaction
v
+----------------+
| INPUT |
| Previous TX ID |
| Digital Sign. |
+-------+--------+
v
+----------------+
| TRANSACTION |
+-------+--------+
v
+----------------+
| OUTPUT |
| Bitcoin Amount |
| Recipient |
| Address |
+----------------+
Working
- The sender selects an unspent transaction output (UTXO) as the input.
- The transaction is created with the recipient’s address and the amount.
- The sender signs the transaction using their private key.
- The transaction is broadcast to the Bitcoin network.
- Network nodes verify the transaction.
- After confirmation, the transaction becomes part of the Bitcoin blockchain.
6. Consensus Algorithms in Blockchain
Need for Consensus Algorithms
A consensus algorithm is a mechanism used by blockchain network participants to agree on the validity and order of transactions without requiring a central authority.
The main needs are:
- To maintain agreement among distributed nodes.
- To validate transactions and prevent fraudulent transactions.
- To prevent double spending.
- To decide which block should be added to the blockchain.
- To maintain the security and integrity of the blockchain network.
1. Proof of Work (PoW)
Proof of Work is a consensus mechanism in which miners compete to solve a computationally difficult mathematical problem.
Working of PoW
- Transactions are collected into a block.
- Miners compete to find a valid nonce that satisfies the required hash condition.
- The miner who finds the valid solution first broadcasts the block.
- Other nodes verify the solution.
- If valid, the block is added to the blockchain.
- The successful miner receives a block reward.
Transactions
↓
New Block
↓
Miners
↓
Solve Mathematical Problem
↓
Valid Proof of Work
↓
Verify by Network
↓
Add Block to Blockchain
Advantages: High security and resistance to attacks.
Disadvantage: Requires a large amount of computational power and electricity.
2. Proof of Burn (PoB)
Proof of Burn is a consensus mechanism where participants burn cryptocurrency by sending it to an address from which it cannot be recovered.
The participant demonstrates commitment to the network by permanently destroying coins.
Working of PoB
User
↓
Owns Cryptocurrency
↓
Sends Coins to
Unspendable Address
↓
Coins Burned
↓
Participant gains
mining/validation
rights
↓
New Block
Features of PoB
- Coins are permanently removed from circulation.
- It does not require the same level of computational power as PoW.
- It demonstrates a user’s commitment to the blockchain.
- The major drawback is that the burned coins cannot be recovered.
