0% found this document useful (0 votes)
130 views27 pages

Fundamentals of Blockchain

Fundamentals of Blockchain

Uploaded by

Arun KTR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views27 pages

Fundamentals of Blockchain

Fundamentals of Blockchain

Uploaded by

Arun KTR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

SATHEA SREE.

S/AP-CSE/VISTAS

FUNDAMENTALS OF BLOCKCHAIN & USE CASES

UNIT I - BASICS OF BLOCK CHAIN

The Double-Spend Problem, Byzantine Generals’ Computing Problems, Public-Key


Cryptography, Hashing, Distributed Systems, Distributed Consensus. Technology Stack:
Blockchain, Protocol, Currency

UNIT II- BITCOIN BLOCKCHAIN AND ETHEREUM BLOCKCHAIN

Bitcoin Blockchain: Structure, Operations, Features, Consensus Model, Incentive Model.

Ethereum Blockchain: Smart Contracts, Ethereum Structure, Operations, Consensus Model,


Incentive Model.

UNIT III -TIERS OF BLOCKCHAIN TECHNOLOGY

Blockchain 1.0, Blockchain 2.0, Blockchain 3.0, Types of Blockchain: Public Blockchain,
Private Blockchain, Semi-Private Blockchain, Sidechains.

UNIT IV- TYPES OF CONSENSUS ALGORITHMS

Proof of Stake, Proof of Work, Delegated Proof of Stake, Proof Elapsed Time, Deposite-Based
Consensus, Proof of Importance, Federated Consensus or Federated Byzantine Consensus,
Practical Byzantine Fault Tolerance. Blockchain Use Case: Supply Chain Management

UNIT V- BLOCK CHAIN USE CASES

Industry applications of Blockchain-Blockchain in Government-Government use cases-


Preventing Cybercrime through block chain-Block Chain in defense, Financial Services Related
Use Cases, Revolutionization of Global Trade, Healthcare Related Services, Blockchain and
IOT, Block chain and AI

Text Books:

T1: Mastering Blockchain: Deeper insights into decentralization, cryptography, Bitcoin, and
popular Blockchain frameworks by Imran Bashir, Packt Publishing (2017).

T2: Mastering Bitcoin: Unlocking Digital Cryptocurrencies, by Andreas Antonopoulos O’Reilly,


First Edition, 2014

1
SATHEA SREE.S/AP-CSE/VISTAS

UNIT I - BASICS OF BLOCK CHAIN

The Double-Spend Problem, Byzantine Generals’ Computing Problems, Public-Key


Cryptography, Hashing, Distributed Systems, Distributed Consensus. Technology Stack:
Blockchain, Protocol, Currency

What is blockchain?

Blockchain is a shared, immutable ledger that facilitates the process of recording transactions
and tracking assets in a business network.

Why is blockchain important?

A block chain network can track orders, payments, accounts, production and much more. And
because members share a single view of the truth, you can see all details of a transaction end to
end, giving you greater confidence, and new efficiencies and opportunities.

Key elements of a blockchain

Distributed ledger technology


All network participants have access to the distributed ledger and its
immutable record of transactions. With this shared ledger,
transactions are recorded only once, eliminating the duplication of
effort that’s typical of traditional business networks.
Immutable records
No participant can change or tamper with a
transaction after it’s been recorded to the shared
ledger. If a transaction record includes an error, a new
transaction must be added to reverse the error, and
both transactions are then visible.
Smart contracts
To speed transactions, a set of rules that are called
a smart contract is stored on the blockchain and run
automatically. A smart contract defines conditions for
corporate bond transfers, include terms for travel
insurance to be paid and much more.

How blockchain works

2
SATHEA SREE.S/AP-CSE/VISTAS

As each transaction occurs, it is recorded as a “block” of data


Those transactions show the movement of an asset that can be
tangible (a product) or intangible (intellectual). The data block can
record the information of your choice: who, what, when, where, how
much. It can even record the condition, such as the temperature of a
food shipment.
Each block is connected to the ones before and after it
These blocks form a chain of data as an asset moves from place to
place or ownership changes hands. The blocks confirm the exact
time and sequence of transactions, and the blocks link securely
together to prevent any block from being altered or a block being
inserted between two existing blocks.
Transactions are blocked together in an irreversible chain: a
blockchain
Each additional block strengthens the verification of the previous
block and hence the entire blockchain. Rendering the blockchain
tamper-evident, delivering the key strength of immutability.
Removing the possibility of tampering by a malicious actor, and
builds a ledger of transactions you and other network members can
trust.

What is Double Spending in Blockchain?


 Blockchain is a sequential list of blocks.
 Each block contains data linked with a cryptographic hash.
 Widely employed for secure transactions across various industries.
 Acts as an immutable, distributed, and decentralized ledger.

The working of Blockchain is as follows. Suppose a user wants to make a transaction. A


block is created and sent to other users. Users validate the block and the transaction gets
executed. The block is added and the users get incentives.
Although Blockchain is secured, still it has some loopholes. Hackers or malicious users
take advantage of these loopholes to perform their activities.
Double spending means the expenditure of the same digital currency twice or more to
avail the multiple services. It is a technical flaw that allows users to duplicate money.
Since digital currencies are nothing but files, a malicious user can create multiple copies
of the same currency file and can use it in multiple places.
This issue can also occur if there is an alteration in the network or copies of the currency
are only used and not the original one.
There are also double spends that allow hackers to reverse transactions so that transaction
happens two times.
By doing this, the user loses money two times one for the fake block created by the
hacker and for the original block as well.

3
SATHEA SREE.S/AP-CSE/VISTAS

