Blockchain Technology Unit I II III Notes
Blockchain Technology Unit I II III Notes
Blockchain Technology
Unit I II III
notes
By,
Manoj Mishra
2
BLOCKCHAIN TECHNOLOGY
By Manoj Mishra
3
UNIT - I
Blockchain:
A blockchain is “a distributed database that maintains a continuously growing list of
ordered records, called blocks.” These blocks “are linked using cryptography. Each block
contains a cryptographic hash of the previous block, a timestamp, and transaction data. A
blockchain is a decentralized, distributed and public digital ledger that is used to record
transactions across many computers so that the record cannot be altered retroactively without the
alteration of all subsequent blocks and the consensus of the network.”
Blockchain is a list of records called blocks that store data publicly and in chronological order.
The information is encrypted using cryptography to ensure that the privacy of the user is not
compromised and data cannot be altered.
Blockchain
A blockchain is a database or a ledger that stores information in a data structure called blocks. It
is based on distributed ledger technology which can be used between parties that don't trust each
other with data. It is because when you add anything onto the blockchain, it requires verification
from all other users available on the network.
Blockchain keeps information permanently in uniformly sized blocks, where each block stores
the hashed information from the previous block to provide cryptographic security. The
blockchain hashing uses SHA256 hashing algorithm, which is a one-way hash function. The
hashed information is the data and a digital signature from the previous block. The hashes of
previous blocks that go back to the very first block produced in the blockchain are known as the
genesis block. A blockchain data structure is in the form of a Merkle Tree, which is used as an
efficient way to verify data.
key. Each individual or node has both of these keys and they are used to create a digital
signature.
This digital signature is a unique and secure digital identity reference and the most important
aspect of blockchain technology. Every transaction is authorized by the digital signature of the
owner.
All of these transactions are stored in a structure known as the digital ledger. In layman’s terms,
the digital ledger works like a spreadsheet containing all the numerous nodes in a network and
has the history of all purchases made by each node. The information contained in the digital
ledger is highly secure and the digital signature safeguards it from being tampered with. The
most interesting part about this ledger is that anyone can see the data, but no one is able to
corrupt it.
The following is a list of the most important features of blockchain technology that set it apart
from its competitors:
● Decentralized model
● Transparency
● Persistency
● Open-source
● Autonomy
● Anonymity
● Immutability
● Auditability
Decentralized model
This indicates that the blockchain utilizes a decentralized, public network that is independent of
any single central node.
By Manoj Mishra
5
In contrast to the traditional, centralized model, the blockchain-based model does not require the
participation of any third parties in order to function.
On a decentralized network, consensus mechanisms in the blockchain ensure that all of the data
is accurate and consistent with one another.
Transparency
The blockchain network can be trusted because the system is transparent to each node in it.
Persistency
Transactions can be verified quickly, and honest miners will reject any fraudulent transactions.
Once a transaction has been recorded in the blockchain, it is nearly impossible to remove or
reverse it.
Open-source
Anyone with public access to the internet can use blockchain systems. The open-source model of
blockchain technology allows anyone to record and check the data they want.
Autonomy
Every node that is part of a blockchain network has the capability to safely move or update
information due to the way blockchain technology is designed.
Anonymity
Within a blockchain system, the transfer of data as well as any transaction is completely
anonymous. You need only be familiar with the blockchain address of the person in question. It
resolves the trust problems that existed between the system's two nodes.
By generating a unique address for themselves, users of the blockchain are able to conduct
anonymous transactions with the distributed ledger. Bear in mind that as a result of the
blockchain's built-in constraints, it is impossible to guarantee the absolute highest level of
privacy protection.
Immutability
By Manoj Mishra
6
Any record that is saved on a blockchain will be kept there in perpetuity without any possibility
of deletion. On the blockchain, the data is encrypted in a way that makes it impossible for
anyone to change it.
Auditability
When it comes to keeping tabs on user balances, the Bitcoin blockchain makes use of a paradigm
known as UTXO, which stands for "Unspent Transaction Output."
In order to complete a transaction, you need to connect it to an earlier one that has not yet been
spent. As soon as the most recent data is verified in the blockchain, any transactions that were
referred but had not yet been spent will have their status changed to "spent."
The blockchain technology has many benefits, but it is not without its flaws. It suffers from a
number of deficiencies, which prevent it from being implemented as a standard application. The
following are some of the categories that can be used to describe its deficiencies:
By Manoj Mishra
7
● Scalability issue
● Inefficiency
Bitcoin was the first currency to utilize the blockchain technology. It makes use of the proof-of-
work consensus algorithm, which places the onus of carrying out the laborious work on the
miners themselves.
The high amount of energy required to solve these difficult mathematical problems makes them
less than ideal for the world.
Private keys
Users of a blockchain have access to private keys and serve as their own banks. If a user loses
their private key, the funds in their wallet will be removed, and it will not be possible for anyone
else to retrieve them.
This is a significant limitation, as it increases the likelihood that users will get things wrong. If
there is a centralized authority that can handle this issue, then the system can no longer be
considered decentralized.
High cost
The high cost of the system is contributed to in large part by the expenses that are associated
with hiring developers, paying the license fees for a paid blockchain solution, and performing
routine maintenance.
Slower process
Blockchain can become sluggish when there are an excessive number of users on the network.
Immutability
The blockchain technology has a number of significant drawbacks, including this one. The
capacity of a blockchain ledger to continue operating without being modified is an example of
immutability. This indicates that we are unable to make any changes to any of the records in any
way.
By Manoj Mishra
8
Immutability is advantageous when you want to ensure that the record will not be altered by
anyone; however, it comes with the drawback that the record will be irreversible and that it will
not allow for any changes to be made to it.
Scalability is an issue
A consensus mechanism is present in blockchain, just like it is in bitcoin. It is necessary for each
participant node to perform a verification of the transaction. Therefore, there is a cap placed on
the total number of transactions that a blockchain network can process.
Bitcoin was not designed to process transactions on a large scale when it first launched. At this
time, the maximum number of transactions that Bitcoin can handle in one second is seven.
Inefficiency
There are a lot of different technologies that are competing to replace blockchain, such as
bitcoin. If you start using Bitcoin, you will quickly discover that the system has a lot of
inefficiencies. Because it does not store data in an effective manner, it can result in storage issues
for multiple nodes that want to join the network. There must be a more effective approach to
dealing with this matter.
Therefore, nodes should replicate the data at regular intervals, or whenever it is updated. The
greater the number of transactions and nodes, the larger the blockchain will become. If it keeps
expanding at this rate, the entire network will become more sluggish.
Because of this, it is not suitable for use in commercial settings, where the network demands that
it be both quick and secure at the same time. It is necessary for each participant node to perform
a verification of the transaction. Therefore, there is a cap placed on the total number of
transactions that a blockchain network can process. Bitcoin was not designed to process
transactions on a large scale when it first launched. At this time, the maximum number of
transactions that Bitcoin can handle in one second is seven.
By Manoj Mishra
9
History of Blockchain
The blockchain technology was described in 1991 by the research scientist Stuart Haber and W.
Scott Stornetta. They wanted to introduce a computationally practical solution for time-stamping
digital documents so that they could not be backdated or tampered. They develop a system using
the concept of cryptographically secured chain of blocks to store the time-stamped documents.
By Manoj Mishra
10
In 1992, Merkle Trees were incorporated into the design, which makes blockchain
more efficient by allowing several documents to be collected into one block. Merkle Trees are
used to create a 'secured chain of blocks.' It stored a series of data records, and each data records
connected to the one before it. The newest record in this chain contains the history of the entire
chain. However, this technology went unused, and the patent lapsed in 2004.
In 2004, computer scientist and cryptographic activist Hal Finney introduced a system called
Reusable Proof Of Work(RPoW) as a prototype for digital cash. It was a significant early step in
the history of cryptocurrencies. The RPoW system worked by receiving a non-exchangeable or a
non-fungible Hashcash based proof of work token in return, created an RSA-signed token that
further could be transferred from person to person.
RPoW solved the double-spending problem by keeping the ownership of tokens registered on a
trusted server. This server was designed to allow users throughout the world to verify its
correctness and integrity in real-time.
By Manoj Mishra
11
The evolution of blockchains has been steady and promising. The words block and chain were
used separately in Satoshi Nakamoto's original paper but were eventually popularized as a single
word, the Blockchain, by 2016. In recent time, the file size of cryptocurrency blockchain
containing records of all transactions occurred on the network has grown from 20 GB to 100 GB.
Digital money is the digital representation of value. The public sector can issue digital money
called central bank digital currency—essentially a digital version of cash that can be stored and
transferred using an internet or mobile application. The private sector can also issue digital
money. Some forms can be redeemed for cash at a fixed face value. These are fully backed with
very safe and liquid assets and are usually referred to as e-money. Stablecoins can be a form of
e-money, but also come in other designs whose value is more volatile. Crypto assets, such as
Bitcoin, are issued in their own denominations and are especially volatile—too much to be
considered a form of digital money (they are usually considered an investment asset).
Distributed ledger technology (DLT) is a digital system for recording the transaction of assets in
which the transactions and their details are recorded in multiple places at the same time. Unlike
By Manoj Mishra
12
In a distributed ledger, each node processes and verifies every item, thereby generating a record
of each item and creating a consensus on its veracity. A distributed ledger can be used to record
static data, such as a registry, and dynamic data, such as financial transactions.
Distributed ledger technology (DLT) refers specifically to the technological infrastructure and
protocols that allow the simultaneous access, validation and updating of records that
characterizes distributed ledgers. It works on a computer network spread over multiple entities or
locations. DLT uses cryptography to securely store data, cryptographic signatures and keys to
allow access only to authorized users.The technology also creates an immutable database, which
means information, once stored, cannot be deleted and any updates are permanently recorded for
posterity.
By Manoj Mishra
13
The blockchain has Design Primitives such as Protocols, Security, Consensus, Permissions,
Privacy.
The following is a list of the five most commonly used blockchain protocols:
1. Hyper ledger: This open source project quickly and effectively creates a set of tools
based on blockchain technology.
2. Multichain: Private blockchains make use of multichain protocols to speed up
transactions. The firm profited from the use of these protocols. Additionally, an APT is
available to expedite blockchain implementation and development.
3. Enterprise Ethereum: Use cases for blockchain software development are increased by
using these protocols. In order to expand swiftly on a broad scale, this protocol utilizes
exchange values.
4. Corda: Corda, like multichain, provides protocol design for businesses. In the financial
and banking sectors, this protocol is employed.
5. Quorum: Due to its tremendous support from financial institutions, the Quorum protocol
is the most significant leading protocol in the financial sector. This protocol is employed
in the creation of a blockchain-based software project. The protocols described above are
extremely complicated, and they are typically utilized in conjunction with specialized
blockchain development services.
Security
The cryptographic technology employed by the blockchain ensures the integrity of transactions.
Decentralization and consensus are at the heart of the blockchain. There are blocks in the block
chain that contain transactions or bundles of transactions, and this data structure is called a block
chain. Each new block is linked to the previous ones in a cryptographic chain in such a way that
the data can't be altered.
By using a consensus mechanism, all transactions are checked for accuracy and integrity.
However, the blockchain technology differs in key critical security features compared to other
technologies.
By Manoj Mishra
14
Consensus
Blockchain technology provides a level of security and anonymity that cannot be matched by any
other technology on the market.
To make sure that all transactions are legitimate, there is no centralized authority that can check
them. Blockchain technology's protocols are to blame for this.
Permission
In order to participate in a network, the block chain requires permission. In a public blockchain,
open-source clients can connect to the network.
The ledger copy is provided once the network has completed the necessary synchronization.
Participants in the permissioned blockchain must be granted permission before they may join the
network.
Both peer-to-peer networking and the Internet are covered by this permissions
policy. Privacy
The network's participants benefit from the privacy provided by the blockchain. Confidentiality
and anonymity are also part of this concept of privacy.
By Manoj Mishra
15
The traditional architecture of the World Wide Web uses a client-server network. In this case, the
server keeps all the required information in one place so that it is easy to update, due to the
server
being a centralized database controlled by a number of administrators with permissions.
In the case of the distributed network of blockchain architecture, each participant within the
network maintains, approves, and updates new entries. The system is controlled not only by
separate individuals, but by everyone within the blockchain network. Each member ensures that
all records and procedures are in order, which results in data validity and security. Thus, parties
that do not necessarily trust each other are able to reach a common consensus.
To summarize things, the blockchain is a decentralized, distributed ledger (public or private) of
different kinds of transactions arranged into a P2P network. This network consists of many
computers, but in a way that the data cannot be altered without the consensus of the whole
network
(each separate computer).
Node - user or computer within the blockchain architecture (each has an independent
copy of the whole blockchain ledger)
Transaction - smallest building block of a blockchain system (records, information,
etc.) that serves as the purpose of blockchain
Block - a data structure used for keeping a set of transactions which is distributed to all
nodes in the network
Chain - a sequence of blocks in a specific order
Miners - specific nodes which perform the block verification process before adding
anything to the blockchain structure
Consensus (consensus protocol) - a set of rules and arrangements to carry out
blockchain operations
By Manoj Mishra
16
The benefit of using the Merkle Tree in blockchain is that instead of downloading every
transaction and every block, a “light client” can only download the chain of block headers.
Also, if someone needs to verify the existence of a specific transaction in a block, then he doesn’t
have to download the entire block. Downloading a set of a branch of this tree which contains this
transaction is enough. We check the hashes which are just going up the branch (relevant to my
transaction). If these hashes check out good, then we know that this particular transaction exist in
this block.
Mining process
”Mining is the mechanism that allows the blockchain to be created securely and in a
decentralized manner. It provides the basis for the cryptocurrency system and enables
Miners validate new transactions and record them on the global ledger ( blockchain ). On
By Manoj Mishra
17
algorithm. The solution found is called the Proof-Of-Work. This proof proves that a
miner did spend a lot of time and resources to solve the problem. When a block is
'solved', the transactions contained are considered confirmed, and the bitcoin concerned
By Manoj Mishra
18
By Manoj Mishra
19
Interestingly, hashes have found a wide range of applications in various use cases, with the most
prominent example referring to digital fingerprinting. Digital fingerprinting is just the same as an
actual fingerprint, and the hashing in digital fingerprints serves as the best instrument for
verifying the fingerprint.
The hash helps in offering confirmation regarding the production of output from the hashing
procedure. In addition, the hash also confirms that the output of the procedure has not been
subject to any unwanted tampering. The verification process generally involves calculations for
confirming matches between hashes and the originally published content. Any form of mismatch
could clearly showcase evidence of modification or tampering in the output hash.
It is also important to note that activities are added subsequently to the chain as they happen.
Most important of all, the new blocks always capture details associated with the previous block.
Any form of modification could change the hash of the chain, thereby helping in easier and
precise identification.
Hashing in cryptography and blockchain is primarily a one-way function that features a properly
crafted algorithm without any concerns for reversal of hashing process and exposure of original
input. Therefore, hashing can provide a substantial advantage over the two-way function in
encryption that enables encryption and decryption through the suitable keys or key-pairs.
Another profound application of hash functions is clearly evident in data structures where you
can find bloom filters or hash tables. In such cases, the objective of hashing focuses on faster
data lookup rather than security. On the other hand, hash functions also find applications in the
context of digital signatures where they are ideal for producing the same output for the same
input with a deterministic approach.
As a result, the use of hashing and digital signature in blockchain could help recipients in
recomputing the output of a hash function with the same hash function. The comparison of the
By Manoj Mishra
20
message digest with the transmitted digest could help in verifying that the message didn’t go
through unwanted modifications in transit.
Even if the message features minor differences in punctuation, content, or spacing, the message
digest in the output would have radical differences. In addition, it is difficult to find out the level
of difference between two different messages through comparison of the digest. As you must
have understood, the smallest difference in inputs could result in a completely unique digest
value.
So, it is quite clear that hashing has a formidable significance for cryptography in the blockchain.
However, the applications of hashing in blockchain have to follow certain important
requirements such as,
SHA-1 could take input of practically any length and then generate a 160-bit message alongside
processing messages in blocks of 512-bit size. If message length is not a multiple of 512-bit, then
the SHA algorithm could pad up the message with data so that it could reach the next closest
multiple of 512-bit.
SHA-2 is presently one of the favorite algorithms in the cryptography community, although with
certain setbacks like in the SHA-1 algorithm. After its introduction in 2001, SHA-2 has been
through substantial changes over the years with the arrival of four variants. The four different
variants include SHA-256, SHA-224, SHA-512, and SHA-384, with SHA-256 being a widely
adopted cryptographic algorithm.
SHA-256 can create a 256-bit message digest through the use of 512-bit block size, while SHA-
224 utilizes a truncated version of SHA-256 for creating a 224-bit message digest using the 512-
bit block size. SHA-512 could create a 512-bit message digest by using the 1024-bit block
By Manoj Mishra
21
size, and SHA-384 utilizes a truncated version of SHA-512. SHA-384 can generate a 384-bit
message digest by leveraging a 1024-bit block size.
The SHA-3 algorithms are the latest additions in secure hashing algorithms showing the
importance of hashing in blockchain. SHA-3 came into existence in 2015 and fall on the same
lines as MD5 algorithm standards. It has the capability to serve as a replacement for SHA-2
while also offering similar variants and hash lengths. The only difference of SHA-3 is that it
presents possibilities of better security.
However, they are capable of offering better security with the reduced possibility of identity theft
or impersonation. Digital signatures follow the specific precedents of asymmetric cryptography
by linking two different keys with mathematical links. The keys include a private key and a
public key. It is possible to deploy a digital signature system with the help of a secure hash
function. The importance of a digital signature in blockchain largely revolves around two
primary objectives such as,
1. Digital signatures ensure that the message received by a recipient has come from the
sender claiming to have sent the information. The property is known as non-repudiation.
2. Digital signatures also provide assurance to recipients about the fact that messages have
not been through any modifications in transit. As a result, infrastructures can find better
safeguards against malicious intermediaries or unintentional modifications.
A hash chain is similar to a blockchain, as they both utilize a cryptographic hash function for
creating a link between two nodes. However, a blockchain (as used by Bitcoin and related
systems) is generally intended to support distributed consensus around a public ledger (data), and
incorporates a set of rules for encapsulation of data and associated data permissions.
By Manoj Mishra
22
A consensus mechanism is a system that cryptocurrencies like bitcoin and ethereum use to
validate the authenticity of transactions and maintain the security of the underlying blockchain.
● Consensus mechanisms are the protocols, algorithms, or other computer systems that
allow cryptocurrencies to work. They are systems of agreement that determine the
validity of transactions and governance of the blockchain.
● There are different types of consensus mechanisms with various benefits and drawbacks.
● A consensus mechanism enables trust and security in a blockchain network.
Note
The consensus mechanism is extremely important to the blockchain network. It influences how
transactions are verified, how much energy is used, network fees, transaction speed, and other
details for the currency and network applications.
The computers that validate new transactions on most blockchains are called miners. In a proof-
of-work protocol, these miners compete against each other to validate the next block of
transactions. The winning miner earns a lucrative mining fee, paid for by those who send
transactions on the network.
The consensus mechanism ensures all miners agree on the next block of transactions and
distributes the information in each new block to all other miners. Anyone can download a copy
of the blockchain to their device as a node. Every copy of the ledger matches exactly. The
consensus mechanism ensures the continued agreement on which wallet owns which assets.
By Manoj Mishra
23
While proof-of-work powers the largest cryptocurrency —bitcoin— it’s not the only way to run
a cryptocurrency network. The most important of the types of consensus mechanisms used today
fall into a few main types:
● Proof-of-Work: With proof-of-work, miners compete against each other to validate the
next transaction block and earn a reward. This is a highly energy-intensive consensus
mechanism but brings a high degree of trust.
● Proof-of-Stake: Proof-of-stake (PoS) is a consensus mechanism wherein those with the
largest holding of the network’s currency validate new blocks. This enables faster and
lower-cost transactions. It rewards those with the biggest stake in the network for
continued participation.
● Proof-of-Authority: Proof-of-authority is not as common but has a unique form. It is used
mainly by private companies or organizations that use blocks created by vetted sources
who have special permissions to access the network. Assurances are based on reputation
and authority rather than public consensus as with other mechanisms.
● Delegated Proof-of-Stake: Delegated proof-of-stake is a variation of PoS in which users
who stake their coins can vote on the number of delegates to create new blocks.
● Proof-of-Capacity: Proof-of-capacity currencies rely on a computer’s available hard drive
storage space for a decentralized block verification and generation process.
● Proof-of-Activity: The proof-of-activity consensus mechanism is a hybrid of proof-of-
stake and proof-of-work in which the miner seeks to utilize the best of both systems.
● Proof-of-Elapsed Time: Proof-of-elapsed time uses a random timer that operates
independently at every node to randomly assign the block verification to a miner.
● Proof-of-Burn: With proof-of-burn, consensus is driven by miners periodically burning
coins, a process of permanently deleting or eliminating that specific coin from
circulation. This validates new transactions while preventing inflation.
Unit II
Requirements for the consensus protocols
● It requires a participant node to prove that the work done and submitted by them qualifies
them to receive the right to add new transactions to the blockchain. However, this whole
mining mechanism of bitcoin needs high energy consumption and a longer processing
time
By Manoj Mishra
24
● Formal requirements for a consensus protocol may include: Agreement: All correct
processes must agree on the same value. Weak validity: For each correct process, its
output must be the input of some correct process.
● All the transactions in the new block are then validated and the new block is then
added to the blockchain.
● The block will get added to the chain which has the longest block height(see
blockchain forks to understand how multiple chains can exist at a point in time).
● Miners(special computers on the network) perform computation work in solving a
complex mathematical problem to add the block to the network, hence named, Proof-
of-Work.
● With time, the mathematical problem becomes more complex.
There are mainly two features that have contributed to the wide popularity of this consensus
protocol and they are:
● It is hard to find a solution to a mathematical problem.
● It is easy to verify the correctness of that solution.
Mining:
By Manoj Mishra
25
The Proof of Work consensus algorithm involves solving a computationally challenging puzzle
in order to create new blocks in the Bitcoin blockchain. The process is known as ‘mining’, and
the nodes in the network that engages in mining are known as ‘miners’.
● The incentive for mining transactions lies in economic payoffs, where competing
miners are rewarded with 6.25 bitcoins and a small transaction fee.
● This reward will get reduced by half its current value with time.
● Energy and Time consumption in Mining: The process of verifying the transactions in
the block to be added, organizing these transactions in chronological order in the
block, and announcing the newly mined block to the entire network does not take
much energy and time.
● The energy-consuming part is solving the ‘hard mathematical problem’ to link the
new block to the last block in the valid blockchain.
● When a miner finally finds the right solution, the node broadcasts it to the whole
network at the same time, receiving a cryptocurrency prize (the reward) provided by
the PoW protocol.
Mining Reward
● Currently, mining a block in the bitcoin network gives the winning miner 6.25
bitcoins.
● The amount of bitcoins won halves every four years. So, the next deduction in the
amount of bitcoin is due at around 2024(with the current rate and growth).
● With more miners comes the inevitability of the time it takes to mine the new block
getting shorter.
● This means that the new blocks are found faster. In order to consistently find 1 block
every 10 minutes. (That is the amount of time that the bitcoin developers think is
necessary for a steady and diminishing flow of new coins until the maximum number
of 21 million is reached (expected some time with the current rate in around 2140)),
the Bitcoin network regularly changes the difficulty level of mining a new block.
By Manoj Mishra
26
Bitcoin uses the Hashcash Proof of Work system as the mining basis. The ‘hard mathematical
problem’ can be written in an abstract way like below :
Given data A, find a number x such as that the hash of x appended to A results is a
number less than B.
● The miners bundle up a group of transactions into a block and try to mine. To mine it,
a hard mathematical problem has to be solved.
● This problem is called the proof of work problem which has to be solved to show that
the miner has done some work in finding out the solution to the problem and hence
the mined block must be valid.
● The answer to the problem needs to be a lower number than the hash of the block for
it to be accepted, known as the ‘target hash’.A target hash is a number that the header
of a hashed block must be equal to or less than for a new block, along with the
reward, to be awarded to a miner. The lower a target is, the more difficult it is to
generate a block. miner continues testing different unique values (known as a
nonce(s)) until a suitable one is produced.
● The miner who manages to solve the problem gets the bitcoin reward and adds the
block to the blockchain by broadcasting that the block has been mined. note: The
target hash adjusts once every 2016 block or approximately once every 2 weeks. All
the miners immediately stop working on the said block and start mining the next
block. Common cryptographic protocols used in PoW: The most widely used proof-
of-work consensus is based on SHA-256 and was introduced as a part of Bitcoin.
Others include Scrypt, SHA-3, scrypt-jane, scrypt-n, etc.
The Proof-of-Work consensus mechanism has some issues which are as follows:
● The 51% risk: If a controlling entity owns 51% or more than 51% of nodes in the
network, the entity can corrupt the blockchain by gaining the majority of the network.
● Time-consuming: Miners have to check over many nonce values to find the right
solution to the puzzle that must be solved to mine the block, which is a time-
consuming process.
● Resource consumption: Miners consume high amounts of computing power in order
By Manoj Mishra
27
to find the solution to the hard mathematical puzzle. It leads to a waste of precious
resources(money, energy, space, hardware). It is expected that 0.3% of the world’s
electricity will be spent to verify transactions by the end of 2018.
● Not instantaneous transaction: Transaction confirmation takes about 10–60 minutes.
So, it is not an instantaneous transaction; because it takes some time to mine the
transaction and add it to the blockchain thus committing the transaction.
Scalability refers to a computer system’s ability to manage an increasing quantity of work (e.g., a
database or search engine). A blockchain network does not scale effectively or has low
scalability with a huge amount of data. Blockchain lacks sufficient efforts to alter the system to
cope with the increasing workload, data and resources (e.g., computing power, servers, or
bandwidth).
However, the term “scalability” has a far larger variety of implications in the context of
Blockchain. Surprisingly, the word “blockchain” has not been thoroughly defined academically.
For example, in one of the most influential papers on blockchain scalability, any enhancement to
Bitcoin in terms of throughput, latency, bootstrap time, or cost per transaction was referred to as
“scaling,” and the ensuing blockchain system was referred to as scalable.
Although their throughputs vary substantially, several blockchain systems can be deemed
“scalable”. It is important to note that the term “scalable” is a comparative phrase in the
Blockchain. When a blockchain system is said to be scalable, it achieves a greater TPS than other
current systems by tweaking its consensus method and adjusting specific system characteristics.
What is the problem of blockchain scalability?
The inability of public blockchains to scale is impeding the supply of optimal solutions to
enterprises and industries. A centrally regulated system underpins many internet transactions
between people or corporations (or controlled by a third-party organization). A bank or a credit
card provider, for example, may operate as a third-party company in the execution of a digital
payment or money transfer transaction between two entities (or individuals). The third-party
vendor charges every successful transaction a fee.
The third-party controls and manages practically all of the stakeholders’ information
participating in the online transaction in a consolidated way. This method necessitates the
involvement of a third party to ensure the transaction’s security. On the other hand, Blockchain
is an immutable distributed ledger of cryptographically signed transactions maintained by a peer-
to-peer network, where no third party is necessary to handle the information and trust among
network users is no longer a problem.
Scalability has been identified as the most significant barrier to establishing public blockchains
By Manoj Mishra
28
in many real-world commercial situations. The scalability issue with Blockchain emerges mostly
when the number of nodes and transactions increases.
Decisions are made by the owners of the network through a central, pre-defined level.
Security
Permissioned blockchains provide the operating organization granular control over permissions,
data access, and the scope of user roles.
Permissioned blockchains can either be fully centralized or partially decentralized. Its members
typically decide on the network’s level of decentralization and the mechanisms for consensus.
By Manoj Mishra
29
Lack of anonymity
Access to the identify of every transactional participant can be crucial information for private
entities concerned with accountability and a provable chain of custody. Every change is tracked
to a specific user, so network administrators can have instantaneous access to has made a change
to the system and when.
Permissioned blockchains cannot use the same type of consensus models that are seen in
permisionless blockchains. There are numerous variants of such consensus algorithms that are
available today for permissioned blockchains. The most popular ones that are being implemented
PBFT Consensus
Permissioned blockchains usually use pbft algorithms. One of the models that is used to facilitate
consensus in blockchain is the practical byzantine fault tolerance algorithm (PBFT). In this
model, each node exists in an internal state, which means that it will maintain an ongoing
specific information or status). Each time a node receives a message, they use the message with
computation will send messages to other nodes to ask if the transaction is valid. After receiving
verification from all of the other nodes, the first node will broadcast that decision with all the
other participants in the network. A consensus decision is achieved based on the total
By Manoj Mishra
30
PBFT can be very beneficial for low latency storage systems, This type of model is often used in
digital assets backed platforms that don’t need a great amount of capacity, but carry out a large
number of transactions. PBFT makes sure that the transaction records within the network are
accurate. A few examples of permissioned blockchains that use this model are Hyperledger and
Chain.
Federated Consensus
In Federated Consensus, each node in the blockchain network puts their trust in a set of signers
who help them reach the consensus stage. In order to carry out the process in an efficient
manner, the block signers use a single block generator, which receives, holds and filters all the
transactions. The generator’s signature is used to coordinate with the signers for the block
validation process. Each block signer will verify the block which is signed by the block generator
and which fulfills the certain conditions set by the network. Once the block generator receives
enough signatures from the network, the block will get published to the network.
This model guarantees security and transparency . It is ideal for use cases such as cross border
remittance, real time KYC etc. Common examples of blockchains that use this model are Stellar
and Ripple.
In Round Robin Consensus, validators take part in the consensus process by signing votes for
By Manoj Mishra
31
blocks. Usually, there are three main types of votes: a prevote, a precommit and a commit. To
receive more than two third of commits means to receive commits from a two third majority of
validators. A block is considered to be committed by the network when a two third majority of
At each height of the blockchain a round-based protocol is run to determine the next block. Each
round consists of three steps (Propose, Prevote, and Precommit), along with two special steps
Commit and NewHeight. The Propose, Prevote, and Precommit steps each take one third of the
total time allocated for that round. Each round is longer than the previous round followed by a
small fixed increase of time. This allows the network to eventually achieve consensus in a
Round robin consensus process doesn’t rely on a single participant for the block validation
process. In this model, several nodes play a major role in validating and signing transactions.
which makes this process more secure when compared to other consensus processes. There are
also lower chances of double spend attacks due to the voting power distribution among trusted
nodes. Round robin consensus mechanism is ideal for the trade, finance and supply chain
industries. Some well known permissioned blockchains that use the Round Robin consensus
By Manoj Mishra
32
A permissionless blockchain is open. Any individual can participate as a node and stay
anonymous. This makes it very easy for a node to tamper and modify transactions and include
them in a new block. This can lead to a fork in the blockchain, which occurs when two parties
are not in agreement with each other. A consensus algorithm can help us avoid such forks so that
everyone agrees to a single version of truth.
In permissioned blockchains, not everyone can join the blockchain. Each individual will need
special permission from the network administrator or the owner to join the network. This is
useful for companies, banks, and institutions that prefer to comply with the regulations and
would like to have complete control of their data. In a permissioned blockchain, all the
participating nodes are known and chosen. However, consensus is still required because we can’t
assume that every node is trustworthy.
A blockchain consensus protocol enables all the parties of the blockchain network to come to a
common agreement (consensus) on the present data state of the ledger. This promotes trust
among unknown peers in a distributed computing environment. If any individual wants to add
some information to the blockchain, it is crucial for the distributed peers of the blockchain to
analyze and agree on all the additions before they are permanently incorporated into the
blockchain.
By Manoj Mishra
33
There are a number of consensus models that are used to maintain transparency and fairness in a
blockchain. However, these models are different for permissioned and permissionless
blockchains. All consensus models are built on a foundation of certain objectives. These include:
● Coming to an agreement: Each model aims to collect as many agreements from the group
as possible
● Co-operation: Every member will work together as a team while putting their own
interests aside.
● Equal Rights: The vote of each group member will have the same value. This means that
● Activity: Each blockchain participant must remain equally active. No one in the network
If you are trying to decide on the right consensus protocol for your blockchain, there are some
● The speed in which your blocks will need to be written into the blockchain? Consensus
formation can take time. If consensus is faster, the trust guarantees will be much lower
eventually synchronous or asynchronous?. For example, the Internet does not guarantee
By Manoj Mishra
34
● How many miners, writers, or validators do you think you will need? These special
blockchain nodes are the ones which will select blocks to write to the chain.
● How “final” does a block need to be? Banks and other financial institutions most often
expect any transactions to be immediately final (that is, they cannot be rolled back).
others, blocks may eventually be final but are not immediately so.
● To what degree do you put your trust in the nodes/operators? Are you trying to protect
your blockchain from nodes that might crash, nodes that might actively attempt to hack
In a permissioned blockchain, choosing the right consensus protocol for permissioned blockchain
depends on factors like the extent of decentralization required (For example, how much the
participants in a network trust each other, the number of permissions that must be granted to all
Most of the time, these types permissioned blockchains usually use pbft algorithms (Practical
byzantine fault tolerance) and its variants including voting and lottery-based consensus as
opposed to consensus models like the Proof-of-Work consensus that are prevalent in the major
benefits like enhanced transparency, security and traceability to businesses in all industries.
However, blockchain networks cannot function properly without consensus algorithms to verify
each and every transaction that is being committed. This is why it is crucial to choose the right
By Manoj Mishra
35
Unit III
Consensus in Hyperledger Fabric is broken out into 3 phases: Endorsement, Ordering, and
Validation.
Endorsement is driven by policy (eg m out of n signatures) upon which participants endorse a
transaction.
Ordering phase accepts the endorsed transactions and agrees to the order to be committed to the
ledger.
Validation takes a block of ordered transactions and validates the correctness of the results,
including checking endorsement policy and double-spending.
Fabric components :
By Manoj Mishra
36
4, Peer Node
5, Channels
6, MSP - Member Service Provider
7, Chaincode ( Smartcontract)
8, State Database
9, Connection profile
10, Private data
1. Node/Fabric network structure
Configtxgen consumes a file named configtx.yaml. Configtx.yaml specifies the definitions of the
target network. The definitions contain organizations, peers, policies, ACLs, capabilities, and
other structure configurations.Configtxgen tool is used to generate the following necessary initial
configuration materials.
1) Genesis block, is the first block or block zero in any blockchain-based system, It is the
prototype of all other blocks in the blockchain network. Based on this which additional blocks
are added to form a chain of blocks, hence we call them blockchain. In theory, there is no real
need for a Genesis Block. However, it is necessary to have a starting point that everyone can
trust.
Without Genesis Block, it would be really difficult for the participant to trust a blockchain and to
know how and when it started.
Technically it means that the Genesis Block has its “previous hash” value set to 0. Which means
that no data was processed before the Genesis Block. All other blocks will have sequential
numbers starting by 1, and will have a “previous hash” set to the hash of the previous block.
It’s a configuration block that initializes the ordering service and the original network structure.
By Manoj Mishra
37
2) Channel configuration transaction This transaction will be broadcast to the ordering service
after network startup for the channel creation operations. It defines and determines channels for
this network.
3) Anchor peer transactions, these transactions will specify anchor peers for each organization
on this channel one by one. Anchor peers are used by gossip to make peers in different
organizations know about each other. There must be at least one anchor peer exist in one
channel, and it’s recommended that there should be a set of anchor peers in every organizations
for crash fault-tolerant and high performance.
3. Orderer: The ordering service implements the consensus protocol to order the transactions,
will sort the transactions submitted by members(clients) using consensus methods in the fabric.
Hyperledger recommends three consensus methods as Solo (dev), kafka, Raft and implements as
per the configuration. Orderer uses an Atomic broadcast protocol to receive data instructions.
Peers can be grouped by the organization and contributed to the network. Peer plays two major
roles in the network, Endorsement & Committing to the ledger. The peer can hold more than
one ledgers, which can be governed by one or more chaincodes.
5. Channels : Hyperledger Fabric channel is a private “subnet” of communication between two
or more specific network members, for the purpose of conducting private and confidential
transactions. A channel is defined by members (organizations), the shared ledger, chaincode
application and the ordering node.
By Manoj Mishra
38
The peer that joins a channel, has its own identity given by a membership services provider
(MSP), which authenticates each peer to its channel peers and services.
6. MSP [Membership Service Provider ]
Membership Service Provider (MSP) : Any of the components in Fabric has an identity &
according to the identity, the exact permissions and role of the component are decided. MSP is
the entity that defines rules, permissions and roles of different components in the Fabric network
and manages the identities of all participants in this blockchain network. The identities of
participants are implemented by Certificate Authority (CA) , Public Key Infrastructure (PKI).
MSP abstracts all cryptographic operations such as issuing and validating the certificates.
Developers can use MSP to define their required identities related with the organizations, peers,
ordering service and users or applications. All the nodes, users and clients use digital certificates
to verify each other and communicate with each other.
7. Chaincode : ( Smart-contract)
Enterprise specific chaincode is what most people call smart contracts.Chaincode is deployed
over channels.
Chaincode is packaged for deployment on the Hyperledger Fabric blockchain network.
Chaincode is one of the key components and there are 2 types of chaincode, a general chaincode
provided by a developer or user and a system chaincode hosted by Fabric framework to
communicate. As a blockchain system, a Chaincode defines a series of executable business logic
that are stored in the ledger. Fabric uses a general-purpose programming language called as
chaincode to fulfill the business logic and access the ledger data. It encapsulates both the asset
definitions and the business logic (or transactions) for modifying those assets.
The business logic inside the chaincode governs all the transactions.
8. State database
The peer state database are LevelDB and CouchDB and officially supported in Fabric. LevelDB
is embedded into the peer node and its default key-value state database embedded in the peer
process. LevelDB is the default state database in the official document of Fabric. CouchDB is
another optional state database that can support rich data query function when the chaincode data
is constructed as JSON format. Compared to LevelDB, the shortcoming is that the CouchDB has
lower efficiency on data processing.
A chaincode persists a set of data which called world state that contains all current state values of
objects. All world state data are organized as key-value pairs. Chain codes can use put, get and
By Manoj Mishra
39
delete operations to interact with world states. The latest values of all keys in chaincodes are
stored in a state database.
9. Connection Profile
A connection profile is primarily used by an application to configure a gateway that handles all
network interactions, allowing it to focus on business logic. A connection profile is normally
created by an administrator who understands the network topology. The connection profile
contains a description of a network view, expressed in a technical syntax, which can either be
JSON or YAML
The core of any blockchain platform is the ledger, a shared, tamper-proof history of the universe.
Specifically, it’s a record of all transactions within its scope. Chaincode is the term for programs
that run on top of the blockchain to implement the business logic of how applications interact
with the ledger. When a transaction is proposed, it triggers chaincode that decides what state
change should be applied to the ledger. For example, chaincode for the sale of bitcoin would
By Manoj Mishra
40
sometimes called smart contracts. However, chaincode can be used to implement functionality
beyond smart contracts. The only constraint is that all chaincodes are controlled by a Peer
according to the sameinterface — which is flexible enough that Hyperledger Fabric actually uses
With more than 120,000 contributing organizations and more than 15,000 engineer contributors
working together, Hyperledger Fabric offers a unique approach to consensus that enables
performance at scale while also preserving the data privacy enterprises demand.Hyperledger
Fabric is an open, proven, enterprise-grade, distributed ledger platform. It has advanced privacy
controls so only the data you want shared gets shared among the “permissioned” (known)
network participants.
Smart contracts document the business processes you want to automate with self-executing terms
between the parties written into lines of code. The code and the agreements contained therein
exist across the distributed, decentralized blockchain network. Transactions are trackable and
irreversible, creating trust between organizations. This enables businesses to make more
informed decisions quicker — saving time, reducing costs, and reducing risks.
Benefits of Hyperledger:
Permissioned network
Establish decentralized trust in a network of known participants rather than an open network of
anonymous participants.
Confidential transactions
Expose only the data you want to share to the parties you want to share it with.
Pluggable architecture
Tailor the blockchain to industry needs with a pluggable architecture rather than a one-size-
fits-all approach.
Easy to get started
By Manoj Mishra
41
Program smart contracts in the languages your team works in today, instead of learning custom
languages and architectures.
Fabric SDK:
The Hyperledger Fabric SDK allows applications to interact with a Fabric blockchain network. It
provides a simple API to submit transactions to a ledger or query the contents of a ledger with
minimal code.
The SDK is composed of several modules:
● fabric-network: Provides high level APIs for client applications to interact with
smart contracts (chaincode), and is the recommended API for building client
applications.
● fabric-ca-client: Provides APIs to interact with the optional Certificate Authority
component, fabric-ca, that contains services for membership management.
● fabric-common: A low-level API, used to implement fabric-network capability, that
provides APIs to interact with the core components of a Hyperledger Fabric network,
namely the peers, orderers and event streams.
fabric-network
This is the recommended API for client application to use for:
fabric-ca-client
Provides the following capabilities for interacting with the Certificate Authority to manage user
identities:
fabric-common
Provides the following capabilities and for use in the implementation of the fabric-network API:
● Submitting transactions.
● querying chaincode for the latest application state.
● monitoring events:
○ connect to a peer's event stream
○ listen on block events
By Manoj Mishra
42
By Manoj Mishra
43
• Reduced risk with well tested, efficient design that aligns understanding across business and
technical analysts and creates reusable assets based on best practices developed over 400+ client
engagements
• Greater flexibility as the higher-level abstractions make it far simpler to iterate, including the
capability to connect them to existing applications via APIs Hyperledger Composer includes the
following main components:
1) Business Network Archive: Capturing the core data in a business network, including the
business model, transaction logic and access controls, the Business Network Archive packages
these elements up and deploys them to a runtime.
2) Composer Playground: This Web- based tool allows developers to learn Hyperledger
Composer, model out their business network, test that network and deploy that network to a live
instance of a blockchain network. Composer playground offers a repository of sample business
networks that can provide a base for building your own business network. 3) REST API support
and integration capabilities: A LoopBack connector for business networks has been developed
that exposes a running network as a REST API which can easily be consumed by client
applications and integrate non-blockchain applications
By Manoj Mishra