Blockchain Notes
Module 1.....................................................................................................................................2
What is blockchain?................................................................................................................................................ 2
Structure of Block...................................................................................................................................................... 3
Transactions.................................................................................................................................................................5
Public Ledger................................................................................................................................................................ 7
Distributed Consensus.......................................................................................................................................... 9
Peer-to-Peer Systems........................................................................................................................................... 11
Centralised vs. Decentralised Systems....................................................................................................13
Types of Blockchain...............................................................................................................................................16
Module 2...................................................................................................................................19
Cryptographic Hash Functions in Blockchain..................................................................................... 19
Hash Chain...................................................................................................................................................................21
Merkle Tree..................................................................................................................................................................23
Public Key Cryptography.................................................................................................................................. 25
Digital Signature......................................................................................................................................................27
Use of hash functions and digital signatures.................................................................................... 29
Module 3..................................................................................................................................30
Creation of Coins................................................................................................................................................... 30
Double Spending..................................................................................................................................................... 31
Script (FORTH)...........................................................................................................................................................32
Mining Process......................................................................................................................................................... 34
Objectives of Consensus Mechanisms in Blockchain.................................................................. 35
Proof of Work (PoW)............................................................................................................................................. 36
Sybil Attack................................................................................................................................................................. 37
Proof of Elapsed Time (PoET)......................................................................................................................... 38
Proof of Stake (PoS)..............................................................................................................................................39
Proof of Burn (PoB)................................................................................................................................................ 40
Module 4..................................................................................................................................... 41
Smart Contracts.......................................................................................................................................................41
Distributed Consensus in Blockchain.......................................................................................................43
1
Paxos...............................................................................................................................................................................45
RAFT..................................................................................................................................................................................47
Byzantine Fault Tolerance (BFT).................................................................................................................. 49
Practical Byzantine Fault Toleranqnce (PBFT).....................................................................................51
Module 5...............................................................................................................................................................................53
History of Ethereum.............................................................................................................................................. 53
Ethereum's Architecture....................................................................................................................................55
2
Module 1
What is blockchain?
Imagine a giant spreadsheet that everyone can see, but no one can change.
It's a system for recording information to make it secure and transparent.
Here's how it works
1. Information is grouped into blocks.
2. Each block is linked to the one before it, forming a chain.
3. This chain is constantly growing as new information is added.
The key is that it can't be changed once information is recorded in a block. This
is because each block contains a special code that refers to the code of the block
before it. If someone tried to change the information in a block, they would also have
to change all the codes of the blocks after it, which is very difficult (and almost
impossible) to do.
So, what can you use blockchain for? Well, it's useful for anything where you
need a secure and reliable record of information. For example, it's used in
cryptocurrencies like Bitcoin to track who owns what coins. It can also track medical
records, voting records, or even house ownership.
Here are some benefits of blockchain
1. Secure: It's very difficult to tamper with information on a blockchain.
2. Transparent: Everyone can see the information on a blockchain.
3. Efficient: Blockchain can automate many tasks and processes.
Blockchain is a complex technology, but this explanation gives you a basic
idea of how it works!
3
Structure of Block
A block in a blockchain acts like a container for recording transactions. These
blocks are chained together to form a chronological record, ensuring security and
tamper-proof data.
Block Header
Previous Block Hash: This is a unique identifier referencing the hash of the block
preceding it in the chain. It creates a linked list structure, where each block points
back to the previous one. The first block, called the genesis block, has a special hash
value.
Timestamp: This indicates the exact time the block was created.
Nonce: This is a random number used in the mining process (depending on the
consensus mechanism). By manipulating the nonce, miners can alter the hash of the
block until it meets specific criteria.
Merkle Root: This is a cryptographic hash representing all the transactions bundled
together in the block. It uses a Merkle tree, a compressed data structure that
efficiently ensures data integrity.
Block Body
4
Transaction Data: This section stores the actual data about the transactions that
took place, such as the sender, receiver, and amount (in cryptocurrency
transactions).
Here's some additional information to consider:
Block Size: Blockchains often have a limit on the size of a block to manage network
efficiency.
Block Reward: In some blockchains, miners receive a reward for successfully adding
a new block.
5
Transactions
A blockchain transaction is essentially a digital record of an event or action. In
the context of cryptocurrencies, it typically represents the transfer of value (like
Bitcoin or Ethereum) from one digital wallet to another. However, blockchain
technology goes beyond just digital currencies and can record any data.
Key Components of a Blockchain Transaction
1. Sender: The individual or entity initiating the transaction.
2. Recipient: The individual or entity receiving the value or data.
3. Amount: The quantity of value being transferred (in the case of
cryptocurrency) or the specific data being recorded.
4. Timestamp: The exact time the transaction occurred.
5. Digital Signature: A cryptographic signature verifying the sender's identity and
authorisation.
How Transactions Work
1. Creation: A transaction is initiated by the sender, who provides the necessary
information (recipient, amount, etc.) and signs it with their private key.
2. Broadcasting: The transaction is broadcast to the entire blockchain network.
3. Verification: Network nodes (computers) validate the transaction by checking
its authenticity, ensuring the sender has sufficient funds (in the case of
cryptocurrency), and confirming that the transaction hasn't been altered.
4. Inclusion in a Block: Once verified, the transaction is added to a block along
with other verified transactions.
5. Mining (or Validation): Miners (or validators in other blockchains) compete to
solve a complex mathematical puzzle. The first to solve it adds the block to the
blockchain. This process secures the network and adds the transactions to the
permanent record.
6
Key Characteristics of Blockchain Transactions
1. Immutability: Once a transaction is recorded in a block, it cannot be altered
or deleted.
2. Transparency: All transactions are visible to everyone on the network,
ensuring transparency and accountability.
3. Security: Cryptographic techniques protect the integrity and security of
transactions.
4. Decentralisation: Transactions are processed and verified by a network of
computers rather than a central authority.
Beyond Cryptocurrencies
While cryptocurrency transfers are the most common use case, blockchain
technology has broader applications:
1. Supply chain management: Tracking the movement of goods from origin to
consumer.
2. Healthcare: Securely storing and sharing medical records.
3. Voting systems: Ensuring fair and transparent elections.
4. Real estate: Facilitating property transactions and ownership verification.
Here are the key things that are typically verified in a transaction before it's sent on
the blockchain
1. Sender's Identity and Authorization: The transaction must be signed by the
sender's private key to verify their identity and authorise the transfer.
2. Recipient's Address: The recipient's address must be valid and exist on the
blockchain.
3. Sufficient Funds: The sender must have enough cryptocurrency to cover the
transaction fee and the amount being sent.
4. Transaction Format: The transaction must adhere to the specific format and
rules defined by the blockchain protocol.
5. Double Spending Prevention: The blockchain's consensus mechanism
ensures that the same cryptocurrency cannot be spent twice. This is typically
achieved through techniques like hashing and time stamping.
6. Transaction Fee: A transaction fee is often required to incentivize miners to
include the transaction in a block. The fee amount varies depending on
network congestion and the sender's priority to the transaction.
7
Public Ledger
A public ledger in blockchain is essentially a shared digital record of
transactions. It's like a massive, transparent spreadsheet that everyone on the
network can see and access.
Key Characteristics
1. Decentralized: Unlike traditional ledgers held by a single entity (like a bank),
the public ledger is distributed across multiple computers (nodes) on the
network.
2. Immutable: Once information is recorded on the ledger, it cannot be altered
or deleted, providing a high level of security and trust.
3. Transparent: All transactions are visible to everyone on the network,
promoting transparency and accountability.
4. Secure: Cryptographic techniques protect the integrity of the ledger and the
data within it.
How it Works
1. Transactions: When a transaction occurs (e.g., sending cryptocurrency), it's
broadcast to the entire network.
2. Verification: Network nodes validate the transaction to ensure its authenticity
and accuracy.
3. Block Creation: Verified transactions are grouped into blocks.
4. Mining (or Validation): Miners (or validators in other blockchains) compete to
solve a complex mathematical puzzle. The first to solve it adds the block to the
blockchain, creating a new record on the public ledger.
8
Importance of the Public Ledger
1. Trust and Transparency: By making all transactions visible, it builds trust
among network participants.
2. Security: The decentralized nature and cryptographic protections make it
difficult to tamper with the ledger.
3. Auditability: Anyone can verify the accuracy of the ledger and transactions.
4. Efficiency: Eliminates the need for intermediaries, streamlining processes.
9
Distributed Consensus
Distributed consensus is the backbone of blockchain technology. It's the
process by which a network of computers (nodes) agrees on a single, shared state
or value, even though they are independent and may have different initial states or
inputs.
In simpler terms, it's how a group can agree on a single version of the truth
without a central authority telling them what to do.
How it Works in Blockchain
In a blockchain, distributed consensus ensures that all nodes agree on the
order and content of transactions. This is crucial for maintaining the blockchain's
integrity and security.
Here's a breakdown of the process
1. Transaction Broadcasting: When a transaction occurs, it's broadcast to all
nodes in the network.
2. Verification: Each node independently verifies the transaction to ensure it's
valid (e.g., the sender has sufficient funds, and the transaction is correctly
formatted).
3. Consensus Algorithm: This is where the magic happens. Various algorithms
(like Proof of Work, Proof of Stake, etc.) determine which node gets to add the
next block of transactions to the blockchain. This process ensures that all
nodes agree on the order of transactions.
4. Block Creation: The chosen node creates a new block containing the verified
transactions and adds it to the end of the blockchain.
5. Propagation: The new block is shared with all nodes in the network.
10
Importance of Distributed Consensus
1. Security: By requiring multiple nodes to agree on the blockchain's state,
malicious actors will find it challenging to tamper with the data.
2. Decentralisation: There's no single point of failure. The network is resilient to
attacks and censorship.
3. Transparency: All nodes have a copy of the blockchain, making it transparent
and auditable.
4. Trustlessness: The system functions without relying on a central authority,
fostering trust among participants.
Common Consensus Algorithms
1. Proof of Work (PoW): Nodes compete to solve complex mathematical puzzles
to validate transactions and create new blocks. Bitcoin uses PoW.
2. Proof of Stake (PoS): Nodes are selected to create new blocks based on the
cryptocurrency they hold (stake). Ethereum transitioned from PoW to PoS.
3. Delegated Proof of Stake (DPoS): A subset of nodes (delegates) is elected by
token holders to validate transactions.
By understanding distributed consensus, you can appreciate the underlying
mechanics of blockchain technology and its potential to revolutionize various
industries.
YouTube Link
1. Consensus in Blockchain Technology in Hindi
11
Peer-to-Peer Systems
A blockchain is inherently a peer-to-peer (P2P) system. This means that
there's no central authority controlling the network. Instead, all participants (nodes)
have equal power and responsibilities.
How it Works
1. Decentralisation: Each node in the network maintains a complete copy of the
blockchain. This ensures redundancy and prevents a single point of failure.
2. Communication: Nodes directly communicate with each other to share
information about new transactions and blocks.
3. Consensus: Nodes work together to agree on the validity of transactions and
the order in which they are added to the blockchain. This is achieved through
consensus algorithms like Proof of Work or Proof of Stake.
4. Security: The distributed nature of the network makes it extremely difficult to
attack or manipulate the blockchain.
Benefits of a P2P Blockchain
1. Resilience: The network can continue to operate even if some nodes go offline.
2. Security: Decentralization makes it harder for hackers to compromise the
system.
3. Transparency: Everyone can see the entire history of transactions.
4. Efficiency: Eliminates the need for intermediaries, reducing costs and
processing times.
Real-world Example: Bitcoin
Bitcoin is a prime example of a P2P blockchain system. No central bank or
authority is controlling the network. Instead, thousands of computers around the
world participate in processing transactions and securing the network.
12
In essence, a P2P blockchain is a democratic system where all participants
have equal rights and responsibilities. This decentralized architecture is fundamental
to the security, transparency, and efficiency of blockchain technology.
13
Centralised vs. Decentralised Systems
Centralised Systems
In a centralised system, control and decision-making are concentrated in the
hands of a single entity or a small group. This authority manages all aspects of the
network, including data storage, processng, and validation.
Key characteristics
1. Single point of control
2. High efficiency and scalability
3. Potential for censorship and manipulation
4. Vulnerability to single points of failure
Example: Traditional banking systems, where a central authority (the bank) controls
all transactions and data.
Decentralised Systems
In a decentralised system, control is distributed among multiple participants (nodes)
in the network. No single entity has complete authority. Instead, decisions are made
collectively through consensus mechanisms.
Key characteristics
1. Distributed control and decision-making
2. Enhanced security and resilience
3. Increased transparency and trust
4. Potential for slower performance and scalability challenges
Example: Blockchain technology, where multiple nodes validate and record
transactions, ensuring transparency and security.
Blockchain and Decentralisation
Blockchain is fundamentally a decentralised system. This is one of its core
principles. By distributing control and data across a network of computers,
blockchain offers several advantages:
1. Security: It's harder to hack or manipulate a decentralised system as there's
no single point of attack.
2. Transparency: All transactions are visible to everyone on the network,
increasing trust and accountability.
14
3. Censorship resistance: It's difficult to censor or block transactions as there's
no central authority to control the network.
4. Resilience: The network can continue to function even if some nodes fail.
However, decentralization also comes with challenges, such as scalability and
performance limitations. To address these issues, some blockchain platforms are
exploring hybrid models that combine elements of centralization and
decentralization.
In conclusion, while centralized systems offer efficiency and scalability, they
are prone to censorship and single points of failure. Decentralized systems, like
blockchain, prioritise security, transparency, and resilience, but may face
performance challenges. The choice between centralised and decentralised systems
depends on the specific requirements of an application.
15
Feature Centralised System Decentralised System
Control Single authority Distributed among participants
Data Storage Centralised server Distributed across nodes
Processing Centralised server Distributed among nodes
Generally faster and more Can be slower and face scalability
Scalability scalable challenges
Vulnerable to a single point More secure due to the distributed
Security of attack nature
Less transparent, data
controlled by central
Transparency authority Transparent, all transactions visible
Censorship Prone to censorship by
Resistance central authority Resistant to censorship
Vulnerable to single point of More resilient, and can continue to
Resilience failure function even if some nodes fail
16
Types of Blockchain
1) Public Blockchain
a) Accessibility: Open to anyone.
b) Permission: Permissionless.
c) Governance: Decentralized.
d) Examples: Bitcoin, Ethereum
e) Characteristics
i) Transparent and immutable.
ii) Anyone can participate in mining and validating transactions.
iii) Ideal for cryptocurrencies and decentralized applications.
2) Private Blockchain
a) Accessibility: Restricted to authorised participants.
b) Permission: Permissioned.
c) Governance: Centralized.
d) Examples: Hyperledger Fabric, Corda
e) Characteristics
i) Controlled by a single entity or a consortium.
ii) Offers greater privacy and security.
iii) Suitable for enterprise applications and supply chain
management.
17
3) Consortium Blockchain
a) Accessibility: Restricted to a predefined group of organisations.
b) Permission: Permissioned.
c) Governance: Semi-decentralized.
d) Examples: R3 Corda, Hyperledger Besu
e) Characteristics
i) Collaboratively managed by a group of organisations.
ii) Offers a balance between privacy and transparency.
iii) Ideal for industry-specific use cases.
18
4) Hybrid Blockchain
a) Accessibility: Combines elements of public and private blockchains.
b) Permission: Can be permissioned or permissionless.
c) Governance: Hybrid.
d) Examples: Ethereum's hybrid scaling solutions
e) Characteristics
i) Offers flexibility and customization.
ii) Suitable for various use cases, including financial services and
healthcare.
19
Module 2
Cryptographic Hash Functions in Blockchain
Cryptographic hash functions are essential components of blockchain
technology, providing security, integrity, and efficiency. These functions take an
arbitrary-sized input (data) and produce a fixed-size output (hash). The key
properties of these functions are:
1. Collision Resistance
a. Definition: Finding two distinct inputs that produce the same hash
output is computationally infeasible.
b. Importance in Blockchain
i. Data Integrity: Ensures that data stored on the blockchain hasn't
been altered. If even a single bit is changed, the hash will be
different, making tampering evident.
ii. Proof of Work: In proof-of-work consensus mechanisms, miners
must find a nonce (random value) that, when combined with the
block's data, produces a hash below a target difficulty. Collision
resistance ensures that finding this nonce is a challenging
computational task.
2. Hiding
a. Definition: The hash output reveals no information about the input data.
b. Importance in Blockchain
i. Privacy: Protects the privacy of transaction data. Even if a hash is
known, it's difficult to determine the original input.
ii. Anonymity: Allows for anonymous transactions, as the sender
and recipient's identities can be masked.
20
3. Puzzle Friendliness
a. Definition: The hash function is suitable for creating computationally
challenging puzzles.
b. Importance in Blockchain
i. Proof of Work: The difficulty of finding a nonce that produces a
hash below a target value directly results from the hash
function's puzzle-friendliness. This ensures the network's security
by making it computationally expensive to create new blocks.
ii. Consensus: The hash function's puzzle-friendliness helps
maintain consensus among nodes in the network. By requiring a
significant amount of computational effort to create a new block,
it discourages malicious actors from manipulating the
blockchain.
Common Hash Functions Used in Blockchain
1. SHA-256: Widely used in Bitcoin and other cryptocurrencies.
2. Keccak-256: Used in Ethereum and other blockchain platforms.
3. Blake2: Known for its speed and security.
21
Hash Chain
A hash chain, also known as a cryptographic hash chain, is a series of
cryptographic hashes linked together linearly. Each hash in the chain is derived from
the previous hash, creating a chain of interconnected blocks of data.
A hash chain is a sequence of cryptographic hash values where each hash in
the sequence depends on the previous one. It’s a one-way function—easy to
compute but hard to reverse—creating an ordered chain of hashed values.
How it works
1. Initial Hash: The first hash in the chain is calculated from a starting value or
seed.
2. Successive Hashes: Each subsequent hash is calculated by hashing the
previous hash together with a new piece of data. This creates a chain of
interconnected hashes.
3. Integrity Verification: By comparing the final hash in the chain to a known
value, the integrity of the entire chain can be verified. If any of the hashes have
been altered, the final hash will be different.
H1=Hash(H0)
H2=Hash(H1)
H3=Hash(H2), and so on.
Key Properties
1. One-Way: Once a hash is computed, it’s very hard to go backwards (from H_1
to H_0).
2. Tamper Resistance: If anyone alters any link in the chain, the subsequent
hashes change, making tampering easily detectable.
3. Deterministic: The same input will always produce the same hash.
Applications of Hash Chains in Blockchain
1. Block Linking: In blockchains, each block contains a hash of the previous
block. This creates a chain of blocks, ensuring that the order of blocks cannot
be altered without being detected.
2. Data Integrity: Hash chains can be used to verify the integrity of large
datasets, ensuring that the data has not been tampered with or corrupted.
22
3. Digital Signatures: Hash chains can be used to create digital signatures,
where a hash of a document is signed and stored in a chain. This ensures the
authenticity and integrity of the document.
Advantages of Hash Chains
1. Security: Hash chains are resistant to tampering, as any alteration to the data
will result in a different final hash.
2. Efficiency: Hash chains can be verified efficiently, as only the final hash needs
to be compared to the known value.
3. Scalability: Hash chains can be used to verify large datasets without
compromising security or efficiency.
23
Merkle Tree
Merkle Trees are a fundamental data structure used in blockchain technology
to efficiently verify the integrity of large datasets. They provide a way to represent
and validate a vast amount of information compactly and securely.
How a Merkle Tree Works
1. Data Division: The data to be verified is divided into smaller pieces or leaves.
2. Hashing: Each leaf is hashed, creating a unique hash value.
3. Pairwise Hashing: Pairs of hash values are combined and hashed again,
creating a new hash value.
4. Tree Structure: This process continues until a single hash value, known as the
Merkle Root, is obtained.
5. Tree Verification: To verify the integrity of a specific piece of data, only the
hash of that leaf and the Merkle Root need to be compared. If they match, the
data is considered valid.
Benefits of Using Merkle Trees in Blockchain
1. Efficient Verification: By only needing to compare the hash of the desired
data with the Merkle Root, the verification process is significantly faster than
checking every individual piece of data.
2. Security: Merkle Trees provide a high level of security as any alteration to the
data would result in a different Merkle Root, making it easy to detect
tampering.
24
3. Scalability: Merkle Trees can handle large datasets efficiently, making them
suitable for blockchain applications that need to store and verify vast
amounts of information.
4. Privacy: Merkle Trees can be used to selectively disclose information while
maintaining privacy for the rest of the data.
YouTube Links
1. Merkle tree in blockchain
2. Merkle Tree in Blockchain 🔥🔥
25
Public Key Cryptography
Public Key Cryptography is a cryptographic system that uses a pair of keys: a
public key and a private key. These keys are mathematically related, but one cannot
be derived from the other.
How it works
1. Key Generation: A user generates a pair of keys: a public key and a private
key.
2. Public Key Distribution: The public key is freely distributed to anyone who
wants to communicate with the user.
3. Encryption: To send a message to the user, someone uses the public key to
encrypt the message.
4. Decryption: The user uses their private key to decrypt the encrypted message.
Key Points
1. Public Key: This can be shared openly without compromising security.
2. Private Key: Must be kept secret.
3. Encryption: Only the private key can decrypt a message encrypted with the
corresponding public key.
4. Digital Signatures: Public key cryptography can also be used to create digital
signatures, verifying a message's authenticity.
Common Uses
1. Secure communication: For sending encrypted messages and emails.
2. Digital signatures: For verifying the authenticity of documents and electronic
transactions.
3. Authentication: For verifying user identities.
4. Key exchange: For securely exchanging cryptographic keys over a public
network.
26
Examples of Public Key Cryptography Algorithms
1. RSA: One of the most widely used public key cryptography algorithms.
2. ECC (Elliptic Curve Cryptography): A more efficient alternative to RSA, often
used in mobile devices and embedded systems.
3. DSA (Digital Signature Algorithm): Primarily used for digital signatures.
27
Digital Signature
Digital signatures are a cryptographic technique used to verify the
authenticity and integrity of digital data. They serve as a digital equivalent of a
handwritten signature, assuring that a message or document originates from a
specific sender and has not been altered in transit.
How Digital Signatures Work
1. Key Generation: A user generates a pair of cryptographic keys: a public key
and a private key.
2. Signing: To sign a message, the sender uses their private key to create a
digital signature. This signature is a mathematical transformation of the
message and the private key.
3. Verification: To verify the signature, the recipient uses the sender's public key
to decrypt the signature and compare it to the original message. If the two
match, the signature is considered valid, confirming the message's
authenticity and integrity.
Key Components of Digital Signatures
1. Public Key: A cryptographic key that can be shared publicly without
compromising security.
2. Private Key: A cryptographic key that must be kept secret.
3. Hash Function: A mathematical function that converts data into a fixed-size
string of characters (hash).
4. Digital Signature Algorithm: A cryptographic algorithm used to generate and
verify digital signatures.
Benefits of Digital Signatures
1. Authentication: Verifies the identity of the sender of a message or document.
2. Integrity: Ensures that the message or document has not been altered or
tampered with.
3. Non-Repudiation: Prevents the sender from denying their involvement in
creating or sending the message.
4. Legal Validity: Digital signatures are often considered legally binding in many
jurisdictions.
28
Common Use Cases of Digital Signatures
1. Email: Verifying the authenticity of emails.
2. Electronic Documents: Ensuring the integrity and authenticity of digital
documents, such as contracts, invoices, and medical records.
3. Cryptocurrency Transactions: Verifying the validity of transactions and
preventing double-spending.
4. Secure Communication: Protecting sensitive data transmitted over networks.
Popular Digital Signature Algorithms
1. RSA: One of the most widely used algorithms.
2. DSA (Digital Signature Algorithm): Used in various standards, including the
U.S. government's Digital Signature Standard (DSS).
3. ECDSA (Elliptic Curve Digital Signature Algorithm): More efficient than RSA,
often used in mobile devices and embedded systems.
29
Use of hash functions and digital signatures
Hash Functions are like magical machines that take any amount of data and
turn it into a unique, fixed-length code. This code is called a hash. Think of it like a
fingerprint for your data.
Why are hash functions important in blockchain?
1. Security: If even one tiny change is made to the data, the hash will completely
change. This makes it very hard for anyone to tamper with the blockchain
without being caught.
2. Efficiency: Comparing hashes is much faster than comparing the whole data.
This helps the blockchain process transactions quickly.
3. Digital Signatures are like a seal of approval that says, "I, [sender's name],
created this message." They're created using a special kind of math that
involves two keys: a public key and a private key.
How do digital signatures work in blockchain?
1. Signing: The sender uses their private key to "sign" the data (like a
transaction). This creates a digital signature.
2. Verification: Anyone can use the sender's public key to check if the signature
is valid. If it is, they know the sender is the one who created the message.
Together, hash functions and digital signatures make blockchain a very
secure system. Here's a simple example:
Imagine you're sending a message to a friend. You use a hash function to
create a fingerprint of the message. Then, you sign the fingerprint with your private
key. When your friend receives the message and the signature, they can use your
public key to verify the signature. If it matches the fingerprint of the message, they
know it came from you and hasn't been changed along the way.
30
Module 3
Creation of Coins
Creating coins in blockchain, specifically cryptocurrencies like Bitcoin, is a
process known as mining.
How Mining Works
1. Consensus Algorithm: Different blockchains use different consensus
algorithms, but the most common one is Proof of Work (PoW).
2. Puzzle Solving: Miners compete to solve a complex cryptographic puzzle. This
puzzle involves finding a number (nonce) that produces a hash that meets
specific criteria when combined with other data in the block.
3. Block Creation: The first miner to solve the puzzle adds a new block containing
verified transactions to the blockchain.
4. Reward: As a reward for their effort, the miner receives newly created coins.
Factors Affecting Coin Creation
1. Difficulty: The puzzle's difficulty adjusts over time to maintain a consistent
block creation rate. As more miners join the network, the difficulty increases.
2. Halving: In some blockchains, like Bitcoin, the reward for mining a block is
halved at regular intervals. This is known as a "halving event."
3. Total Coin Supply: The total number of coins that can be created is often
predetermined and limited. For example, Bitcoin has a maximum supply of 21
million coins.
Significance of Coin Creation
1. Incentive: The reward for mining coins incentivizes miners to contribute to the
security and maintenance of the blockchain network.
2. Inflation: The creation of new coins can lead to inflation, but the rate of
inflation is often controlled by the blockchain's design and consensus
algorithm.
3. Scarcity: The limited supply of coins can create scarcity and increase their
value.
31
Double Spending
Double Spending is a potential security threat in blockchain systems where a
malicious actor attempts to spend the same cryptocurrency unit twice. This would
violate the fundamental principle of blockchain that a unit can only be spent once.
How Double Spending Can Occur
1. Splitting the Transaction: A malicious actor could create two conflicting
transactions spending the same unit.
2. Race Condition: If both transactions are broadcast to the network
simultaneously, there's a risk that one might be included in a block before the
other.
3. Reversal: The malicious actor could attempt to reverse the first transaction by
creating a chain of blocks that exclude it.
Prevention Mechanisms
1. Consensus Algorithms: Proof-of-Work (PoW) and Proof-of-Stake (PoS) are
consensus algorithms that help prevent double-spending. They require a
significant amount of computational power or stake to create a new block,
making it difficult for attackers to outpace honest nodes.
2. Confirmation Time: Blockchains typically require a certain number of
confirmations before a transaction is considered final. This reduces the risk of
double spending as it becomes increasingly difficult to reverse a transaction
after it has been included in multiple blocks.
3. Replay Protection: Some blockchains use techniques like replay protection to
prevent transactions from being replayed on different chains.
4. Sidechains: Sidechains can be used to isolate transactions and reduce the
risk of double spending.
In summary, double spending is a potential threat to blockchain security, but it
is mitigated by various mechanisms that ensure the integrity and consistency of the
blockchain.
32
Script (FORTH)
Script (FORTH) is a stack-based programming language often used in
blockchain systems, particularly Bitcoin. It serves as a scripting language for
executing smart contracts and verifying transactions.
Key Features of Script (FORTH)
1. Stack-based: Operations are performed on a stack of data, making it a
relatively simple and efficient language.
2. Minimal Syntax: Script has a minimal syntax, which can be both a benefit and
a drawback, depending on the complexity of the desired functionality.
3. Interpreted: Script code is interpreted at runtime, allowing for flexibility and
dynamic execution.
4. Limited Functionality: While it's capable of executing basic logic and
calculations, Script is not as expressive as more general-purpose
programming languages.
Use Cases in Blockchain
1. Smart Contracts: Script can be used to define and execute simple smart
contracts, automating transactions and agreements based on predefined
conditions.
2. Transaction Verification: The script is used to verify the validity of transactions
on the blockchain, ensuring that they comply with the network's rules and
regulations.
3. Custom Scripts: Developers can create custom scripts to perform specific
tasks or extend the functionality of the blockchain.
Limitations of Script (FORTH)
1. Limited Expressiveness: Script's simplicity can be a limitation for complex
applications.
2. Performance Overhead: Interpretation can introduce performance overhead
compared to compiled languages.
3. Security Concerns: While Script is generally secure, there have been instances
of vulnerabilities exploited in poorly written scripts.
33
Alternatives to Script (FORTH)
1. Solidity: A more expressive and feature-rich language used in Ethereum and
other blockchain platforms.
2. Vyper: A simpler language designed for writing secure smart contracts.
3. WebAssembly (Wasm): A low-level language that can be used to execute
code on the blockchain, offering higher performance and flexibility.
34
Mining Process
Mining is a process used in many blockchains to verify transactions and add
new blocks to the chain. It's like a digital gold rush, where miners compete to solve
complex mathematical puzzles.
Here's a simplified breakdown of the mining process:
1. Transaction Collection: Miners collect a batch of recent transactions.
2. Creating a Block: These transactions are bundled into a block. The miner adds
a unique identifier, called a nonce, to the block.
3. Solving the Puzzle: The miner uses powerful computers to repeatedly hash the
block's data, including the nonce. The goal is to find a hash that meets specific
criteria, often involving a certain number of leading zeros.
4. Block Validation: Once a miner finds a valid hash, they broadcast the new
block to the network. Other miners verify the block's validity and add it to their
copy of the blockchain.
5. Reward: The miner who successfully adds a block to the blockchain is
rewarded with newly minted cryptocurrency.
Why is Mining Important?
● Security: The mining process ensures the security of the blockchain by
making it extremely difficult to manipulate the data.
● Decentralization: By distributing the mining process across many computers,
it prevents any single entity from controlling the network.
● Incentive: The reward system motivates miners to contribute their computing
power to the network.
Key Points to Remember:
● Proof of Work: The mining process is often based on a consensus mechanism
called Proof of Work (PoW).
● Hashing: Hash functions are used to create unique digital fingerprints of data,
including the block's contents and the nonce.
● Block Reward: The reward for mining a block can be in the form of
cryptocurrency or transaction fees.
● Energy Consumption: Mining can be energy-intensive, particularly with Proof
of Work, as it requires significant computational power.
35
Objectives of Consensus Mechanisms in Blockchain
Consensus mechanisms are the backbone of blockchain technology, ensuring
the security, integrity, and decentralization of the network. Their primary objectives
are:
1. Agreement
● Common Ledger State: Ensuring all nodes in the network agree on the current
state of the blockchain.
● Transaction Order: Ensuring that all nodes agree on the order in which
transactions are processed and added to the blockchain.
2. Security
● Preventing Double Spending: Ensuring that the same cryptocurrency cannot
be spent multiple times.
● Tamper Resistance: This makes it extremely difficult to alter or delete existing
transactions.
● Protection Against Attacks: Safeguarding the network from malicious actors
who may try to manipulate the blockchain.
3. Decentralisation
● Distributed Trust: Distributing trust among multiple nodes rather than relying
on a central authority.
● Resilience: Ensuring the network can continue to operate even if some nodes
fail.
● Censorship Resistance: Preventing any single entity from controlling or
manipulating the network.
4. Efficiency:
● Scalability: Enabling the network to handle a growing number of transactions
and users.
● Performance: Ensuring fast transaction processing times and low latency.
● Resource Optimization: Using computational resources efficiently.
36
Proof of Work (PoW)
Proof of Work (PoW) is a consensus mechanism used in many blockchains,
notably Bitcoin, to secure and validate transactions. It involves a competitive process
where miners compete to solve a complex mathematical puzzle.
How it works:
1. Transaction Collection: Miners collect a batch of recent transactions.
2. Block Creation: These transactions are bundled into a block. The miner adds a
unique identifier, called a nonce, to the block.
3. Solving the Puzzle: Miners use powerful computers to repeatedly hash the
block's data, including the nonce. The goal is to find a hash that meets specific
criteria, often involving a certain number of leading zeros.
4. Block Validation: Once a miner finds a valid hash, they broadcast the new
block to the network. Other miners verify the block's validity and add it to their
copy of the blockchain.
5. Reward: The miner who successfully adds a block to the blockchain is
rewarded with newly minted cryptocurrency.
Key Points:
● Security: The computational effort required to solve the puzzle makes it
difficult for malicious actors to manipulate the blockchain.
● Decentralization: PoW ensures that no single entity has control over the
network, preventing censorship and ensuring transparency.
● Incentive: The reward system motivates miners to contribute their computing
power to the network's security and maintenance.
Drawbacks of PoW:
● Energy Consumption: The computational power required for mining can be
energy-intensive.
● Scalability: As the network grows, the difficulty of solving the puzzle increases,
which can slow down transaction processing.
While PoW has been a cornerstone of blockchain technology, its energy
consumption has led to the development of alternative consensus mechanisms like
Proof of Stake (PoS).
37
Sybil Attack
A Sybil attack is a type of attack where a malicious actor creates multiple fake
identities to gain control over a system or network. In the context of blockchain, a
Sybil attacker could create numerous fake nodes to manipulate the network's
consensus mechanism, potentially leading to a compromised blockchain.
How Sybil Attacks Can Harm Blockchain Networks:
● Manipulating Voting: By creating multiple fake identities, an attacker can gain
control over voting processes, such as those used in decentralized
governance systems.
● Disrupting Consensus: Attackers can flood the network with false information
or spam transactions, disrupting the consensus mechanism and slowing
down the network.
● Launching DDoS Attacks: Sybil attackers can launch distributed
denial-of-service (DDoS) attacks by overwhelming the network with traffic
from multiple fake nodes.
Defence Mechanisms Against Sybil Attacks:
● Proof of Work (PoW): By requiring significant computational power to create
new blocks, PoW makes it difficult for attackers to create a large number of
fake nodes.
● Proof of Stake (PoS): In PoS, nodes are selected to validate transactions based
on their stake in the network. This makes it more difficult for attackers to create
a large number of fake nodes, as they would need to acquire a significant
amount of the cryptocurrency.
● Identity Verification: Some blockchains require users to verify their identity to
prevent Sybil attacks.
● Reputation Systems: By tracking the behaviour of nodes and rewarding good
behaviour, reputation systems can discourage Sybil attacks.
● Economic Penalties: Some blockchains impose economic penalties on nodes
that engage in malicious behaviour, such as double spending or spamming.
By understanding the risks posed by Sybil attacks and implementing appropriate
defence mechanisms, blockchain networks can maintain their security and integrity.
38
Proof of Elapsed Time (PoET)
Proof of Elapsed Time (PoET) is a consensus mechanism designed to be more
energy-efficient and fair than traditional mechanisms like Proof of Work (PoW). It's
commonly used in permissioned blockchains, where participants are known and
trusted.
How PoET Works:
1. Randomized Waiting Time: Each node in the network is assigned a random
waiting time.
2. Waiting Period: Nodes must wait for their assigned time before they can
propose a new block.
3. Block Creation: The node that finishes its waiting period first is allowed to
create the next block and add it to the blockchain.
Key Advantages of PoET:
● Energy Efficiency: PoET doesn't require significant computational power,
making it much more energy-efficient than PoW.
● Fairness: Each node has an equal chance of being selected to create the next
block, regardless of its computing power.
● Security: PoET can be combined with other security measures, such as
Byzantine Fault Tolerance, to ensure the security of the network.
Limitations of PoET:
● Centralization Risk: In permissioned blockchains, there's a risk of
centralization if a small group of nodes collude.
● Limited Scalability: PoET may not be suitable for highly scalable public
blockchains.
In conclusion, PoET is a valuable consensus mechanism for permissioned
blockchains, offering a balance between security, fairness, and energy efficiency. It's
particularly well-suited for enterprise use cases where trust and efficiency are
paramount.
39
Proof of Stake (PoS)
Proof of Stake (PoS) is a consensus mechanism used in blockchain technology to
validate transactions and create new blocks. Unlike Proof of Work (PoW), which relies
on computational power, PoS relies on the amount of cryptocurrency a participant
holds.
How PoS Works:
1. Staking: Participants, often called validators, stake a certain amount of
cryptocurrency as a deposit.
2. Selection: A validator is randomly selected to create the next block based on
the amount of cryptocurrency they have staked. The more cryptocurrency a
validator stakes, the higher their chances of being selected.
3. Block Creation: The selected validator creates a new block containing verified
transactions.
4. Validation: Other validators on the network verify the new block.
5. Reward: If the block is valid, the validator receives a reward in the form of
newly minted cryptocurrency.
Key Advantages of PoS:
● Energy Efficiency: PoS is significantly more energy-efficient than PoW, as it
doesn't require massive amounts of computational power.
● Scalability: PoS can potentially handle a larger number of transactions than
PoW.
● Security: The more cryptocurrency a validator stakes, the less likely they are to
act maliciously, as they risk losing their stake.
Disadvantages of PoS:
● Wealth Concentration: Wealthy individuals or organizations with large
amounts of cryptocurrency may have a disproportionate influence on the
network.
● Security Risks: If a large number of validators collude, they could potentially
manipulate the network.
In summary, Proof of Stake is a more energy-efficient and scalable consensus
mechanism than Proof of Work. It offers a promising alternative for future blockchain
networks, but it's important to address potential security and centralization risks.
40
Proof of Burn (PoB)
Proof of Burn (PoB) is a less common consensus mechanism in blockchain
technology that involves permanently destroying or "burning" a specific amount of
cryptocurrency to participate in the network and validate transactions.
How PoB Works:
1. Burning Cryptocurrency: To become a validator, a user must burn a certain
amount of cryptocurrency. This act permanently removes the burned coins
from circulation.
2. Staking Burnt Coins: The burned coins act as a stake in the network. The more
coins a user burns, the higher their chances of being selected to validate
blocks.
3. Block Validation: A validator is selected to create a new block based on the
amount of cryptocurrency they have burned.
4. Reward: The validator who creates a valid block is rewarded with newly
minted cryptocurrency.
Key Advantages of PoB:
● Energy Efficiency: PoB is generally more energy-efficient than PoW as it
doesn't require significant computational power.
● Security: The burning of cryptocurrency acts as a deterrent to malicious
behaviour, as validators risk losing their investment.
Disadvantages of PoB:
● Reduced Supply: The burning of coins reduces the overall supply of the
cryptocurrency, which can impact its value and liquidity.
● Centralization Risk: If a small group of individuals or entities control a
significant portion of the burned coins, they could potentially gain significant
influence over the network.
In conclusion, Proof of Burn is an interesting concept, but its limitations and
potential drawbacks have led to its limited adoption in the blockchain space. While it
offers some advantages in terms of energy efficiency and security, it's important to
consider the trade-offs associated with burning cryptocurrency.
41
Module 4
Smart Contracts
Smart contracts are self-executing contracts with the terms of the agreement
directly written into code. They operate on a blockchain network, automatically
executing predefined conditions and actions when specific criteria are met.
Key characteristics of smart contracts:
● Self-executing: Once deployed, smart contracts run autonomously without
the need for intermediaries.
● Transparent: The code of a smart contract is publicly visible, ensuring
transparency and accountability.
● Immutable: Once deployed, the code of a smart contract cannot be altered,
guaranteeing the integrity of the agreement.
● Secure: Smart contracts leverage the security of the underlying blockchain
network to protect against fraud and manipulation.
How Smart Contracts Work:
1. Code Development: Smart contracts are written in programming languages
like Solidity, Vyper, or others, depending on the blockchain platform.
2. Deployment: The code is deployed to the blockchain network, where it
becomes a part of the distributed ledger.
3. Execution: When specific conditions are met, the smart contract
automatically executes the predefined actions, such as transferring funds,
issuing tokens, or triggering other events.
Use Cases of Smart Contracts:
● Financial Applications:
○ Decentralized finance (DeFi): Facilitating peer-to-peer lending, trading,
and other financial services.
○ Insurance: Automating insurance claims and payouts.
● Supply Chain Management:
○ Tracking the origin and movement of goods.
○ Verifying product authenticity and quality.
42
● Real Estate:
○ Automating property transactions and title transfers.
○ Managing rental agreements and property leases.
● Healthcare:
○ Securely storing and sharing medical records.
○ Automating payments for healthcare services.
● Voting Systems:
○ Ensuring the security and transparency of voting processes.
Benefits of Smart Contracts:
● Efficiency: Automation reduces the need for intermediaries, streamlining
processes and saving time and costs.
● Transparency: The code of a smart contract is publicly visible, increasing trust
and accountability.
● Security: Blockchain technology provides a secure and immutable platform
for executing smart contracts.
● Reduced Fraud: Smart contracts minimize the risk of fraud and human error.
Challenges and Considerations:
● Complexity: Developing complex smart contracts requires specialized
knowledge and expertise.
● Security Risks: Vulnerabilities in smart contract code can lead to security
breaches and financial losses.
● Scalability: As the number of smart contracts and transactions increases,
scalability becomes a concern.
By understanding the fundamentals of smart contracts and their potential
applications, we can harness their power to revolutionize various industries and
create a more efficient, transparent, and secure digital future.
43
Distributed Consensus in Blockchain
Distributed consensus is a fundamental concept in blockchain technology
that enables a network of computers to agree on a single, shared state without
relying on a central authority. It ensures that all nodes in the network have a
consistent and accurate view of the blockchain.
How Distributed Consensus Works
1. Transaction Broadcasting: When a new transaction is created, it is broadcast
to all nodes in the network.
2. Validation: Each node independently verifies the transaction to ensure its
validity and authenticity.
3. Consensus Algorithm: A consensus algorithm is used to determine which
node will add the next block of transactions to the blockchain. This algorithm
ensures that the network reaches agreement on the order of transactions and
the state of the blockchain.
4. Block Creation: The selected node creates a new block containing the verified
transactions and adds it to the end of the blockchain.
5. Block Propagation: The new block is broadcast to all nodes in the network.
6. Verification and Acceptance: Other nodes verify the new block and, if it is
valid, add it to their copy of the blockchain.
Common Consensus Algorithms
1. Proof of Work (PoW): Nodes compete to solve complex mathematical puzzles
to validate transactions and create new blocks. This process is
energy-intensive but provides a high level of security.
2. Proof of Stake (PoS): Nodes are selected to validate transactions based on the
amount of cryptocurrency they hold. This is more energy-efficient than PoW
but can be more susceptible to attacks.
3. Practical Byzantine Fault Tolerance (PBFT): A deterministic consensus
algorithm that is well-suited for permissioned blockchains. It requires a
majority of honest nodes to reach consensus.
4. Delegated Proof of Stake (DPoS): A hybrid of PoS and a democratic voting
system. A subset of nodes, called delegates, are elected by token holders to
validate transactions.
44
Importance of Distributed Consensus:
● Security: Ensures the integrity and security of the blockchain.
● Decentralisation: Prevents single points of failure and censorship.
● Transparency: Makes the blockchain transparent and auditable.
● Trustlessness: Enables trustless interactions between participants.
By understanding the principles of distributed consensus, you can appreciate
the underlying mechanics of blockchain technology and its potential to revolutionize
various industries.
45
Paxos
Paxos is a family of consensus algorithms designed to ensure that a
distributed system can reach agreement on a value, even in the presence of failures
and network partitions. It's a complex algorithm with multiple phases, but the core
idea is to have a proposer propose a value, and then have a majority of nodes agree
on that value.
How Paxos Works?
While the specific implementation details can vary, the general concept
involves several phases:
1. Prepare Phase:
a. A proposer sends a "Prepare" request to a majority of nodes.
b. Nodes that receive the request promise to accept the next proposal
from that proposer.
2. Promise Phase:
a. Nodes that receive the "Prepare" request send a "Promise" message
back to the proposer.
3. Accept Phase:
a. The proposer sends an "Accept" request to a majority of nodes,
including the proposed value.
b. Nodes that receive the "Accept" request, if they haven't promised
another value, accept the proposed value.
Key Concepts in Paxos
● Proposer: A node that proposes a value.
● Acceptor: A node that votes on proposed values.
● Quorum: A majority of nodes.
● Value: The specific value that the nodes need to agree on.
46
Why is Paxos Important in Blockchain?
While not as widely used as Proof-of-Work (PoW) or Proof-of-Stake (PoS),
Paxos-inspired algorithms play a crucial role in various blockchain systems. Here's
why:
● Fault Tolerance: Paxos can tolerate node failures and network partitions,
ensuring the system's reliability.
● Consensus: It guarantees that all nodes in the network agree on the same
state, preventing inconsistencies.
● Efficiency: Paxos can be more efficient than some other consensus
algorithms, especially in certain scenarios.
● Flexibility: It can be adapted to different use cases and can be combined with
other consensus mechanisms.
In conclusion, Paxos is a powerful tool for achieving consensus in distributed
systems, including blockchain networks. While it might not be as well-known as PoW
or PoS, its underlying principles are essential for building reliable and secure
blockchain systems.
PAXOS in Blockchain Technology 🔥🔥
47
RAFT
Raft is a consensus algorithm designed to be simpler to understand and
implement than other algorithms like Paxos. It's a popular choice for many
distributed systems, including blockchain networks.
How Raft Works:
Raft is based on the concept of a leader election process and a log replication
mechanism.
1. Leader Election:
a. Nodes periodically hold leader elections.
b. Nodes vote for a leader, and the node with the majority of votes
becomes the leader.
2. Log Replication:
a. The leader is responsible for receiving and processing client requests.
b. It appends entries to its log and replicates them to follower nodes.
c. Followers replicate the leader's log and vote for the leader.
3. Safety and Liveness:
a. Raft ensures safety by preventing inconsistent states.
b. Liveness is ensured by the leader election process and the log
replication mechanism.
Key Concepts in Raft:
1. Leader: The node responsible for proposing and committing log entries.
2. Follower: A node that follows the leader and replicates its log.
3. Candidate: A node that is running for election to become the leader.
4. Log: A sequence of entries, each representing a state change.
5. Term: A period of time during which a leader is elected.
Raft's Advantages:
1. Simplicity: Raft is easier to understand and implement than other consensus
algorithms like Paxos.
2. Efficiency: It can achieve high throughput and low latency.
3. Fault Tolerance: Raft can tolerate node failures and network partitions.
48
Use Cases of Raft in Blockchain:
● Distributed Databases: Raft can be used to synchronize data across multiple
nodes in a distributed database.
● Blockchain Networks: Raft can be used as a consensus mechanism for
blockchain networks, ensuring the consistency and security of the blockchain.
● Distributed File Systems: Raft can be used to synchronize files across multiple
nodes in a distributed file system.
In conclusion, Raft is a robust and efficient consensus algorithm that is
well-suited for a wide range of distributed systems, including blockchain networks. Its
simplicity and reliability make it a popular choice for developers.
49
Byzantine Fault Tolerance (BFT)
Byzantine Fault Tolerance (BFT) is a class of algorithms designed to ensure the
correct operation of a distributed system even in the presence of faulty or malicious
nodes. These nodes, often referred to as "Byzantine" nodes, can behave
unpredictably, send conflicting information, or even try to disrupt the system.
How BFT Works:
BFT algorithms typically involve a group of nodes that communicate with each
other to reach consensus on a particular value or decision. The key idea is to ensure
that a majority of honest nodes can agree on a correct outcome, even if some nodes
are faulty or malicious.
Key Techniques Used in BFT:
● Voting: Nodes vote on proposed values, and the majority vote determines the
outcome.
● Quorum Slicing: Divides the nodes into smaller groups to reduce the impact
of faulty nodes.
● State Machine Replication: Replicates the state of the system across multiple
nodes to ensure consistency.
● Digital Signatures: Verifies the authenticity of messages and prevents
tampering.
BFT in Blockchain:
BFT algorithms are crucial in blockchain systems to ensure the security and reliability
of the network. By preventing malicious nodes from disrupting the consensus
mechanism, BFT helps maintain the integrity of the blockchain.
Common BFT Algorithms:
● Practical Byzantine Fault Tolerance (PBFT): A well-known BFT algorithm that
is often used in permissioned blockchains.
● Raft: A more recent algorithm that is simpler to implement and offers good
performance.
● Paxos: A complex but powerful algorithm that can tolerate a high number of
faulty nodes.
In conclusion, Byzantine Fault Tolerance is a critical component of distributed
systems, including blockchain networks. By employing various techniques, BFT
50
algorithms ensure the reliability and security of these systems, even in the face of
malicious actors.
51
Practical Byzantine Fault Toleranqnce (PBFT)
Practical Byzantine Fault Tolerance (PBFT) is a consensus algorithm designed
to ensure the correct operation of a distributed system, even in the presence of faulty
or malicious nodes. It's particularly well-suited for permissioned blockchains, where
the participants are known and trusted.
How PBFT Works:
1. Primary Node Selection: A primary node is elected to lead the consensus
process.
2. Request Processing: Clients send requests to the primary node.
3. Request Broadcasting: The primary node broadcasts the request to all other
nodes.
4. Vote Collection: Nodes process the request and vote on its validity.
5. Consensus: If a majority of nodes agree on the request, it is executed.
6. State Machine Replication: The state of the system is replicated across all
nodes, ensuring consistency.
Key Concepts in PBFT:
● Primary Node: The node responsible for processing client requests and
proposing new blocks.
● Backup Nodes: Nodes that can take over as the primary node in case of
failures.
● Quorum: A majority of nodes that must agree on a decision.
● View Changes: If the primary node fails or becomes malicious, a view change
protocol is initiated to elect a new primary node.
Advantages of PBFT:
● High Performance: PBFT can achieve high throughput and low latency.
● Fault Tolerance: It can tolerate up to one-third of the nodes being faulty.
● Deterministic Execution: The same input will always produce the same
output.
Disadvantages of PBFT:
● Scalability: PBFT may not be suitable for large-scale, public blockchains.
● Permissioned Networks: It is typically used in permissioned blockchains,
where the participants are known and trusted.
52
In conclusion, PBFT is a powerful consensus algorithm that ensures the
security and reliability of distributed systems. Its ability to tolerate failures and
malicious behaviour makes it a valuable tool for building robust and trustworthy
blockchain networks. However, its scalability limitations may make it less suitable for
public blockchains with a large number of participants.
Byzantine Fault Tolerant ( BFT ) 🔥
53
Module 5
History of Ethereum
Ethereum, a revolutionary blockchain platform, was conceived in 2013 by
Vitalik Buterin. Unlike Bitcoin, which primarily focuses on digital currency, Ethereum
aimed to create a platform for decentralized applications (dApps).
Key Milestones in Ethereum's History
1. Whitepaper Publication (2013): Vitalik Buterin published a whitepaper
outlining the vision for Ethereum, a platform that could execute smart
contracts.
2. Crowdfunding (2014): Ethereum raised significant funds through an initial coin
offering (ICO), selling Ether tokens to fund development.
3. Mainnet Launch (2015): The Ethereum mainnet was launched, making it
accessible to the public.
4. The DAO Hack (2016): A significant security breach, known as The DAO hack,
exploited a vulnerability in a smart contract, leading to a major loss of funds.
5. Ethereum Hard Fork (2016): To address the DAO hack, the Ethereum network
underwent a hard fork, resulting in the creation of two chains: Ethereum and
Ethereum Classic.
6. Ethereum 2.0 (2020+): A major upgrade to the Ethereum network, focused on
improving scalability, security, and energy efficiency.
Ethereum's Impact:
● Decentralized Finance (DeFi): Ethereum has become the foundation for a
thriving DeFi ecosystem, enabling decentralized lending, borrowing, and
trading.
● Non-Fungible Tokens (NFTs): Ethereum is the leading platform for creating
and trading NFTs, representing unique digital assets like art, collectables, and
virtual real estate.
● Smart Contract Revolution: Ethereum's smart contract capabilities have
opened up new possibilities for automating complex agreements and
processes.
● Global Community: Ethereum has fostered a large and active community of
developers, researchers, and enthusiasts.
54
Ethereum's innovative approach and its ability to power a wide range of
decentralized applications have solidified its position as a leading blockchain
platform. As it continues to evolve, Ethereum is poised to shape the future of
technology and finance.
55
Ethereum's Architecture
Ethereum's architecture is designed to facilitate the creation and execution of
smart contracts. It's a complex system with several key components:
1. Ethereum Virtual Machine (EVM):
● Turing-Complete: The EVM is a virtual machine capable of executing any
computation, making it a powerful platform for smart contracts.
● Gas: A mechanism to limit computational resources and prevent infinite loops.
● Bytecode: Smart contracts are compiled into bytecode, which the EVM can
understand and execute.
2. Blockchain:
● Distributed Ledger: A decentralized, immutable record of all transactions and
smart contract executions.
● Blocks: Transactions are grouped into blocks, which are added to the chain in
chronological order.
● Consensus Mechanism: Ethereum uses a consensus mechanism (currently
Proof-of-Stake) to validate and add new blocks to the chain.
3. Accounts:
● Externally Owned Accounts (EOAs): Controlled by private keys.
● Contract Accounts: Self-executing programs that hold Ether and other assets.
4. Transactions:
● Transfers: Sending Ether from one account to another.
● Contract Creation: Deploying new smart contracts.
● Contract Interaction: Calling functions within existing smart contracts.
5. Ethereum Network:
● Nodes: Computers that participate in the network and validate transactions.
● Peer-to-Peer Network: Nodes communicate directly with each other, ensuring
decentralization.
56
How it Works:
1. Transaction Creation: A user creates a transaction and signs it with their
private key.
2. Transaction Broadcasting: The transaction is broadcast to the network.
3. Transaction Validation: Nodes validate the transaction and its signature.
4. Block Creation: Valid transactions are included in a block by a miner or
validator.
5. Block Verification: The new block is verified by other nodes in the network.
6. Block Addition: If the block is valid, it is added to the blockchain.
Ethereum's Transition to Proof-of-Stake: Ethereum has transitioned from a
Proof-of-Work (PoW) consensus mechanism to a Proof-of-Stake (PoS) mechanism.
This shift aims to reduce energy consumption and improve scalability. In PoS,
validators stake their Ether to secure the network and earn rewards.
57