The hacker gets incentives as well for the fake blocks that have been mined and
confirmed.

How Does Double Spending Happen?

Double spending can never arise physically. It can happen in online transactions. This mostly
occurs when there is no authority to verify the transaction. It can also happen if the user’s wallet
is not secured. Suppose a user wants to avail of services from Merchant ‘A’ and Merchant ‘B’.

 The user first made a digital transaction with Merchant ‘A’.


 The copy of the cryptocurrency is stored on the user’s computer.
 So the user uses the same cryptocurrency to pay Merchant ‘B’
 Now both the merchants have the illusion that the money has been credited since the
transactions were not confirmed by the miners.
This is the case of double spending.

Example: Suppose a user has 1 BTC. He/She wants to avail of services from merchant A and
merchant B. The user creates multiple copies of the same BTC and stores it. The user first sends
the original BTC to Merchant A and gets the service. Simultaneously, the user sends the copied
version of 1 BTC to Merchant B. Since the second transaction was not confirmed by other
miners, the merchant accepts the bitcoin and sends the service. But the cryptocurrency that was
sent is invalid. This is the case of Double Spending.

4
SATHEA SREE.S/AP-CSE/VISTAS

Types Of Double Spending Attacks

There are different types of Double Spending attacks:

Finney Attack: Finney Attack is a type of Double spending Attack. In this, a merchant accepts
an unauthorized transaction. The original block is eclipsed by the hacker using an eclipse attack.
The transaction is performed on an unauthorized one. After that, the real block shows up and
again the transaction is done automatically for the real block. Thus the merchant loses money
two times.

Race attack: is an attack in which there is a ‘race’ between two transactions. The attacker sends
the same money using different machines to two different merchants. The merchants send their
goods but transactions get invalid.

51% Attack: This type of attack is prevalent in small blockchains. Hackers usually take over
51% of the mining power of blockchain and therefore can do anything of their own will.

How Bitcoin Handles Double Spending?

Bitcoin is one of the most popular blockchains. To combat Double spending it uses some
security measures. There are two types of examples of double spending in BTC.

Types of Double Spending in Bitcoin:

 Case 1: Creating duplicates of the same Bitcoin and sending them to multiple users.
 Case 2: Reversing a transaction after receiving the service.

To tackle these double-spending issues, some security measures are taken. They are:

Validation:

 Transactions undergo validation by a significant number of nodes in the network.

5
SATHEA SREE.S/AP-CSE/VISTAS

 A block is added to the pending transactions list only after sufficient validations.

Timestamp:

 Confirmed transactions are timestamped, making them irreversible.


 Once a transaction involving Bitcoin is verified, subsequent attempts to spend the same
Bitcoin are invalidated.

Block Confirmations:

 Merchants receive block confirmations to ensure transaction legitimacy.


 Bitcoin requires a minimum of 6 confirmations by miners to validate a block.

Network Redundancy:

 Each node in the Bitcoin network retains a copy of every transaction.


 Redundancy prevents network-wide failures from affecting transaction verification.

A detailed example of how bitcoin handles double-spending.

 A user wants to spend 2 BTC. He/She can create multiple copies of the same
cryptocurrency.
 The user can send the same cryptocurrency to two different addresses say ‘Bob’ and
‘Alice’.
 Both of these transactions are sent to the pool of unconfirmed transactions.
 The first transaction T1 would be approved via the confirmation mechanism.
 The confirmation mechanism states that a minimum of six confirmations by miners
should be done for block validation. The block is added to the network.
 However, the second transaction T2 didn’t get sufficient confirmation so it would be
recognized as invalid by the confirmation process. The block with the highest number of
confirmations is accepted and the other one is rejected. So transaction T1 is valid, and
Alice received the bitcoin.

6
SATHEA SREE.S/AP-CSE/VISTAS

Solutions to Prevent Double Spending

Double spending, a critical challenge in digital transactions, can be effectively mitigated through
centralized and decentralized approaches:

Centralized Approach:

o Utilizes a trusted third party to verify transactions and maintain user balances.
o Transactions are identified uniquely and verified by the third party before
approval.
o Limitations include dependency on a central authority and potential cross-border
transaction complexities.
o Failure of the centralized system can result in widespread access issues for users.

Decentralized Approach:

o Exemplified by cryptocurrencies like Bitcoin, where no central authority is


involved.
o Transactions are validated using robust cryptographic algorithms within a
decentralized network.
o Offers enhanced security and transparency compared to centralized systems.
o Each transaction follows predefined protocols, ensuring integrity and preventing
double spending.

Combatting Double Spending

Double spending, a critical concern in digital transactions, can be effectively mitigated through
proactive measures and robust security features:

7
SATHEA SREE.S/AP-CSE/VISTAS

User Responsibilities:

o Transaction Confirmations:
 Users should wait for a minimum of six confirmations before conducting
subsequent transactions.
 Increased confirmations by various network participants reduce the
likelihood of double spending attacks in blockchain systems.

o Hardware Security:
 Safeguarding hardware resources is essential to prevent unauthorized
access.
 Hardware theft can potentially enable attackers to manipulate transactions
or alter data.

o Phishing and Malware Prevention:


 Users should delete spam emails and avoid phishing attempts to mitigate
malware risks.
 Phishing attacks targeting login credentials are common and pose
significant security threats.

o Software Maintenance:
 Regularly update software and install antivirus programs to mitigate
vulnerabilities.
 Outdated software can harbor bugs that malicious actors exploit for
fraudulent activities.

Success in Double Spending Prevention:

