Blockchain Module 1
Blockchain Module 1
514
3 0 0 3
OBJECTIVES :
· To impart knowledge to create the smart contacts and deploy the smart
contracts on a blockchain
MODULE I BLOCKCHAIN 07
MODULE V HYPERLEDGER 07
L TOTAL HOURS – 45
–
45;
REFERENCES :
2 Arvind Narayanan, Joseph Bonneau, Edward Felten, Andrew Miller, and Steven
. Goldfeder,”Bitcoin and Cryptocurrency Technologies: A Comprehensive
Introduction”, Princeton University Press, ISBN-13: 978-0691171692, ISBN-10:
0691171696, 2016.
4 Brojo Kishore Mishra, Sanjay Kumar Kuanar, “Handbook of IoT and Blockchain:
. Methods, Solutions, and Recent Advancements (Internet of Everything (IoE)) “,
CRC Press; 1st edition, ISBN : 9781000206371, 1000206378, 2020.
OUTCOMES :
· Create the smart contacts using solidity and deploy the smart contracts on a
blockchain
History of Blockchain
Let’s discuss the timeline of blockchain evolution:
1991: In 1991, researcher scientists named Stuart Haber and W. Scott Stornetta introduce
Blockchain Technology. These scientists wanted some Computational practical Solution for
time-stamping the digital documents so that they couldn’t be tempered or misdated. So both
scientists together developed a system with the help of Cryptography. In this System, the
time-stamped documents are stored in a Chain of Blocks.
1992: After that in 1992, Merkle Trees formed a legal corporation by using a system
developed by Stuart Haber and W. Scott Stornetta with some more features. Hence,
Blockchain Technology became efficient to store several documents to be collected into one
block. Merkle used a Secured Chain of Blocks that stores multiple data records in a
sequence. However, this technology became unused when the Patent came into existence
in 2004.
2000: In the year 2000, Stefan Konst published his theory of cryptographic secured chains,
plus ideas for implementation.
2004: In the year 2004, Cryptographic activist Hal Finney introduced a system for digital
cash known as “Reusable Proof of Work”. This step was the game-changer in the history of
Blockchain and Cryptography. This System helps others to solve the Double Spending
Problem by keeping the ownership of tokens registered on a trusted server.
2008: After that 2008, Satoshi Nakamoto conceptualized the concept of “Distributed
Blockchain” in his white paper: ”A Peer to Peer Electronic Cash System”. He modified the
model of Merkle Tree and created a system that is more secure and contains the secure
history of data exchange. His System follows a peer-to-peer network of time stamping. His
system became so useful that Blockchain become the backbone of Cryptography.
2009: After that, the evolution of Blockchain is steady and promising and became a need in
various fields. In 2009, Satoshi Nakamoto Releases Bitcoin White Paper. Blockchain
technology is so secure that the following surprising news will give proof of that. A person
named, James Howells was an IT worker in the United Kingdom, he starts mining bitcoins
which are part of Blockchain in 2009 and stopped this in 2013. He spends $17,000 on it and
after he stopped he sells the parts of his laptop on eBay and keep the drive with him so that
when he needs to work again on bitcoin he will utilize it but while cleaning his house in 2013,
he thrashed his drive with garbage and now his bitcoins cost nearly $127 million. This money
now remains unclaimed in the Bitcoin system.
2014: The year 2014 is marked as the turning point for blockchain technology. Blockchain
technology is separated from the currency and Blockchain 2.0 is born. Financial institutions
and other industries started shifting their focus from digital currency to the development of
blockchain technologies.
2015: In 2015, Ethereum Frontier Network was launched, thus enabling developers to write
smart contracts and dApps that could be deployed to a live network. In the same year, the
Linux Foundation launched the Hyperledger project.
2016: The word Blockchain is accepted as a single word instead of two different concepts as
they were in Nakamoto’s original paper. The same year, a bug in the Ethereum DAO code
was exploited resulting in a hard fork of the Ethereum Network. The Bitfinex bitcoin
exchange was hacked resulting in 120,000 bitcoin being stolen.
2017: In the year 2017, Japan recognized Bitcoin as a legal currency. Block.one company
introduced the EOS blockchain operating system which was designed to support commercial
decentralized applications.
2018: Bitcoin turned 10 in the year 2018. The bitcoin value continued to drop, reaching the
value of $3,800 at the end of the year. Online platforms like Google, Twitter, and Facebook
banned the advertising of cryptocurrencies.
2019: In the year 2019, Ethereum network transactions exceeded 1 million per day. Amazon
announced the general availability of the Amazon Managed Blockchain service on AWS.
2020: Stablecoins were in demand as they promised more stability than traditional
cryptocurrencies. The same year Ethereum launched Beacon Chain in preparation for
Ethereum 2.0.
2022 : Ethereum has shifted from Proof of Work(PoW) to Proof of Stake(PoS) consensus
mechanism. The original Ethereum mainnet merged with Beacon Chain which has Proof-of-
Stake. Now it is existing as one chain. Ethereum’s energy consumption has reduced by
~99.95%.
Timeline Blockchain Bitcoin Ethereum
Satoshi Nakamoto
conceptualized the concept of
2008 “Distributed Blockchain” in his NA NA
white paper: ”A Peer to Peer
Electronic Cash System”.
in the United
Kingdom, who
starts mining
bitcoin.
● Satoshi Nakamoto
Releases Bitcoin
White Paper
Ethereum
Blockchain Is
2014 Blockchain 2.0 is born. NA
Funded By
Crowdsale
Ethereum
Linux Foundation launched the
2015 NA Frontier Network
Hyperledger project.
was launched
Bitfinex bitcoin
Blockchain is accepted as a exchange was
2016 single word instead of two hacked resulting in NA
different concepts 120,000 bitcoin being
stolen.
Ethereum
network
2019 NA NA transactions
exceeded 1
million per day.
Ethereum
launched Beacon
2020 Stablecoins saw a rise. NA Chain in
preparation for
Ethereum 2.0.
Ethereum’s
consensus
mechanism is
now PoS.
Blockchain is a list of blocks. Each block comprises some information associated with some
hash. Blockchain is used nowadays widely for transactions. It is 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.
● The hacker gets incentives as well for the fake blocks that have been mined and
confirmed.
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’.
● 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.
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.
To tackle these double-spending issues, some security measures are taken. They are:
● 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.
Double Spending can be prevented using two approaches: Centralized and Decentralized
● Centralized Approach: In this case, a secured third party is employed to verify the
transactions. The third-party can track each of the user’s balances. Suppose a user
makes a transaction. The third-party identifies the transaction with a unique identity.
Then it verifies the transaction and allows the transaction. The problem is that suppose
we want to make transactions with other countries where a third party is not required. So
in such cases, decentralized systems come into play. another drawback is if the whole
system fails, the users cannot have access.
● Decentralized Approach: This approach is used by Bitcoin. In this, there is no
involvement of central authority. Each transaction is verified using powerful algorithms.
The decentralized approach proved to be more secure than the centralized approach.
Protocols are established and each protocol does its job at each step. Therefore this also
promotes transparency.
Double spending has been minimized to a large extent as companies are using many
security features. But we as users also have some responsibility so that such attacks don’t
happen.
● Any user should wait for a minimum of six confirmations of the transaction before
performing another transaction. In the blockchain, more the confirmations by different
users, lesser will be double spending attacks.
● Users should keep their hardware resources safe so that hackers do not misuse them for
their own purposes. Often hackers target the hardware part because the hardware is
costly. If they somehow steal the hardware, they can roll back any transaction or alter
information.
● Users should delete spam mails and avoid phishing to avoid unnecessary malware
attacks Phishing is a very common attack by hackers as hackers target login
credentials.
● Software should be updated regularly with the latest antivirus installed. If the software is
not up to date then the bugs present can cause major damage.
With the increasing dependency on the blockchain, double spending attacks have also
become a major problem. Many companies have adopted security features.
● Features like confirmation of the transaction by the nodes have been adopted. A
minimum of six confirmations is required to approve the transaction.
● The blocks once created are immutable. They are made irreversible so that no
transaction is reverted back.
● The network’s distributed ledger of transactions autonomously records each transaction.
Each node has a copy of all transactions that are being done in the network.
● Verification of each transaction’s authenticity is done by Blockchain protocols to prevent
double-spending. The concept of hashing is adopted. Here each block has a unique
hash.
● Control of the blockchain: The biggest disadvantage is if the hackers manage to take
control of 51% computation power, they can do any transaction of their own will and can
steal other users’ money. Therefore there is a threat to security as millions and millions
of money are involved in transactions.
● Alteration of information: Transaction information can also be altered by hackers. They
can mine blocks and hide the original blocks using attacks like Eclipse attack, Finney
Attack, etc.
● No authority: The third major problem is no central authority is present to verify the
transactions. But these problems will be eliminated if companies take proper security
measures and users are also aware of the measures.
1. Node –
It is of two types – Full Node and Partial Node.
● Full Node –
It maintains a full copy of all the transactions. It has the capacity to validate, accept and
reject the transactions.
● Partial Node –
It is also called a Lightweight Node because it doesn’t maintain the whole copy of the
blockchain ledger. It maintains only the hash value of the transaction. The whole
transaction is accessed using this hash value only. These nodes have low storage and
low computational power.
2. Ledger –
It is a digital database of information. Here, we have used the term ‘digital’ because the
currency exchanged between different nodes is digital i.e cryptocurrency. There are three
types of ledger. They are –
1. Public Ledger –
It is open and transparent to all. Anyone in the blockchain network can read or write
something.
2. Distributed Ledger –
In this ledger, all nodes have a local copy of the database. Here, a group of nodes
collectively execute the job i.e verify transactions, add blocks in the blockchain.
3. Decentralized Ledger –
In this ledger, no one node or group of nodes has a central control. Every node
participates in the execution of the job.
3. Wallet –
It is a digital wallet that allows user to store their cryptocurrency. Every node in the
blockchain network has a Wallet. Privacy of a wallet in a blockchain network is maintained
using public and private key pairs. In a wallet, there is no need for currency conversion as
the currency in the wallet is universally acceptable. Cryptocurrency wallets are mainly of two
types –
1. Hot Wallet –
These wallets are used for online day-to-day transactions connected to the internet.
Hackers can attack this wallet as it is connected to the internet. Hot wallets are further
classified into two types –
a. Online/ Web wallets –
These wallets run on the cloud platform. Examples – MyEther Wallet, MetaMask Wallet.
b. Software wallets –
It consists of desktop wallets and mobile wallets. Desktop wallets can be downloaded on
a desktop and the user has full control of the wallet. An example of a desktop wallet is
Electrum.
c. Mobile wallets –
They are designed to operate on smartphone devices. Example – mycelium.
2. Cold Wallet –
These wallets are not connected to the internet. It is very safe and hackers cannot attack
it. These wallets are purchased by the user. Example – Paper wallet, hardware wallet.
a. Paper wallet –
They are offline wallets in which a piece of paper is used that contains the crypto
address. The private key is printed in QR code format. QR code is scanned for
cryptocurrency transactions.
b. Hardware wallet –
It is a physical electronic device that uses a random number generator that is associated
with the wallet.
The focus of wallets is on these three things –
1. Privacy
2. Transactions should be secure
3. Easy to use
Privacy of a wallet is maintained using public and private key pairs. Transactions are made
secure as a private key is used both to send fund and to open the encrypted message.
4. Nonce –
A nonce is an abbreviation for “number only used once,” which is a number added to a
hashed or encrypted block in a blockchain. It is the 32-bit number generated randomly only
one time that assists to create a new block or validate a transaction. It is used to make the
transaction more secure.
It is hard to select the number which can be used as the nonce. It requires a vital amount of
trial-and-error. First, a miner guesses a nonce. Then, it appends the guessed nonce to the
hash of the current header. After that, it rehashes the value and compares this to the target
hash. Now it checks that whether the resulting hash value meets the requirements or not. If
all the conditions are met, it means that the miner has created an answer and is granted the
block.
5. Hash –
The data is mapped to a fixed size using hashing. It plays a very important role in
cryptography. In a blockchain network hash value of one transaction is the input of another
transaction. Properties of the hash function are as follows –
● Collision resistant
● Hiding
● Puzzle friendliness
Features of Blockchain
A blockchain is a chain of blocks that contains information. Most people think that Blockchain
is Bitcoin and vice-versa. But it’s not the case. In fact, Bitcoin is a digital currency or
cryptocurrency that works on Blockchain Technology. Blockchain was invented by Satoshi
Nakamoto. As the name suggests, Each block consists of a number of transactions, and
each transaction is recorded in the form of a Hash. Hash is a unique address assigned to
each block during its creation and any further modification in the block will lead to a change
in its hash.
Features of Blockchain
Let’s have a look at the primary features of the blockchain technology:
1. ImmutableL:Immutability means that the blockchain is a permanent and unalterable
network. Blockchain technology functions through a collection of nodes. Once a transaction
is recorded on the blockchain, it cannot be modified or deleted. This makes the blockchain
an immutable and tamper-proof ledger that provides a high degree of security and trust.
● Every node in the network has a copy of the digital ledger. To add a transaction every
node checks the validity of the transaction and if the majority of the nodes think that it is
a valid transaction then it is added to the network. This means that without the approval
of a majority of nodes no one can add any transaction blocks to the ledger.
● Any validated records are irreversible and cannot be changed. This means that any user
on the network won’t be able to edit, change or delete it.
2. Distributed
All network participants have a copy of the ledger for complete transparency. A public ledger
will provide complete information about all the participants on the network and transactions.
The distributed computational power across the computers ensures a better outcome.
Distributed ledger is one of the important features of blockchains due to many
reasons like:
● In distributed ledger tracking what’s happening in the ledger is easy as changes
propagate really fast in a distributed ledger.
● Every node on the blockchain network must maintain the ledger and participate in the
validation.
● Any change in the ledger will be updated in seconds or minutes and due to no
involvement of intermediaries in the blockchain, the validation for the change will be
done quickly.
● If a user wants to add a new block then other participating nodes have to verify the
transaction. For a new block to be added to the blockchain network it must be approved
by a majority of the nodes on the network.
● In a blockchain network, no node will get any sort of special treatment or favors from the
network. Everyone will have to follow the standard procedure to add a new block to the
network.
3. Decentralized
Blockchain technology is a decentralized system, which means that there is no central
authority controlling the network. Instead, the network is made up of a large number of
nodes that work together to verify and validate transactions. Each and every node in the
blockchain network will have the same copy of the ledger.
Decentralization property offers many advantages in the blockchain network:
● As a blockchain network does not depend on human calculations it is fully organized and
fault-tolerant.
● The blockchain network is less prone to failure due to the decentralized nature of the
network. Attacking the system is more expensive for the hackers hence it is less likely to
fail.
● There is no third-party involved hence no added risk in the system.
● The decentralized nature of blockchain facilitates creating a transparent profile for every
participant on the network. Thus, every change is traceable, and more concreate.
● Users now have control over their properties and they don’t have to rely on third-party to
maintain and manage their assets.
4. Secure
All the records in the blockchain are individually encrypted. Using encryption adds another
layer of security to the entire process on the blockchain network. Since there is no central
authority, it does not mean that one can simply add, update or delete data on the network.
Every information on the blockchain is hashed cryptographically which means that every
piece of data has a unique identity on the network. All the blocks contain a unique hash of
their own and the hash of the previous block. Due to this property, the blocks are
cryptographically linked with each other. Any attempt to modify the data means to change all
the hash IDs which is quite impossible.
5. Consensus
Every blockchain has a consensus to help the network to make quick and unbiased
decisions. Consensus is a decision-making algorithm for the group of nodes active on the
network to reach an agreement quickly and faster and for the smooth functioning of the
system. Nodes might not trust each other but they can trust the algorithm that runs at the
core of the network to make decisions. There are many consensus algorithms available each
with its pros and cons. Every blockchain must have a consensus algorithm otherwise it will
lose its value.
6. Unanimous
All the network participants agree to the validity of the records before they can be added to
the network. When a node wants to add a block to the network then it must get majority
voting otherwise the block cannot be added to the network. A node cannot simply add,
update, or delete information from the network. Every record is updated simultaneously and
the updations propagate quickly in the network. So it is not possible to make any change
without consent from the majority of nodes in the network.
7. Faster Settlement
Traditional banking systems are prone to many reasons for fallout like taking days to process
a transaction after finalizing all settlements, which can be corrupted easily. On the other
hand, blockchain offers a faster settlement compared to traditional banking systems. This
blockchain feature helps make life easier.
Blockchain technology is increasing and improving day by day and has a really bright future
in the upcoming years. The transparency, trust, and temper proof characteristics have led to
many applications of it like bitcoin, Ethereum, etc. It is a pillar in making the business and
governmental procedures more secure, efficient, and effective.
Smart Contracts – Blockchain technology enables the creation and execution of smart
contracts, which are self-executing contracts that automatically execute when certain
conditions are met. Smart contracts have the potential to revolutionize various industries by
providing a secure and transparent way to execute contracts.
Transparency – The blockchain ledger is public and transparent, which means that anyone
can access and view the transactions on the network. This makes it a highly transparent
system that is resistant to fraud and corruption.
Applications of Blockchain – Blockchain technology has a wide range of applications
across various industries. Some of the most well-known applications include cryptocurrency,
supply chain management, identity verification, and voting systems. However, blockchain
technology has the potential to revolutionize many other industries as well, such as
healthcare, real estate, and finance.
Conclusion: In conclusion, blockchain technology is a revolutionary technology that has the
potential to transform various industries. Its decentralized, secure, transparent, and
immutable nature make it a highly desirable platform for various applications. As the
technology continues to evolve and mature, we can expect to see more innovative use
cases for blockchain technology in the future.
Types of Blockchain
1. Public Blockchain
· It is a permissionless distributed ledger on which anybody can join and
conduct transactions.
· It is a non-restrictive form of the ledger in which each peer has a copy. This
also means that anyone with an internet connection can access the public
Blockchain.
· This user has access to historical and contemporary records and the ability
to perform mining operations.
· Trustable: Public Blockchain nodes do not need to know or trust each other
because the proof-of-work procedure ensures no fraudulent transactions.
· Scalability Issues: Its transactions are processed and completed slowly. This
harms scalability. Because the more we try to expand the network's size, the
slower it will become.
2. Private Blockchain
· Scalability: You can tailor the size of your private Blockchain to meet your
specific requirements. This makes private blockchains particularly scalable
since they allow companies to easily raise or decrease their network size.
3. Hybrid Blockchain
· Organizations who expect the best of both worlds use a hybrid blockchain,
which combines the features of both private and public blockchains.
· Real Estate: Real-estate companies can use hybrid networks to run their
systems and offer information to the public.
· Retail: The hybrid network can also help retailers streamline their processes.
4. Consortium Blockchain
· In the same way that a hybrid blockchain has both private and public
blockchain features, a Consortium blockchain, also known as a federated
blockchain, does.