Blockchain Security Features:

 Transaction Confirmation: Nodes in the blockchain network validate


transactions, requiring a minimum of six confirmations for approval.
 Immutable Blocks: Once created, blockchain blocks are immutable and
irreversible, ensuring transaction integrity.
 Distributed Ledger: The network’s decentralized ledger autonomously
records all transactions, with each node maintaining a copy to prevent
tampering.
 Authenticity Verification: Blockchain protocols utilize hashing to verify
the authenticity of each transaction, effectively preventing double
spending attempts.

Disadvantages of Blockchain Concerning Double Spending:


 Control of the blockchain
 Alteration of information
 No authority

8
SATHEA SREE.S/AP-CSE/VISTAS

Byzantine Generals’ Computing Problems:


The Byzantine General's Problem, conceptualized in 1982 by Leslie Lamport, Robert Shostak,
and Marshall Pease. Byzantine Generals Problem is an impossibility result which means that the
solution to this problem has not been found yet as well as helps us to understand the importance
of blockchain. It is basically a game theory problem that provides a description of the extent to
which decentralized parties experience difficulties in reaching consensus without any trusted
central parties.

The Byzantine army is divided into many battalions in this classic problem called the
Byzantine General’s problem, with each division led by a general.
The generals connect via messenger in order to agree to a joint plan of action in which all
battalions coordinate and attack from all sides in order to achieve success.
It is probable that traitors will try to sabotage their plan by intercepting or changing the
messages.
As a result, the purpose of this challenge is for all of the faithful commanders to reach an
agreement without the imposters tampering with their plans.

Money and Byzantine General’s Problem:

Money needs a consistent value for everyone to agree on its worth.


Precious metals were initially used due to their perceived universal value.
Verifying the purity of these metals was inefficient, hindering daily transactions.
Centralized money systems arose with trusted parties managing the money supply,
increasing efficiency.
However, these systems introduced risk of data manipulation by the central authority.
Centralized systems lack transparency, making them susceptible to the Byzantine
Generals Problem (difficulty agreeing on truth in unreliable communication).
Bitcoin uses blockchain technology to create a decentralized, verifiable, and trustless
money system.
This eliminates the need for a central authority and reduces the risk of manipulation.

Byzantine Generals Problem:

Requires all loyal generals to agree on a single course of action despite unreliable
communication. In Bitcoin, the agreed-upon truth is the blockchain.
Blockchain: A public, distributed ledger recording all Bitcoin transactions. All nodes
(users) need to agree on the order and occurrence of these transactions for the system to
function.
Decentralized Consensus: Since there's no central authority, Bitcoin relies on a consensus
mechanism (proof-of-work) to validate transactions.
Proof-of-Work (PoW): Miners compete to solve complex puzzles to add new transaction
blocks to the blockchain. This makes the system:

9
SATHEA SREE.S/AP-CSE/VISTAS

Counterfeit-resistant: Requires significant effort to create valid blocks, disincentivizing


fake transactions.
Provable: Difficult to alter past blocks due to the interconnected nature of the blockchain.
Nodes can independently verify block validity.
Trust-free: No need to trust other users. Each node can verify information themselves.

Byzantine Fault Tolerance (BFT):


Inspired by the Byzantine Generals Problem, BFT allows systems to tolerate faulty or
malicious nodes.
Byzantine Generals Problem: A thought experiment where generals need to agree on a
battle plan despite unreliable communication.
BFT for Trustworthy Blockchains: BFT is crucial for building secure blockchain
features and rules.
BFT and Consensus: When at least two-thirds of the network agrees (consensus), the
system functions even with Byzantine failures.
BFT in Consensus Protocols: Proof-of-work, proof-of-stake, and proof-of-authority all
exhibit some BFT properties.
BFT for Decentralization: BFT is essential for creating decentralized networks.
BFT and Network Structure: The consensus mechanism using BFT defines the network
structure (e.g., leader-based with validator nodes).
BFT and Consensus Messages: BFT relies on messages exchanged between relevant
nodes to maintain transaction order and global state consistency.
Future of BFT: As interest in decentralized systems grows, more innovative BFT systems
are expected to emerge.
BFT Beyond Blockchains: BFT applications extend beyond blockchains to critical
industries like nuclear power, space, and aviation.

Byzantine General’s Problem in a Distributed System

Distributed systems require honest nodes (computers) to agree on a value despite


malicious nodes.

This problem is called the Byzantine Generals Problem (BGP).

Byzantine Agreement: All honest nodes agree on a single initial value chosen by one
node.

10
SATHEA SREE.S/AP-CSE/VISTAS

Consensus: All honest nodes agree on a common value, but each node may have started
with a different value.

Imagine the Byzantine army's divisions as network nodes.

Commanders represent programs maintaining transaction ledgers.

These ledgers record events and transactions in the correct order.

All ledgers must be consistent across the network, meaning they reflect the same reality.

Byzantine General’s Problem Example:

A "Byzantine fault" can be a digital signal stuck between "0" and "1," causing
unpredictable outputs in circuits.

This is solvable with redundancy: even a faulty signal has minimal impact if there are
enough good ones (like a majority vote).

BGP highlights the difficulty of achieving agreement in unreliable environments.

Distributed systems address this by using protocols like Byzantine Fault Tolerance (BFT)
inspired by BGP.

BFT ensures consistent data and reliable operations despite potential Byzantine failures .
Public-Key Cryptography:

Introduction To Public-Key Cryptography:

Most of the time blockchain uses public-key cryptography, also known as asymmetric-key
cryptography. Public key cryptography uses both public key and private key in order to encrypt
and decrypt data. The public key can be distributed commonly but the private key cannot be
shared with anyone. It is commonly used for two users or two servers in a secure way.

11
SATHEA SREE.S/AP-CSE/VISTAS

Public Key: Public keys are designed to be public. They can be freely given to everyone or
posted on the internet. By using the public key, one can encrypt the plain text message into the
cipher text. It is also used to verify the sender authentication. In simple words, one can say that a
public key is used for closing the lock.
Private Key: The private key is totally opposite of the public key. The private key is always kept
secret and never shared. Using this key we decrypt cipher text messages into plain text. In simple
words, one can say that the private key is used for opening the lock.

Why Do We Need Public-Key Cryptography?

In symmetric-key cryptography, a single key is used to encrypt and decrypt the message. Here,
the possibility of data loss or unauthorized access to data is high. To overcome the unauthorized
access of data and data sent securely without any loss, we use public-key cryptography.

Public-key cryptography is more secure than symmetric-key cryptography because the public
key uses two keys to encrypt and decrypt the data
Public-key cryptography allows users to hide the data that they want to send. The sender
encrypts the data and the receiver decrypts the data. The encrypted message is not understood by
unauthorized users.

Working On Public-Key Cryptography

Suppose, the sender wants to send some important message to the receiver.

The sender first creates a message in the form of plain text which is in a readable format.
The sender knows the public key of the receiver but doesn’t know the private key of the
receiver because the receiver keeps secret his private key. With the help of the public key
of the receiver and the private key of the sender, the sender generates the encrypted
message i.e. called cipher text. Cipher text is in an unreadable format. In this step, plain
text converts into cipher text.
Now, cipher text reaches the receiver end. The receiver knows its own private key, and
with the help of the private key receiver converts the cipher text into readable format i.e.
plain text.

The below example shows the working of public-key cryptography.

Public Key Cryptography

12
SATHEA SREE.S/AP-CSE/VISTAS

Let us try to understand the working of public-key cryptography with an example. Suppose
Sachin is the sender who wants to send a message to Anurag. Here Anurag is the receiver.

Sachin uses Anurag’s public key to encrypt the message and Anurag uses his own private key to
decrypt the message.

First Sachin creates plain text. Sachin has access to Anurag’s private key and cipher text. Using
Anurag’s public key and his own public key,

Sachin will generate an encrypted message i.e. cipher text which is in an unreadable format.
After applying the encryption process plain text converts into cipher text.
Now, Anurag receives a cipher text. First Anurag will decrypt the cipher text message into a
readable format. For decrypting Anurag will use the private key. Now cipher text converts into
plain text and is readable by the receiver. Because Sachin keeps his private key, Anurag knows
that this message couldn’t have come from anyone else. This is also called a digital signature.

Benefits of Public-key Cryptography

Authentication: It ensures to the receiver that the data received has been sent by the only
verified sender.
Data integrity: It ensures that the information and program are changed only in a
specific and authorized manner.
Data confidentiality: It ensures that private message is not made available to an
unauthorized user. It is referred to as privacy or secrecy.
Non-repudiation: It is an assurance that the original creator of the data cannot deny the
transmission of the said data to a third party.
Key management: Public-key cryptography allows for secure key management, as the
private keys are never transmitted or shared. This eliminates the need for a secure
channel to transmit the private key, as is required in symmetric key cryptography.
Digital signatures: Public-key cryptography allows for the creation of digital signatures,
which provide non-repudiation and can be used to verify the authenticity and integrity of
data.
Key exchange: Public-key cryptography enables secure key exchange between two
parties, without the need for a pre-shared secret key. This allows for secure
communication even if the parties have never communicated before.
Secure communication: Public-key cryptography enables secure communication over an
insecure channel, such as the internet, by encrypting the data with the public key of the
recipient, which can only be decrypted by the recipient’s private key.
Versatility: Public-key cryptography can be used for a variety of purposes, such as
secure communication, digital signatures, and authentication, making it a versatile tool
for securing data and communications.

Limitation of Public-Key Cryptography

13
SATHEA SREE.S/AP-CSE/VISTAS

One can encrypt and decrypt the fixed size of messages or data. If there is an attempt to
encrypt or decrypt a large size of the message then the algorithm demands high
computational power.
The main disadvantage of this algorithm is that if the receiver losses its private key then
data/message will be lost forever.
If someone has access private key then all data will be in the wrong hand.
There are many secret-key which is faster than public-key cryptography.
Key distribution: The process of securely distributing public keys to all authorized
parties can be difficult and time-consuming, especially in large networks.
Performance: Public-key cryptography is generally slower than symmetric-key
cryptography due to its more complex algorithms, making it less suitable for applications
that require fast processing speeds.
Security assumptions: Public-key cryptography relies on mathematical assumptions
about the difficulty of certain problems, such as factoring large numbers, which may not
hold true in the future. As a result, public-key cryptography is vulnerable to future
advancements in computing power and algorithmic breakthroughs.
Susceptibility to man-in-the-middle attacks: Public-key cryptography is vulnerable to
man-in-the-middle attacks where an attacker intercepts and alters the public key before it
reaches the intended recipient. This can result in the attacker being able to decrypt the
message or impersonate the sender.
Complexity: Public-key cryptography can be more complex to understand and
implement than symmetric-key cryptography, requiring specialized knowledge and
expertise.
Blockchain – Private Key Cryptography
Private key encryption is an encryption method that allows users to send and receive
information securely over a network. As part of the blockchain, private key cryptography is
used to ensure the security of transactions and ownership of digital assets.
What is Private-Key Cryptography?
Private key cryptography also known as symmetric-key cryptography is an encryption method
in which a single key is used to encrypt and decrypt data. This key is kept secret between the
sender and receiver and is used to encrypt and decrypt messages. Private key encryption is
widely used to secure communications over the Internet because it ensures that only the
intended recipient can read the message.
 In private key cryptography, to encrypt a message, the sender uses a key to scramble the
plaintext into ciphertext. Cipher text can only be decrypted with the same key, known only
to the sender and receiver.
 Although private key encryption is useful for secure communications, it has some
limitations. One of the biggest limitations is key distribution. Since the same key is used
for encryption and decryption, both the sender and receiver must have the key. This can be
difficult to achieve, especially when communicating with multiple parties.
 To overcome this limitation, public key cryptography was developed. Public key
cryptography, also known as asymmetric key cryptography, uses two keys (public and
private) to encrypt and decrypt data. The public key is used for encryption and the private
key is used for decryption. It allows users to communicate securely without sharing keys.

14
SATHEA SREE.S/AP-CSE/VISTAS

Why Do We Need Private-Key Cryptography?


Private key cryptography is an important part of blockchain technology because it provides a
secure way to sign transactions and prove ownership of digital assets. Blockchain is a
decentralized system in which multiple parties participate in transactions and ownership of
digital assets can be transferred between them.
 Ensures security and integrity of transactions: To ensure the integrity and security of
these transactions, private key cryptography is used. Each blockchain participant has a
unique private key, which is used to sign transactions. When a private key is used to sign a
transaction, it generates a digital signature to verify the authenticity of the transaction. This
digital signature ensures that only the owner of a particular asset can transfer it, preventing
unauthorized access to the asset.
 Provides a secure way to prove ownership of digital assets: Without private key
encryption, there is no secure way to prove ownership of digital assets or verify the
authenticity of transactions. This could lead to fraudulent transactions and could
compromise the integrity of the blockchain system.
 Provides anonymity of transactions: In addition to ensuring transaction security and
ownership of digital assets, private key cryptography can also provide anonymity for
blockchain transactions. Since transactions are signed using private keys rather than
personally identifiable information, users can remain anonymous while participating in the
blockchain network.
In general, private key cryptography is essential in blockchain technology because it provides a
secure and decentralized way to transfer ownership of digital assets while maintaining system
integrity.
How Does Private Key Cryptography Work?
Private key cryptography, also known as symmetric-key cryptography, is an encryption method
that uses a single key to encrypt and decrypt data. The key is kept secret and shared between
the sender and receiver.

1. Key generation: First, a secret key is generated. The key is a long string of random
characters that are kept secret by the sender and receiver.

15
SATHEA SREE.S/AP-CSE/VISTAS

2. Encryption: To encrypt a message, the sender uses a key to scramble the plaintext into
ciphertext. The sender then sends the ciphertext to the receiver.
3. Decryption: To decrypt the ciphertext, the recipient uses the same key that was used to
encrypt the message. The receiver applies the reverse operation of the encryption algorithm
to the ciphertext to recover the original plaintext message.
Private key cryptography provides security because the key is kept secret between the sender
and receiver. Anyone intercepting the ciphertext cannot decrypt it without knowing the key.
This means that private key cryptography can be used to ensure message confidentiality.

Benefits of Private Key Cryptography


Private key cryptography is an important part of blockchain technology, and it has several
advantages that make it an invaluable tool for securing the network and enabling secure
transactions. Here are some key benefits of private key cryptography in the blockchain context:
1. Secure Transactions: Private key cryptography guarantees the authenticity and integrity
of transactions by providing a secure way to sign transactions and ownership of digital
assets. Proof that transactions signed with a private key are verified by the blockchain
network, preventing fraudulent transactions and ensuring that only the rightful owner can
transfer digital assets.
2. Hack Prevention: Private key encryption protects blockchain networks from hacking and
unauthorized access to digital assets. Each blockchain participant has a unique private key
that is used to sign transactions, making it difficult for hackers to gain access to the
network or steal digital assets.
3. Anonymity: Private key encryption provides anonymity to blockchain transactions by
allowing users to remain anonymous while participating in the blockchain network.
Transactions are signed using private keys rather than personally identifiable information
to ensure user privacy.
4. Scalability: Compared to other encryption methods, private key encryption is relatively
fast and suitable for expanding blockchain networks. Private key cryptography can be used
to secure and process large volumes of transactions, allowing blockchain networks to scale
and support growing numbers of users and transactions

Hashing:

A hash function maps the data of any arbitrary size to data of fixed size. Bitcoin uses
SHA-256 hash function that produces a hash (output) of size 256 bits (32 bytes).

16
SATHEA SREE.S/AP-CSE/VISTAS

Bob, while placing an order with Lisa, creates a message similar to the one shown above.
This message is hashed through a hash function that produces a 32 byte hash. The beauty of
this hash is for all practical purposes the hash (the 256-bit number) is considered unique for
the contents of the message. If the message is modified, the hash value will change. Not only
that given a hash value, it is impossible to reconstruct the original message.

After having seen the importance of hashing, let us move on another concept in Bitcoin that
is mining.

Distributed systems:

Distributed systems are a computing paradigm whereby two or more nodes work with each other
in a coordinated fashion in order to achieve a common outcome and it's modeled in such a way
that end users see it as a single logical platform.
A node can be defined as an individual player in a distributed system. All nodes are capable of
sending and receiving messages to and from each other. Nodes can be honest, faulty, or
malicious and have their own memory and processor. A node that can exhibit arbitrary behavior
is also known as a Byzantine node. This arbitrary behavior can be intentionally malicious, which
is detrimental to the operation of the network. Generally, any unexpected behavior of a node on
17
SATHEA SREE.S/AP-CSE/VISTAS

the network can be categorized as Byzantine. This term arbitrarily encompasses any behavior
that is unexpected or malicious:

Design of a distributed system; N4 is a Byzantine node, L2 is broken or a slow network link

The main challenge in distributed system design is coordination between nodes and fault
tolerance. Even if some of the nodes become faulty or network links break, the distributed
system should tolerate this and should continue to work flawlessly in order to achieve the desired
result. This has been an area of active research for many years and several algorithms and
mechanisms has been proposed to overcome these issues.

Distributed systems are so challenging to design that a theorem known as the CAP theorem has
been proved and states that a distributed system cannot have all much desired properties
simultaneously. In the next section, a basic introduction to the CAP theorem will be provided.

Nodes in Distributed Systems


Node: An individual player in a distributed system, able to send and receive messages.
Node Types:
 Honest: Reliable and behaves as expected.
 Faulty: May deviate from protocol unintentionally.
 Malicious (Byzantine): Intentionally disrupts the network.
 Byzantine behavior: Unexpected or malicious actions.
Challenges:
 Coordination between nodes.
 Fault tolerance: System should function despite faulty nodes or broken links.

CAP Theorem: Understanding Trade-offs in Distributed Systems

The CAP Theorem, also known as Brewer's Theorem, states that a distributed data system
can only guarantee two of the following three properties:

18
SATHEA SREE.S/AP-CSE/VISTAS

 Consistency: All nodes in the system have the same, latest data at any given time.
 Availability: Every request receives a response, even if the data is not yet consistent
(e.g., temporary error).
 Partition Tolerance: The system continues to operate even if the network is divided
(partitioned) due to failures.

Why can't we have all three?

 Maintaining perfect consistency across a distributed system requires complex


coordination, especially when dealing with network partitions. Guaranteeing immediate
availability during this coordination can be challenging.
 Conversely, ensuring high availability might involve sacrificing some consistency, as
updates might not be immediately reflected on all nodes.

CAP and Fault Tolerance:

 Replication is a common technique to achieve fault tolerance by storing data copies on


multiple nodes.
 Consistency is often achieved through consensus algorithms, ensuring all replicas
eventually agree on the latest data (state machine replication). Blockchain is an example
of this approach.

Fault Types:

 Crash faults: Nodes simply crash or become unavailable.


 Byzantine faults: Nodes exhibit arbitrary, malicious behavior, making them difficult to
detect and handle.

CAP and Blockchain (covered later):

 The lecture will explore how Blockchain achieves properties that might seem to violate
CAP.

Key Points:

 CAP is a fundamental theorem in distributed systems design.


 It helps us understand the trade-offs between consistency, availability, and partition
tolerance.
 Different systems prioritize different CAP properties based on their needs.

Byzantine Generals problem:


 Paul Baran (1962) introduced cryptographic signatures and the concept of decentralized
networks.

19
SATHEA SREE.S/AP-CSE/VISTAS

 Lamport et al. (1982) proposed the Byzantine Generals Problem (BGP) as a thought
experiment for coordinating an attack despite unreliable messengers.
 BGP is analogous to achieving consensus in distributed systems with potentially faulty nodes.
 Generals represent nodes, traitors represent Byzantine nodes, and messengers represent
communication channels.
 Practical Byzantine Fault Tolerance (PBFT) by Castro and Liskov (1999) and Bitcoin's Proof-
of-Work (PoW) (2009) offer solutions for achieving consensus.
 BGP helps understand challenges in unreliable environments and the need for consensus
mechanisms in distributed systems.

Consensus

Consensus is a process of agreement between distrusting nodes on a final state of data. In order
to achieve consensus different algorithms can be used. It is easy to reach an agreement between
two nodes (for example in client-server systems) but when multiple nodes are participating in a
distributed system and they need to agree on a single value it becomes very difficult to achieve
consensus. This concept of achieving consensus between multiple nodes is known as distributed
consensus.

Consensus mechanisms

A consensus mechanism is a set of steps that are taken by all, or most, nodes in order to agree on
a proposed state or value. For more than three decades this concept has been researched by
computer scientists in the industry and Academia. Consensus mechanisms have recently come
into the limelight and gained much popularity with the advent of bitcoin and blockchain.

There are various requirements which must be met in order to provide the desired results in a
consensus mechanism. The following are their requirements with brief descriptions:

Agreement: All honest nodes decide on the same value.


Termination: All honest nodes terminate execution of the consensus process and
eventually reach a decision.
Validity: The value agreed upon by all honest nodes must be the same as the initial value
proposed by at least one honest node.
Fault tolerant: The consensus algorithm should be able to run in the presence of faulty
or malicious nodes (Byzantine nodes).
Integrity: This is a requirement whereby no node makes the decision more than once.
The nodes make decisions only once in a single consensus cycle.

Types of consensus mechanism

20
SATHEA SREE.S/AP-CSE/VISTAS

There are various types of consensus mechanism; some common types are described as
follows:

Byzantine fault tolerance-based: With no compute intensive operations such as


partial hash inversion, this method relies on a simple scheme of nodes that are
publishing signed messages. Eventually, when a certain number of messages are
received, then an agreement is reached.
Leader-based consensus mechanisms: This type of mechanism requires nodes to
compete for the leader-election lottery and the node that wins it proposes a final
value.

Advantages of distributed systems:


 Scalability: There are two types of scaling: horizontal scaling and vertical scaling:
 Reliability: Reliability is the fault tolerance of the system which means that the system
will continue to provide its service as soon as one or more components
(software/hardware) of the system fail.
 Availability: is the total time a system remains in normal operation for a specific period
of time. A measure of availability is the percentage of time the system is up and running
continuously for a period of time (usually 1 year).
 Efficiency: The efficiency of a distributed system is high load and low latency. This
means that a system that can handle many concurrent requests with low latency is a high-
performance system.
 Manageability: it is the ability to easily expand and maintain the system. In other words,
it is the time to perform repair (repair) or maintain (maintain) when needed, the higher
the time, the lower the availability.

Distributed Consensus in Distributed System:


A procedure to reach a common agreement in a distributed or decentralized multi-agent platform.
It is important for the message passing system.

Example –

A number of processes in a network decide to elect a leader. Each process begins with a bid for
leadership. In traditional or conventional distributed systems, we apply consensus to ensure
reliability and fault tolerance. It means, in a decentralized environment when you have multiple
individual parties, and they can make their own decision, then it may happen that some node or
some parties are working maliciously or working as a faulty individual. So in those particular
cases, it is important to come to a decision or common point of view. So having a common point
of view in an environment where people can behave maliciously or people can crash the work in
a faulty way, is the main difficulty. So under this kind of distributed environment, our objective
is to ensure reliability which means to ensure correct operation in the presence of faulty
individuals.

Features :

21
SATHEA SREE.S/AP-CSE/VISTAS

 It ensures reliability and fault tolerance in distributed systems.


 In the presence of faulty individuals, it is Ensure correct operations.

There are some conditions that need to be followed in order to achieve distributed consensus.

Termination – Every non-faulty process must eventually decide.


Agreement – The final decision of every non-faulty process must be identical.
Validity – Every non-faulty process must begin and ends with the same value.
Integrity – Every correct individual decides at most one value, and the decided value must be
proposed by some individual.

The correctness of Distributed Consensus Protocol :

It can be described by the following two properties as follows.

Safety Property – It ensures that you will never converge to an incorrect value or correct
individuals in a network will never converge to an incorrect value.
Liveness Property – It states that every correct value must be accepted eventually which
means something good will eventually happen.
Termination Property – It guarantees that every correct process will eventually decide
on a value. This ensures that the protocol will eventually terminate.
Agreement Property – It guarantees that all correct processes will eventually agree on a
single value. This ensures that all correct nodes in the network will come to a consensus.
Fault Tolerance – Distributed consensus protocols must be able to handle failures and
errors, both in the network and in the participating nodes. This ensures that the system
remains correct and functional even in the presence of faults.
Byzantine Fault Tolerance – Some distributed consensus protocols, like PBFT, have the
additional property of Byzantine Fault Tolerance (BFT). This means they can tolerate up
to a certain number of malicious nodes in the network without compromising safety and
liveness properties.
Scalability – The protocol must be able to scale to handle large networks and increasing
numbers of nodes without sacrificing safety, liveness, or fault tolerance. This ensures that
the protocol can be used in real-world scenarios with a large number of participants.

Application of Distributed Consensus :

Leader election in a fault-tolerant environment for initiating some global action without
introducing a single point of failure.
Maintaining consistency in a distributed network. Suppose you have different nodes
monitoring the same environment. If one of the nodes crashes, a consensus protocol
ensures robustness against such faults.
Blockchain technology: Distributed consensus is a fundamental concept in blockchain
technology, which allows multiple nodes to agree on a shared database without relying on
a central authority.

22
SATHEA SREE.S/AP-CSE/VISTAS

Distributed databases: Distributed consensus protocols can be used to maintain


consistency across multiple replicas of a distributed database.
Load balancing: Consensus protocols can be used to dynamically distribute the workload
across multiple nodes in a distributed system to ensure that no node is overloaded.
Fault tolerance: Distributed consensus protocols can provide fault tolerance in distributed
systems by allowing nodes to recover from crashes or network partitions.
Agreement protocols: Consensus protocols can be used to achieve agreement among
multiple nodes in a distributed system on a particular course of action or decision.

The Blockchain Tech Stack

Introduction

The blockchain tech stack is a multi-layered architecture that enables the creation of
decentralized, trustless systems for securely storing and transferring digital assets without
intermediaries. Each layer of the stack has a specific role and is essential for the overall
functionality and security of the blockchain.

Protocols are a set of rules that allow data to be shared across the network. They are a set of
guidelines that facilitate the exchange of information in a simple, efficient, and secure way.
Different machines use different hardware and software but protocols help in communication
irrespective of the difference. The protocols play a very important role as they help to monitor
and secure a computer network.

Why Does Blockchain Need a Protocol?

A blockchain is a chain of blocks where each block is used to store information and each block is
associated with a unique address in terms of hash. It is a distributed, decentralized ledger that
stores data such as transactions and is shared publicly across all the nodes that are present in the
network. Ledger means the main record which holds the list of transaction records and
distributed means that each machine is connected to one another. So there is no involvement of
any central authority or middlemen which satisfies the property of decentralization.

But to maintain how data is transferred across the networks in a secured manner, a set of
protocols is required. Since blockchains are used for transactions, protocols play a very
important role in data sharing so as to maintain the security of the cryptocurrency networks.

What is Blockchain Protocols?

Blockchain protocols are a set of protocols used to govern the blockchain network. The rules
define the interface of the network, interaction between the computers, incentives, kind of data,
etc. The protocols aim to address the four principles:

Security: Protocols maintain the security of the whole crypto network. Since the network
involves the transfer of money so protocols define the structure of data and also secure data from
the malicious users.

23
SATHEA SREE.S/AP-CSE/VISTAS

Decentralization: Blockchain is a decentralized network. There is no involvement of any central


authority. So the protocols authorize the whole network.

Consistency: Whenever a transaction occurs, protocols update the whole database at each step
so that each user is well versed with the whole crypto network.

Scalability: Scalability means an increase in the number of transactions. Earlier scalability was
an issue in the blockchain. But nowadays most protocols handle the issue of an increasing
number of transactions in the network and the addition of nodes to the network.

How Does Blockchain Protocol Work?

 Suppose there is a transaction between two individuals A and B.


 Individual A makes a request to make a transaction. A block for ‘A’ is created. This
block once created cannot be altered. This is done by the blockchain protocol.
 After this, the block is sent to each and everyone in the network. This distribution of
blocks across the network is also done by protocols.
 The nodes verify the transaction.
 After the verification, a reward is sent to each node. The sending of incentives is also
managed by protocol. Upon successful transaction, the block is added to the list.
Protocols update the database. The updated database is distributed across the network by
the protocols so that each user has access to the summary of the whole network.
 After this the transaction is complete.
 So there is the involvement of protocols at each step for a secured transaction. Therefore
the whole crypto network is secured, scalable and consistent.

Main Types of Blockchain Protocols

24
SATHEA SREE.S/AP-CSE/VISTAS

1. Hyperledger: Hyperledger is an open-source framework that is developed by Linux. It helps


the enterprises to provide blockchain solutions, and how to create a secured blockchain protocol.
The main aim is to provide universal guidelines for Blockchain implementation.

2. Quorum: Quorum is another enterprise blockchain protocol that aims to address the problems
related to finance. It is open source project associated with Ethereum. It is open-source and
nowadays has become one of the best enterprise blockchain frameworks.

3. Corda: Corda is an enterprise protocol. It is handled by the R3 banking consortium. This


protocol is useful in the field of banking and financial organizations. It utilizes consensus
algorithms to maintain transparency and security. It is also an open-source framework. It allows
for the building of interoperable blockchain networks with strict privacy.

4. Enterprise Ethereum: Ethereum is one of the public blockchain suite protocols. It defines the
platform for decentralized applications. It is the blockchain of choice for developers and
enterprises, who are creating technology based upon it to change the way many industries
operate.

Layers of the Blockchain Tech Stack

25
SATHEA SREE.S/AP-CSE/VISTAS

1. Protocol Layer

 Description: The Protocol or Network layer is the foundational blockchain platform


responsible for maintaining communication between nodes.
 Functions: Establishes peer-to-peer (P2P) connections and handles the transmission of
data (transactions and blocks) between nodes.
 Examples:
o Bitcoin: The original blockchain protocol for cryptocurrency.
o Ethereum: A blockchain with smart contract functionality.
o Hyperledger Fabric: A permissioned blockchain for enterprise solutions.
o EOS: A blockchain platform for decentralized applications (dApps).

2. Consensus Layer

 Description: The consensus layer ensures that all nodes agree on the state of the
distributed ledger, maintaining security and consistency even with potential malicious
actors or network issues.
 Functions: Achieves agreement on the ledger's state across the network.
 Examples:
o Proof of Work (PoW): Used by Bitcoin.
o Proof of Stake (PoS): Used by Ethereum 2.0.
o Partial Byzantine Fault Tolerant (PBFT): Used by Hyperledger.
o Delegated Proof of Stake (DPoS): Used by EOS.

3. Data Storage Layer

 Description: This layer manages the storage of transactions and blocks in a blockchain,
utilizing specific data structures and distributed databases.
 Functions: Stores transactional data, potentially includes off-chain data, and ensures
secure data management.
 Examples:
o LevelDB and RocksDB: Databases used for blockchain data.
o IPFS and Filecoin: For off-chain data storage.
o AWS S3 or Google Cloud Storage: Traditional cloud storage options.
o Security Technologies: Secure key management systems (e.g., HSMs), multi-
signature wallets, and authentication mechanisms (e.g., OAuth, JWT).

4. Logic Layer

 Description: The Logic or Smart Contracts layer encodes business logic and rules,
facilitating the execution of smart contracts.
 Functions: Uses virtual machines (VMs) to execute smart contracts in an isolated
environment.
 Examples:
o Bitcoin Script: For Bitcoin smart contracts.

26
SATHEA SREE.S/AP-CSE/VISTAS

o Solidity: For Ethereum smart contracts.


o Hyperledger Chaincode: For Hyperledger smart contracts.
o Ethereum Virtual Machine (EVM): For executing Ethereum smart contracts.

5. Application Layer

 Description: The Application Programming Interface (API) layer provides interfaces and
dashboards for developers and users to interact with the blockchain.
 Functions: Facilitates the creation of applications that leverage blockchain functionality,
including accessing data, sending transactions, and managing accounts.
 Examples:
o Web3.js and Ether.js: For Ethereum interaction.
o REST API: For Hyperledger Fabric.
o JSON-RPC and RESTful APIs: General APIs.
o Frontend Technologies: Node.js, Python, Go, HTML, CSS, JavaScript, React,
Angular, and GraphQL.

Application Layer: dApps

 Description: Decentralized applications (dApps) built on the blockchain use its features
such as immutability, security, and decentralization.
 Functions: Utilize smart contracts to enable various functionalities across different use
cases.
 Use Cases:
o Finance: DeFi platforms, cryptocurrency exchanges.
o Supply Chain Management: Tracking and verifying goods.
o Digital Identity: Secure identity verification and management.

27

You might also like