0% found this document useful (0 votes)
29 views73 pages

Unit 1

blockchain notes for Decentralization

Uploaded by

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

Unit 1

blockchain notes for Decentralization

Uploaded by

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

PCET-NMVPM’s

Nutan College of Engineering and Research, Talegaon, Pune


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BLOCKCHAIN TECHNOLOGY-UNIT-01

Overview of Blockchain

What is a Blockchain?

A decentralized computation and information sharing platform enables multiple


authoritative domains, who do not trust each other, cooperate, coordinate, and
collaborate in a rational decision-making process.

Important keywords

● Decentralized
● Computation and Information sharing platform
● Multiple Authoritative Domains
● Cooperate, Coordinate and Collaborate
● Rational Decision-making Process

The important aspect of Blockchain is that we can combine multiple authoritative
domains that do not trust each other. They can come to a common platform to cooperate,
coordinate and collaborate in the application development process at the business intelligence
process.

Format definition of Blockchain

A blockchain is an open, distributed ledger that can record transactions between two parties
efficiently and in a verifiable and permanent way.

An explanation of individual keywords:

● Open (accessible to all)


● Distributed or Decentralized (no single party control)
● Efficient (fast and scalable)
● Verifiable (everyone can check the validity of information)
● Permanent (the information is persistent)

A detailed explanation of individual keywords:

● Open: Whatever information we are putting inside the Blockchain should be


accessible to all. So, everyone will be able to observe and validate that particular
information.
● Distributed ledger: Keeping a copy of the public ledger to every individual
party in the platform and communicating with each other.
● Efficiently: We need to ensure the efficiency of the information and the
protocol’s efficiency, so the protocol needs to be fast and scalable. It should
scale up with the number of client requests and the number of participants in the
network.
● Verifiable: Everyone in the network should be able to check the validity of the
information.
● Permanent: The information that we are entering inside the Blockchain is
persistent or sometimes calls it tamper-proof. Once we have inserted
information inside a Blockchain, we will not change that information or update
it in the future time. If we want to update that transaction, we have to insert a
new transaction saying that the old transaction is invalid and this is the new
transaction. But whatever has been already committed that committed
transactions will never be able to roll back, or someone will not be able to
change that particular transaction.

Use Case (1): Information sharing among multiple parties

First scheme without using Blockchain Technology:

● Alice wants to share some documents with Bob.


● Alice will write down her content inside her document and share it with Bob.
● Later, Bob updates it and shares it again with Alice.
The above scheme is a traditional way of cooperation, coordination, and sharing. The major
disadvantage of this method is that both can’t simultaneously edit the document, which is a
fundamental problem of this scheme.
Second scheme without using Blockchain Technology:

Leveraging the shared Google docs or similar platforms, both Alice and Bob can write
the document simultaneously. However, this environment is still centralized. So the
question arises, Does a centralized environment harm, or what is the disadvantage of
a centralized environment?

The major problem of a centralized system is that it works as a single



point of failure.
● If we do not have sufficient bandwidth to load Google docs or similar
platforms, we will not download and edit the document. For example:
without an Internet connection, we will not be able to access the
document.
● What if the server crashes? There will be a 100% loss of data.
However, the company like Google has their dedicated server
architecture and made the server application failsafe. In the case of a
crash, the system will load the document from the backup repositories.
A scheme using Blockchain Technology:

Alice has her copy of the document, and Bob has his own of the document. These copies belong
to both Alice and Bob, and they can simultaneously write/modify their document.
The document sharing technology in between ensuring that the information consistencies
maintained between the documents which both possess.
The above example is an ideal use case where we can use the Blockchain platform. The
Blockchain platform which is spans over the network and it will help us to make this kind of
cooperation and coordination, and it goes as follows:

Alice will keep her copy of the document.

Bob will keep his copy of the document.

They can independently write/modify their copy. The Blockchain platform will ensure that the
information inside the document will be synchronized within the finite interval. As a
consequence, both can see the most updated copy while keeping track of document
modification history.

This is the advantage of Blockchain technology over a completely decentralized or


decentralized architecture where we have a shared copy shared between multiple
parties. Blockchain is a decentralized database with strong consistency support. It helps both
Alice and Bob to simultaneously read or write the documents without relying on the centralized
system.
The below example is a use case of Blockchain Technology where multiple nodes (Entities or
Users or Computers or Network Applications) communicate without depending on a
centralized system.

Every node maintains a local copy of the global datasheet

The system ensures consistency among the local copies

The local copies at every node are identical

The local copies are continuously updated based on the global information

In general, it is named as a public ledger

A database of historical information available to everyone

The historical information may be utilized for future computation

Example from banking system:

The historical information is the banking transactions


The old transactions are used to validate the new transactions

Public Ledger: It works like a database containing the historical information available to inform
everyone, and it can be utilized for future computation.

Use Case (2): Public Ledger from Banking Sector

Whenever we are going to the bank and request to make a transaction, the bank checks our
records and validates transactions stored in a centralized information system. However, in a
public ledger, we are moving from a centralized banking system to a decentralized banking
system. Moreover, where every individual has their copy of the global transactions, which are
synchronized and consistent. Whenever we are trying to make a new transaction, or someone
else is trying to make a new transaction, the new transaction is validated against the old
transactions that are already there inside the public ledger.

Lets us understand the same concept with an example:

We have 3 participants Alice, Bob, and Eve. Now assume that Alice initially has

100$ (dollars), and this information is available to all the participants.

Alice transfers 50$ to Bob.

As this is a valid transaction and this will be updated into the public ledger. The public ledger
possesses by all participants is as follows.
Alice: $100

Alice -> Bob: 50 (Alice: $50, Bob: $50)

Bob transfers 30$ to Eve, and it is also a valid transaction by seeing the public ledger. The
public ledger possesses by all participants is as follows.

1.
1. Alice: 100$
2. Alice -> Bob: 50$ (Alice: 50$, Bob: 50$)
3. Bob -> Eve: 30$ (Alice: 50$, Bob: 20$, Eve: 30$)
● Alice tries to send 80$ to Eve. This transaction is not valid, and the
participant will not accept it. Hence, it will not be added into the
public ledger as the record shows Alice is only having 50$.

Blockchains are nothing but a public ledger; however, whenever we are implementing such kind
of Blockchain by utilizing the concept of the public ledger, we need to ensure several different
aspects.

●Protocols for commitment: Ensure that every valid transaction from


the clients is committed and included in the Blockchain within a finite
time.
● Consensus: Ensure that the local copies are consistent and updated.
● Security: The data needs to be tampering proof. Note that the clients
may act maliciously or can be compromised.
● Privacy and Authenticity: The data (or transactions) belong to various
clients; privacy and authenticity need to be ensured.
More detailed explanation:(Optional reading)

1. Protocols for commitment


● Whenever someone is making a new and valid transaction, it
must be committed to the existing public ledger or Blockchain;
otherwise, that entry will miss. Consequently, the whole
transaction branch will become inconsistent.
● There should be a mechanism for validity checking of every
upcoming transaction from the clients, and based on that
validity checking, the transaction must be added into the
existing public ledger or Blockchain; else, delete or discard the
transaction.
2. Consensus:
● It is an important aspect in the context of Blockchain. A local
copy of the information is available to every individual party.
There is no such centralized platform system, such as a bank
server, that maintains transaction consistency.
● The consensus mechanism ensures that whatever local copy
every individual party has, these are consistent and identical
to each other.
3. Security:
● The third important aspect is security. It means that the data
we are inserting in a public ledger or inside the Blockchain, as
this Blockchain is distributed, and individual parties maintain
their local copy of the Blockchain.
● If a person changes something in that local copy and
broadcasts that saying it is updated information. The other
network nodes should understand whatever this person has
broadcasted false or the tampered information, and if it so, it
must be discarded.
● The security needs to be ensured as we do not have
centralized authority like the bank that maintains the validity of
the information; instead, we have to provide the validity in a
decentralized way.
4. Privacy and Authenticity:
● The data or the transactions, which are there inside the
Blockchain, belong to various clients.
● After every transaction, the transaction information is put
inside the Blockchain. A copy of the Blockchain is available to
every party, so the privacy and authenticity of the information
need to be ensured.
Public Ledgers,
The public ledger organizes into a long chain of blocks of information. When a buyer and a
seller engages in a transaction, the blockchain verifies the authenticity of their accounts. This
is done by using the public ledger and by checking if the funds are available proceeds with the
transactions. However, if the funds are either not available in the buyer’s account or are
promised to another party, then the sale is prevented effectively making double buying
impossible.

A public ledger derives its name from the age-old record-keeping system used to record
information, such as agricultural commodity prices, news, and analysis. The public ledger was
available for general public viewing as well as for verification. As cryptocurrency-based
blockchain systems emerged, which rely on a similar record-keeping and public verification
mechanism, the use of the public ledger gained popularity in the world of cryptocurrency.
This article explores cryptocurrency public ledgers, how they work, and the challenges they
face.

KEY TAKEAWAYS:

A cryptocurrency public ledger is a record-keeping system

The ledger maintains participants’ identities anonymously, their respective cryptocurrency balances,
and a record of all the genuine transactions executed between network participants.

Scaling and security concerns are one challenge for cryptocurrency public ledgers and transactions.

How Cryptocurrency Public Ledgers Work


A cryptocurrency is an encrypted, decentralized digital currency that facilitates the exchange
of value by transfer of cryptotokens between network participants. The public ledger is used
as a record-keeping system that maintains participants’ identities in secure and (pseudo-
)anonymous form, their respective cryptocurrency balances, and a record book of all the
genuine transactions executed between network participants.

To draw a parallel, think about writing a check to a friend, or making an online transfer to
their bank account for $200. In both cases, the details of the transaction will be updated in
the bank's records—the sender’s account is debited by $200 while the receiver’s account is
credited by the same amount. The bank’s accounting systems maintain the record of
balances and ensure that the sender’s account has sufficient funds; otherwise, the check
bounces or the online transfer will not be allowed. If the sender has only $200 in their
account, and they issue two $100 checks, the order in which the checks are
presented determines who will receive the money and whose check will bounce.
Verifying Transaction Details
The transaction's details in the bank's records can be queried and verified by the two
parties between whom the transaction took place. Additionally, the bank record is
accessible only by the designated bank officials and the concerned (central) authorities like
the tax department or the government on a need basis. No one else can have access to
those details.

As a data storage container, the public ledger forms the backbone of a cryptocurrency by
storing information after verification. While its use is being widely adopted, configuring the
public ledger with the right parameters is important to maintain decentralized and
anonymous features for hassle-free transactions in cryptocurrencies.

Bitcoin
What is Bitcoin & how does it work?
Bitcoin is a decentralized digital currency that enables instant payments to
anyone, anywhere in the world.

The primary objective was to design Bitcoin to have a cross-country payment


system such that no government organization will have control over it. A
decentralized architecture helps it get a system where one has external control
over it and works over a complete peer-to-peer network, and supports different
securities levels so that the entire system becomes tamper-proof.

The entire system runs and manages two broad operations: transaction
management and money insurance. The transaction management includes the
transferring of bitcoins from one user to another safely. The money issuance
mechanism generates bitcoins in an economic aspect to properly regulate the
monetary base of bitcoin.

Money insurance in Decentralized Bitcoin Cryptocurrency

To understand the methodologies of money issuance in a decentralized system,


let us first understand how the centralized or normal banking system manages
money. The banking authority, the Central Bank (In India, RBI), regulates the
money inside the country. They create the new money, or with time they
demolish or drop the old money. They also control the rate at which money will
be generated, and all the banks must be compliant with the rules and
regulations of the Central Bank.

Bitcoin Cryptocurrency is an example of a Decentralized digital currency


system. It is designed and developed by considering technical and economic
aspects together. It uses underlying blockchain technology and a
permissionless distributed consensus mechanism where anyone can join the
cryptocurrency system, and there wouldn’t be any controller such as Central
Agencies.

A high-level overview of Bitcoin Cryptocurrency

In the bitcoin cryptocurrency system, there are two types of users: miners and
normal users.

• A normal user needs to download and install a bitcoin wallet then


generate a bitcoin network identity for himself/herself so that other
uses can send or receive transactions.
• Internally bitcoin wallet communicates to the seed node, a special
node with information about other nodes in the peer-2-peer
network, and gets a list of nearby nodes’ IP addresses to
communicate and exchange transaction details.
• A normal user role is to transfer or receive bitcoins from others
within the bitcoin network and validate the transactions received
from other peers and forward the valid transactions to other peers
except where it received. However, if the received transaction is for
him/her, then he/she updates their wallet with the transaction
amount.
• A Miner plays an important role in the bitcoin network. He listens to
all the transactions for approximately 10 minutes, validates all the
transactions, combines them, and places them into a block. Later
he appends the newly generated block to the bitcoin blockchain
and forwards it to the peers within the bitcoin network. Once others
accept the newly appended block, the system generates a reward,
and this reward is the only mechanism through which money is
generated in the bitcoin network.
• Bitcoin blockchain uses blockchain technology, and this
technology provides tamper-proof assurance for the bitcoin
blockchain. It means no one will modify old transaction details.
These transaction records are used to validate the new
transactions. So the tamper-proof assurance is crucial for the
proper functioning of a distributed permissionless cryptocurrency
system.
Permission-less Blockchain
Bitcoin-based architecture where blockchain has been used as a fundamental
building block. It uses a permission-less model. Ideally, in this model, any node
can join the network anytime without having any pre-authentication and pre-
authorization security services. It is more like anyone can join the network.

The major difficulty is how to validate the transactions when each individual
does not know or trust each other. This is achieved via the challenge-response
consensus protocol among the nodes. However, this kind of consensus protocol
cannot be used in the conventional distributed system.

In the challenge-response consensus method, the network throws a certain


challenge to the users or the nodes in the bitcoin network, and then the users
or nodes collectively try to solve the problem. If anyone such as an individual or
a group of users or nodes could solve the problem, they advertise the solution
to its neighbor. This is the way block of transactions are committed in the bitcoin
blockchain.

Summary: Bitcoin cryptocurrency, the difference between decentralized vs.


centralized banking system, and a high-level overview of the bitcoin
cryptocurrency.
Blockchain – Essence of Bitcoin

Bitcoin is a completely decentralized, peer-to-peer, permissionless


cryptocurrency designed by leveraging the underlying technology called
Blockchain.

● Completely Decentralized:
○ No central party for ordering or recording, or controlling
anything such as currencies.
○ Compare to the Banking system, which is centralized
and compliant to Government institutions’ rules and
regulations.
● Peer-to-Peer:
○ Software that runs on machines of all stakeholders to
form the system.
○ We do not have a central system with which all the
peers are connected. Rather, we have a complete
decentralized system where individual peers are
connected, and they share the information among
themselves.
● Permissionless:
○ No identity; no need to signup anywhere to use; no
access control – anyone can participate in any role.
○ Anyone can join the bitcoin network and performs the
transaction.
○ How can we ensure the system’s security, as the
persons who are joining the network are not
authenticated? They can be malicious or perform
malicious activity. The system should have the
mechanism to sustain and preserve integrity in the
presence of such kinds of malicious attacks.

This was the interesting concept that has been put forward in this Bitcoin
architecture.

Bitcoin Value Proposition


Bitcoin
size as per Feb 2021 – Growing exponentially

Bitcoin
Price as per Feb 2021

How Bitcoin works


A trivial
example of Bitcoin transactions to understand Bitcoin architecture.
As we discussed in the earlier notes about the public ledger, the same thing is
applied here. Now we are storing transaction information in a block. So every
block contains the transaction information. In the above example, blocks contain
single transaction information. Example:

● Block 1: A = 100₹
● Block 2: A -> B 50₹
● Block 3: B -> J 30₹

However, in actual Bitcoin blocks contain multiple transactions. Indeed it may


contain more than 1000 transactions in a single block.

All these blocks are connected using the concept of a hash chain. The
advantage of hash chaining is that it requires re-generation and updation of all
the subsequent transaction hash values to alter a single transaction record from
a block. The blockchain copy is available to every individual party, such as
Alice, Bob, Eve, and Jane. The case of a fraudulent transaction by an
individual can easily detect by others by verifying the old records that existed in
the blockchain.

In general, whenever there is a transaction, those transactions are included in


the existing blockchain, and all the individual parties receive updates from the
other network nodes. So, in the long run, blockchain size will gradually increase.

The Bitcoin Transaction Life Cycle


● Alice wants to send some money to Bob. Alice opens her Bitcoin
wallet, provides Bob’s address, the amount to transfer, and
sends.

● The wallet constructs the transactions, signs (Digital Signature


Scheme) using Alice’s private key and broadcasts it to the
network.
● For example, Alice -> Bob 50₹. As the network is Peer-to-Peer,
everyone is connected to each other through some means.
● The network nodes (Alice, Jane, or Eve) validate the transactions
based on the existing Blockchain (Old transaction records) and
propagate the transaction record to the miners.

● The miners are the special node exists in the Blockchain


network.
● The task of the miner is to include the transaction to the next
block to be mined. That means the miner’s task is to collect all
the clients’ transactions, which were there for, say, the last 10
minutes, construct a new block, and then apply a mining
mechanism.
● Mining is a procedure to construct a new block and add this to
the existing blockchain through cryptographic hash computation.

● Every block is connected with the next block through a


cryptographic hash function by miners. However, generating a
specific kind or pattern of the hash value is computationally
difficult and time-consuming. Still, it has to be solved by the
miners; then, only the miner can add this block to the blockchain.
This process is called Proof of Work, and for doing this work,
the miner earns Bitcoins.
● Once one of the miners or sometimes more than one miner
solves the problem, they can connect that block with the existing
blockchain. This is the broad overview of the entire methodology
of Bitcoin.
● The updated blockchain is propagated in the network by the
miner. It means every participating node in the network receives
a copy of this updated blockchain.
● Once they received included Bob. Bob’s wallet software looks into
the updated blockchain and updates the wallet if any legitimate
transaction exists by his name.

Bitcoin – The Miners


The life of a Miner in Bitcoin Network

The first task is to validate the transactions and construct a new block.

Once they have constructed a new block, they employ their hash power
and vote on consensus to determine who will complete the work first and then
propose that block as a new block.

Add that new block to the existing bitcoin blockchain, and broadcast that
updated blockchain to the peers. So that way, the entire blockchain gets
propagated in the network.

Mining Bitcoin

• The first and foremost task is to join the network, listen for
transactions, and validate the proposed transactions from the
network clients.
• Listen for the new blocks proposed by other miners, validate, and
re-broadcast to the peer nodes. However, re-broadcast to a node
that resides in a subnet of the bitcoin network. This is the standard
policy followed by the bitcoin network nodes to avoid the Sybil
attack.
• Collect the transactions for a predefined time, and construct a new
block that includes all the transactions not included in a block of
the main bitcoin blockchain received from the peer nodes.
• Participate in the mining procedure, where the miner task is to find
a nonce [number once generated] to make the new block valid by
utilizing the predefined difficulty function. That means the proposed
new block must have a certain minimum number of zeros at the
prefix. This is also called “Proof of Work” for consensus that a
miner had done some work quicker than other miners in the bitcoin
network.
• Once a miner can generate a valid block and quicker compared to
other miners. The miner will broadcast that new block to the peers,
and everybody in the peering system will accept that block if it is
part of the main chain.
• In the typical bitcoin network, multiple new valid blocks
may be generated together by the different miners, and
these blocks may or may not have a list of the same
transactions.
• Flooding rule: If multiple valid blocks are received from
the peer nodes to an individual (a node or miner), the
individual will accept the valid blocks but rebroadcast the
block received from more peers.
• The bitcoin blockchain always has the main chain and
multiple orphans blocks. The main chain is the longest
blockchain in the network, and orphans blocks are blocks
from the fork chain that come out from the main chain but
do not grow longer than the main chain.
• Whenever a miner finds a new valid block and can successfully
append it to the main chain, the miner earns a certain reward.
However, other mines may be trying to generate a valid block
during the same period, but already one of the miners found the
valid one. In that case, they will discard the generation process and
start collecting all the new transactions that are not there in the new
append block of the bitcoin blockchain.
Mining Difficulty

It is a measure of how difficult it is to find a hash below the giving target. The
mining procedure says that we are going to generate a 256-bit hash value. And
there is mining difficulty, and it is represented in this way. Out of 256-bit hash,
at least the first 64 bit should be zeros. This says that you have to generate a
hash value wherein the final hash result, at least the first 64 bits, should be zero,
and after that, the remaining bits can be zeros and ones.

This is the difficulty of the mining procedure, and based on that, we defined a
metric called mining difficulty.

These difficulty parameters change for every 2016 block or every two weeks.

The desire rate of generation of a block is every 10 minutes. If the system tries
to generate a new block every 10 minutes, then 2 weeks are required to
generate 2016 blocks.

Difficulty level readjustment mechanism (Valid for every 2 weeks or 2016 blocks):

The difficulty level readjustment works as follows. The system finds out whether
miners can generate 2016 blocks within 2 weeks or not. If they are taking less
time, that means the difficulty is too simple for the miners.

So the system increases the difficulty parameters for the next round of 2016
blocks.

On the other hand, if the miners take more than 2 weeks to generate 2016
blocks. It means that the current difficulty is too hard for the miners. So the
system reduces the difficulty parameters for the next round of 2016 blocks.
This way, the bitcoin network dynamically changes the difficulty levels. In
general, the change in difficulty is in proportion to the amount of time over or
under two weeks the previous 2016 blocks took to find.

Difficulty formula

The difficulty level readjustment happens after every two weeks or 2016 blocks,
whichever comes first. The expectation is that within 2 weeks, 2016 blocks
must be generated so that inter-block generation time becomes equal to 10
minutes. The formula to generate or find the current difficulty is as follows:

Hash-rate versus Difficulty

The hash is a random number between 0 and . To find a block, the hash
must be less than a given target.

• The offset for difficulty 1 is . It means out of 265 bits,


the initial 48 bits must be zeros, and the remaining can be either
zeros or ones.
• In general, the offset for difficulty D is .
• The D tells how many zeros would be there at the beginning. So
the expected number of hashes need to be calculated
as .
The difficulty level dynamically changes the amount of hash that miners need
to generate.

If D is a more difficult value, then generate more hashes to get the resulted
target well.
Smart Contracts,
A smart contract is a self-executing contract and the contract terms between
the two parties are written directly in code or programable logic using some
general-purpose, high-level programming language rather than on paper
documents.

The blockchain environment facilitates the execution of these kinds of contracts


as similar to bitcoin scripts. However, the bitcoin script was simple as compared
to the scripts used in the smart contracts. Moreover, the bitcoin script concept
is extended to execute complex types of contract code in the blockchain
environment.

Even the bitcoin script, apart from basic scripts like transfer bitcoins from sender
to receiver, the sender can also write a script in such a way so that the receiver
will not able to spend the bitcoins immediately. Rather, the bitcoins will become
spendable only when the imposed condition is met.
In the smart contract, generally, there are buyer, seller, assets, and contracts.
A buyer is willing to buy the asset which the seller possesses, and the contract
is the agreement between the two.

In general, a certain script will be executed at the seller’s end whenever a buyer
buys something, and similarly, a certain script will be executed at the buyer’s
ends.

Let us try to understand the smart contract with an example of an asset as


ownership.

Suppose the buyer has sent a certain amount of currency to the seller, and the
contract actually verifies that this amount of money has been transferred from
the buyer to the seller.

Then, the seller sends the ownership of that particular asset to the buyer. So in
the future, the seller will not be able to claim ownership of that asset. At the
same time, the buyer will be able to claim his or her ownership of that particular
asset. This is the concept of smart contracts, which are executed in a closed
environment with the help of blockchain.

In a typical business platform, there is a limited number of buyers and sellers.


The buyers and sellers can always register at a central port so that everyone
can know each other. But there may not be any trust relationship between them,
and most probably, it happens that some sellers are fraud. They are just taking
the money and not giving the asset to buyers.
So these kinds of frauds or malicious activities in the system can be prevented
with the help of a permissioned blockchain.

Smart Contract Design Limitations

Sequential execution

The blockchain concept came from a permissionless environment, and the best
use case is bitcoin cryptocurrency. In bitcoin, the transactions are executed
sequentially based on the consensus. If a transaction gets verified and
committed, that will be executed first, and the transaction committed later will
be executed next. Similarly, in the context of smart contracts, the request to the
applications (i.e., smart contracts) are ordered by order of the consensus in
which the individual application of the contracts get a consensus, and they are
executed in that particular order.

These sequential order types actually give the effective throughput and ensure
that certain consensus or ordering of transactions is made. We can apply “Proof
of Work” based techniques in the permissionless model where the network
chooses a challenge, and the user tries to solve that particular challenge
individually. The nature of the challenge is that it is difficult to find a solution for
that challenge, but once a solution is found, everyone can verify it very easily.
So with that particular challenge-response-based method, the nodes try to
come to a consensus.

The serializable order of transaction execution gives a bound on the effective


throughput. If the commitment latency gets increased, then throughput gets
decreased. It is similar to if we increase the difficulty of the challenge, the
effective throughput will decrease. The throughput is defined as the number of
transactions committed per unit time. So the effective throughput is inversely
proportional to the commitment latency.

This can be a possible attack on the smart contract platform. The attacker
introduces a contract that will take a long time to execute, and that is why if a
certain contract takes a huge time to execute, the other contracts will not be
able to execute further, as once the consensus for the previous contract has
been reached, then only other will be able to execute the contracts which are
submitted later on.

Maintaining a serializable order of the transactions prevents you from executing


a later contract until the previous contract gets executed. If an attacker
introduces a malicious contract in the system, which will take a huge amount
for execution, the attacker will launch a denial of service attack on the
consensus algorithm.

Non-deterministic execution

To implement a smart contract, we need to go to some programming language


that gives us more power than the bitcoin script. Bitcoin script is not turning
complete language and does not support all the constructs. For example, it does
not support loops and has a certain limitation on execution. However, to
implement a smart contract, we need to increase the power of the script so that
we can write any general-purpose contract in the form of a code. Thus, we
choose programming language based on the requirements. One of the
interesting languages is golang, and it has been used in the smart contracts
Ethereum platform.

For example, in golang, iteration over a map construct may produce a different
order in two executions. However, the smart contract execution is contrary; it
should always need to be deterministic; otherwise, the system may lead to a
certain inconsistent state or may have many forks in the system. One particular
user executes the contract and gets one result or one order of result compared
to another user executes and gets another result. So if we are getting two
different ordering of results, it may be difficult for the system to ensure the
longest chain in the blockchain.

Execution on all nodes

We execute the smart contract to all nodes and propagate the state to others;
that way, it reaches a consensus. To ensure consensus, the question is, do we
have a sufficient number of trusted nodes to validate the execution of the smart
contracts. If the number of trusted nodes is less than the number of malicious
nodes, they may control the entire environment. However, it can be prevented
by going to a permissionless setting and use a Proof of Work-based consensus
mechanism. But the major problem is like we may be stuck to a particular block
or a kind of starvation scenario where a contract is taking a long time to execute,
and all the contracts are getting backlog. So that is why we want to move from
the challenge response-based method to the traditional distributed system-
based consensus algorithm in this permission setting. But in that case, we have
to ensure that you have a sufficient number of trusted nodes in the system.
Do we really need to execute contracts at each node?

Indeed it is not necessary, and we need state synchronization across all the
nodes. So, we execute the contract in one node and propagate the state of the
contract to the neighboring node, and those nodes will propagate it further. That
way, every node in the system gets the same states of the contract.

But a typical question comes that what if the node that executes the contract
becomes faulty. The system gets down, and it will not be able to make any
progress further. In this scenario, the idea is to use state machine replication
and execute the contract at a subset of nodes to ensure that the same state is
propagated to all the nodes. This way, we can ensure that every node that is
there is the part of the smart contract they are on the same page. They know
that list of contracts gets executed, and the remaining part needs to be
executed.

State machine replication is a powerful tool to ensure consensus in a permission


blockchain environment.
Block in a Blockchain,
Public vs. Private Blockchain,

Permissioned
Parameters Permissionless

Open Network allowing anyone to interaction Closed Network with limited Decentralization and designated
Overview consensus validation and ful decentralized parties for participation in Consensus Validation

Also Known
As Public, Trustless Private, Permissioned Sandbox

1. Full transparency 1. Controlled Transparency


2. Development in Open Source 2. Development by Private entities
3. Mostly Anonymous 3. Not anonymous
4. Privacy dependent on technological limitations 4. Privacy based on governance decision
Key 5. No Control Authority 5. No Single authority
Attributes 6. Involves digital assets 6. May or May not involve digital assets.

1. Brader decentralization 1. Incremental Decentralization


2. Highly transparent 2. Strong privacy
3. Censorship resistant 3. Customizable
Benefits 4. Security resilience 4. Faster and Scalable.

1. Less energy efficient 1. Limited decentralization


2. Slow and difficult to scale 2. Override risk
Drawback 3. Less user privacy 3. Less transparent

1. P2P 1. B2B
Market 2. B2C 2. B2C
Traction 3. Government to Citizens 3. Government to Organizations
Understanding Cryptocurrency to Blockchain,
The world is continuously undergoing revolutionary technological innovations, and the concepts of
cryptocurrency and Blockchain have become an integral part of this advancement. Both
cryptocurrency and Blockchain, work together in providing us with a new future. There are multiple
types of cryptocurrencies competing in the market today, such as Bitcoin, Ethereum, Namecoin,
Ripple, etc., which, when empowered by Blockchain, operate without the need for a central authority.
However, not everything is good with these concepts, and many governments across the world have
come forward, against cryptocurrency and Blockchain. Many have gone ahead further in banning the
entire process and making it illegal for anyone to be related to them.

This paper aims to introduce the concepts of cryptocurrency and Blockchain, along with providing
information on their working and relation to each other. The paper also analyses the controversial
nature of cryptocurrencies and Blockchain.

Introduction

Cryptocurrency, unlike any other medium of exchange, is a digital medium of commerce


commencement. It is similar to the real-world currency, however it does not have any physical
embodiment or central issuing or regulating authority that means it is used to make payments without
any fees, as no bank or government authorises it. Cryptocurrency uses cryptographic functions to
administer financial transactions and prevent them from fraudulent and counterfeiting transactions
as the legible information in such codes is almost un-crack-able. Its existence is based on the
Blockchain technology which leverages decentralised peer-to-peer networked ledger of all
transactions and thus helps in gaining decentralisation, transparency, and immutability.

Cryptography evolved in the digital era to become a system to secure information, communications,
and money online while it was born way back during World War II as a way to secure communications.
During the 90’s technological advancements, many attempted to create a digital currency with the
help of emerging markets such as Flooz, Beena, and Digi Cash but inevitably failed. Eventually, in 2009,
Satoshi Nakamoto with a group of his programmers introduced ‘Bitcoin’ as a peer-to-peer electronic
cash system. There has been a proliferation of cryptocurrencies since then, and currently, there are
around 2000 cryptocurrencies available in the market.

How Cryptocurrency Works?

Cryptocurrencies allow users to make secure payments and store money using decentralised
technology while being anonymous about the user’s identity and without going through the
centralised banking procedures. They run on Blockchain, which is a distributed public ledger.
Cryptocurrency units are made through a process called mining. Mining involves solving complicated
math problems using computers that generate coins. The currencies can also be bought from brokers
and can be stored and spent by using cryptographic wallets. Cryptographic wallets are digital wallets
that allow the currency to move from one owner to the next.

In cryptography, every transaction is recorded when the amount is transferred by the sender to the
receiver, and then a hash of previous transactions and the public keys (wallet address) of the next
owner is signed with individual private keys of both the parties in the transaction. Finally, the
transaction is confirmed and then broadcasted in the network, adding the transaction to the end of
the cryptocurrency. Thus, every transaction is recorded and a public ledger is maintained which
contains the record of all previous owners. Thus, by maintaining a public ledger, everyone in the
network can scan everyone’s account balance.

This decentralised network of maintaining a public ledger through Blockchain was introduced by
bitcoin. This process also eliminates the problem of double spending. Double spending is a fraudulent
technique in which the same amount is spent twice. It very important monetary issue faced by digital
payment networks around the globe. In traditional ways, it was solved by a third-party involvement,
a central server, which helps in maintaining the records of the transactions, which entails an authority
in control of funds and personal details. However, with bitcoin it is not an issue anymore as there is a
record of every bitcoin transaction ever made.

All the legitimate transactions can only be marked by the miners and transported across the network
because only miners can solve a cryptographic puzzle to confirm the transaction. Once the transaction
is marked legitimate and spread across the network, every network connection is added to its
database, which is further confirmed by the miners. After the confirmation, the data becomes un-
forge-able and irreversible. Thus, by doing so, the miners receive a transaction fee as a reward. Strong
cryptography ensures consensus-keeping processes in cryptocurrencies.

Types of Cryptocurrencies

The most common cryptocurrencies are:

(a) Bitcoin:

It is the first and most commonly traded cryptocurrency to date. Started by Satoshi Nakamoto, it sets
and serves as a digital gold standard in the entire cryptocurrency market and is used as a global means
of exchange. Currently, it is limited to 21 million coins.

(b) Ethereum:
This cryptocurrency has ascended to second place in the hierarchy of cryptocurrency. Ethereum can
not only process transactions but can process complex contracts and programs. It is the perfect
instrument for Blockchain, launched in 2015. With a turbulent past journey, it is proved to be a hugely
popular cryptocurrency launchpad in 2017, which provide a base for decentralised cryptocurrency
applications (more like an app store for cryptocurrency).

(c) Ripple:

Founded in 2012, Ripple is used by large companies instead of individual users because it allows the
movement of money in larger amounts across the globe. It is not a Blockchain based system, therefore
it allows variety of transactions, and not just cryptocurrency. As a lot of banks have joined Ripple, it
has immense value in the financial world. Unlike other cryptocurrencies, it has pre-mined coins which
require no mining thereafter.

(d) Litecoin:

Litecoin currency was the first cryptocurrency after bitcoin. Famous for its innovations, including faster
payments and processes to allow many more transactions, it is tagged as the silver to the digital gold
bitcoin.

(e) Namecoin:

Mined with bitcoin software as a bonus, Namecoin is a cryptocurrency. Based on the code of bitcoin
which uses a similar proof-of-work algorithm. As similar to the bitcoin, it is also limited to 21 million
coins. However, unlike bitcoin, Namecoin has its Blockchain transaction database storage.

How Blockchain Relates to Cryptocurrency

Cryptocurrency and Blockchain are often confused to being synonymous with each other. While they
both are intertwined in multiple ways, it is important to note that the two are different technologies.
Cryptocurrency, as discussed above, is a digitised currency that is either used as a store of value or
used as an exchange of value which falls under the umbrella of Blockchain. The cryptocurrency was
the first use case of Blockchain. Blockchain can be defined as any system which keeps “records by
cryptographic-ally linking ‘blocks’ of transaction data together into a ledger” (Braun, 2018). It writes
accounts in a specific sequence and makes it impossible for the accounts to be put out of that
sequence.
Every transaction in Blockchain technology is endorsed through a “consensus algorithm”, and involves
three parties, namely: the sender, the receipt, and the miner (Kulkarni, 2018). While senders and
recipients are the participants of the Blockchain transaction, the miners are the people that validate
such transactions and make the next block in the Blockchain. In return, such members are given
compensation through the different types of cryptocurrencies, like bitcoin, etc.

Blockchain, Bitcoin, and Ether

Bitcoin is the first example of Blockchain, and it is not difficult to say that without Blockchain, there
would have been no existence of bitcoin. In bitcoin’s Blockchain database, the ledger is stored and
revised collectively with the use of multiple computers attached to the original bitcoin network. As
this is a collective process, no one computer or institution is in charge of the process, as a result even
if one of the many computers is hacked or face technical issues, the other computers are capable of
going on without it.

However, bitcoin is not all that Blockchain is tied to. After the successful operation of bitcoin for a few
years, many programmers and developers replicated the concept of bitcoin, and after adding new
features, created other kinds of ledgers for storing data securely. After bitcoin, ether is the most
valuable virtual currency in existence. Ether runs on the concept of ‘Ethereum Blockchain’, where in
addition to recording the virtual currency transactions, the program can execute simple programs as
well. For example, it has become possible to move the virtual currency of ether between different
wallets, after an event through the Ethereum Blockchain.

Problems with the Old System

One of the several limitations of the old way of storing data was the maintenance being handled by a
single authority. If the database is being maintained by a single authority, it becomes more prone to
cyber-attacks, and it becomes easier for people to lose their access to the data provided. However,
with the introduction of Blockchain, people can now maintain and update their own individual copy
of the data. Through Blockchain, it has become easier for people to separate and maintain their own
records, which makes the process more efficient and less time-consuming.

Limitations to Blockchain

It would not be correct to say that Blockchain is completely safe, as there have been virtual currency
thefts in existence. Most theft cases are a result of hacking or stolen passwords or private keys, that
make the currency accessible to the users. This is where Blockchain gets problematic, as once the
currency is moved out of the virtual wallet, it is not possible for the currency to be moved back due to
the absence of any central authority. Therefore, for virtual wallets, the burden lies on the user to keep
his passwords safe and be as cyber-secure as possible.
Moreover, Blockchain experiences limitations in the quantity of data that it is capable to process. As
all the computers record every transaction, it is not possible for any of the computers to store more
or less, as compared to the others, which puts a limit on the quantity. This situation often makes
Blockchain technology unattractive and prone to questions and challenges.

Conclusion

According to the International Data Corp., it has been predicted that the worldwide annual spending
on Blockchain and Cryptocurrency would reach $11.7 billion by the year 2022 (Seth, 2019). The figures
clearly indicate that these concepts are expected to be our future and something that would keep
evolving and expanding in the long run. Therefore, it has become important for people to understand
the concepts with both its pros and cons and to make the correct choice.

Permissioned Model of Blockchain,

Permissioned Blockchain – Introduction

Permissioned blockchain – A decentralized computation and information sharing platform that


enables multiple authoritative domains which do not trust each other to cooperate, coordinate, and
collaborate in a rational decision-making process under a closed environment with the enablement of
security services such as authentication and authorization.

In the permissioned blockchain architecture, the users have to register and authenticate themself to
use the system. In this system, the users know each other. However, users may not trust each other,
assuming that certain users in the blockchain network may behave maliciously. Although, they got
authenticated to use the system. The objective is to run the blockchain among this known and
identified set of participants, but security and consensus are still required for the smooth functioning
of the entire ecosystem.

The permissioned environment consists of a closed environment, and the individual users knew each
other. They try to come to a common platform with no centralized database or data server rather a
completely decentralized architecture. Having a set of users known each other a priory, but they may
not trust each other. So in this particular setting, users cannot join the blockchain network anytime.
Rather, they have to go through the authentication mechanism to authenticate themselves before
accessing the permissioned blockchain network.
Provenance Tracking of Assets (Supply Chain System)

To ensure that whenever a certain asset moves from one particular supplier to the distributors,
distributor to the vendors, and at the end, to the market via retailers. At every stage, tracking
information must be maintained by different authoritative domains. Every authoritative domain has
complete control over the tracking information that they are providing. However, other authoritative
domains can verify the tracking information but can’t tamper. Here authoritative domains represent
Supplier, Distributor, and Vendor as these are independent organizations with different policies to
work. In this type of use case, we can use premissioned blockchain architecture.

Provenance/sorce/origin of assets - in the permission settings of blockchain.

The interesting fact is that why not use a centralized server to have these tracking entries? And anyone
can look into that centralized tracking entries and verify indeed. The problem is who will maintain the
centralized server. Suppose if a party, say Distributor, maintains a centralized server, then why Vendor
or Supplier trust the data uploaded by the distributor. In the other case, suppose they are using a
third-party solution—having high maintenance charges and difficulty building a trust relationship
among individuals.

Provenance Tracking of Assets (International Postal Services)

Let us understand how it works in the centralized environment.

National Postal Service

The single-party setup, such as sending or receiving goods within the same country and the same
service provider, is easy, and a centralized system solves this problem. They can maintain tracking
information in their centralized server, and with tracking IDs, the users can easily track the status of
consignments.

International Postal Service

Maintaining the tracking information for international goods services is difficult. For example, A typical
use case can be like sending postal mail from India to the USA. The India Post is the one authoritative
domain, and basically, they transfer the post up to their border gateway, and from there, they will
send it to some international agency. Who will take the courier to USA post, and then USA post will
take it and transfer it internally.
The first problem is that whenever we have multiple authorities, it is difficult, or there is a kind of trust
issue whenever they rely on a centralized server. So the question comes who will host that server? If
India post will host the server, then the question comes that why the USA post will trust or believe the
data which is there in the India Post server and vice versa.

The second problem is that if none of the India or USA posts will host that particular service, they may
purchase the service from some third-party agent. It is like take the service of a third-party cloud. They
have to pay a significant amount of money for that third-party cloud. As there are multiple
authoritative domains, they require a certain kind of access to that central server, and the question
comes that system provides a guarantee that the data which is entered by the USA post is not getting
tampered with by the data which is being entered by India post or vice versa.

Whenever there are multiple authoritative domains in the loop, there is a trust relationship problem.
That is why people do not go for any centralized server.

Premissioned Blockchain Architecture

For this kind of provenance tracking of assets, it is more beneficial to use the permissioned blockchain
environment and the beauty of the permissioned blockchain environment is that it does not require
to host any centralized server. The individual would maintain the data, but everyone will be able to
validate other’s data.

The first typical use case was from the Supply Chain System, where goods are transferred between
the suppliers and distributors, distributors and vendors, and vendors and retailers. In this scenario, we
have multiple suppliers, distributors, and vendors. Like every individual supplier, distributor, and the
vendor has its individual authoritative domain and follows its own policy of entering data. Still, a third-
party auditor should have access to this entire data. They should reliably verify the correctness of data
that is being passed through supplier distributor vendor and the final in the market.

The second typical use case was from Postal services, where we know that the posts/goods/couriers
will either go from India to USA post or vise versa. So we have a closed set of participants who are
participating in the entire blockchain environment. But still, the trust relationship is not there. To
maintain a certain kind of security or ensure that the data is not getting tampered with while
transferring from one authoritative domain to another authoritative domain.

However, why not permissionless architecture? We can also use the permissionless model, but there
are certain disadvantages of using the permissionless model because we are going for an open
environment. Whenever we are going for an open environment, the network or system becomes more
complex. It has to handle many things all together, which is why we want to move from a
permissionless to a permissioned model.
Summary

We have seen permissioned blockchain architecture and different use cases from Supply Chain System
and another from International Postal Service. Studies permissionless blockchain architecture is not

.
suitable for these use cases

Overview of Security aspects of Blockchain.

Basic Crypto Primitives:


Hash functions,
Blockchain – Cryptographic Hash Functions
A Hash function is any function that can be used to map data of arbitrary length
to fixed-size length. A trivial hash function is as follows:

where and are integers and is the modular (remainder after division
by ) operations. can be of any arbitrary length integer, but is within the
range . However, this does not qualify for cryptographically secured
hash functions and these are mainly used in Blockchain Technology to verify
the integrity of data.

According to the pigeonhole principle, the major problem with a hash function
is to avoid collision as we are mapping something from the arbitrary length to
the fixed length.
Suppose N items are put into M containers, where N < M than at least one
container must contain more than one item. Thus, the collision must be there,
but it can be minimized if the cryptographer well designs the hash function.

Let us first understand what a collision is in the hash function. Given the two
distinct messages, M1 & M2 to the hash function H(*), which produce the hash
value H(M1) & H(M2) where H(M1) == H(M2) are the same.

Everything is done online in the digital world era: Suppose there is a contract
between two parties, and signing is done on the hash value of the agreement
paper. If collision exists then, the malicious party can modify the contract
agreement paper and force the other party to accept it in the future as the
signature is valid for a forged agreement too.

Cryptographical Hash Functions:

A cryptographic hash function is a mathematical algorithm that takes an


arbitrary amount of data as input and produces a fixed-size output called Hash
or Digest or Checksum. A cryptographic hash function can assure data integrity.

Example of Cryptographically Secured Hash Functions

● SHA1 (SHA160), SHA256, SHA512


● RIPEMD160, RIPEMD256
Here the number indicates the security level or steps requires to break the
hashing scheme using the brute force method: For example, SHA160 or SHA1
means to find collision it requests steps. However, because of the birthday
paradox, it reduces to steps.

Important note: SHA1 collision is reported in 2017 in this paper published


by Google researchers.

Properties of a hash function,


Security requirements for Cryptographically Secure Hash Functions

● Preimage resistance – One way ness – It means given a , we


can computer , but given a , no deterministic algorithm
can computer .
● Second preimage resistance – (Weak collision resistance
property) – It means given a and respective , an adversary
need to come up another and such that .
This is assumed to be a weak collision resistance property as there
is a restriction imposed to generate same hash value.
● Collision resistance – (Strong collision resistance property) – It
means adversary can choose any & such that and
come up with the same hash value. If any cryptographic algorithm
adheres to a strong collision resistance property, it means the
adversary takes more time and computing power to find a collision.
● Avalanche effect – A small change in the input data results in a
significant change in the output hash value. The example is
illustrated in the below diagram.
We can notice that a small change in text results in significant changes in the
hash value using the SHA1 cryptographic hashing algorithm.

Hash pointer and Merkle tree,

Blockchain – Merkle Trees


In the earlier notes, we had seen a mechanism called time-stamping digital
documents, a digital document sharing technique where multiple people can
edit the document, and the entire traces will be captured and stored in the chain
of blocks so that any malicious modification in the chain can be detected easily
by the others. This scheme is best for a single document. However, an effective
technique would be to use Merkle Tree where multiple documents hash will be
stored in a binary tree-like structure and modification of whole documents can
be detected by just comparing root hash. This concept is known as a hash tree
and used in blockchain technology.
Every leaf node is labeled with the hash of a data block and every non-leaf
node is labeled with the cryptographic hash of the labels of its child nodes.

In the above diagram, we are securing four documents D1, D2, D3, & D4
together and the root hash value will be propagated and any change in the
document effectively reflect the change in the root hash value.

This way we can collectively secure the number of documents together by using
the concept of Merkle Tree.

In 1992, Bayer, Harber, and Stornetta used Merkle Tree for timestamping and
verifying a digital document. This technique improved the efficiency by
combining timestamping of several documents into one block.

Other uses of Merkle Tree

● Peer to Peer Networks: Data blocks received in undamaged and


unaltered; other peers do not lie about a block.
● Bitcoin implementation – Shared information is unaltered; no one
lies about a transaction.
Public key cryptography
Public Key Cryptography or in short PKI is also known as asymmetric cryptography. It
uses two pairs of keys - public and private. A key is a some long binary number. The
public key is distributed worldwide and is truly public as its name suggests. The private
key is to be strictly held private and one should never lose it.

In case of Bitcoin, if you ever lose the private key to your Bitcoin wallet, the entire
contents of your wallets would be instantly vulnerable to theft and before you know it,
all your money (the contents of your wallet) would be gone with no mechanism in the
system to trace out who stole it - that is the anonymity in the system that I mentioned
earlier.

The PKI accomplice’s two functions - authentication and the message privacy through
encryption/decryption mechanism. I will now explain both these functions –

Authentication

When the two parties exchange messages, it is important to establish a trust between the sender
and the receiver. Especially, the receiver must trust the source of message. Going to our earlier
scenario (depicted in Figure 1) of Bob sending some money to Lisa for purchasing of some goods
from her, let us see how the PKI builds this trust between Bob and Lisa. Look at below image −

In the first place, if Bob wants to send some money to Lisa, he has to create a private/public key of its own.
Note that both keys are always paired together and you can not mix the private and public keys of different
individuals or different instances.

Now, Bob says that he is sending $10 to Lisa. So he creates a message (a plain-text message) containing Bob’s
(sender) public key, Lisa’s (receiver) public key, and the amount ($10).

The purpose of this remittance such as “I want to buy pumpkin from you” is also added into the message. The
entire message is now signed using Bob’s private key. When Lisa receives this message, she will use the
signature verification algorithm of PKI and Bob’s public key to ensure that the message indeed originated from
Bob. How the PKI works is beyond the scope of this tutorial. The interested reader is referred to this site for a
more detailed discussion on PKI. This establishes the authenticity of the message originator. Now, let us look at
the message privacy.

Message Privacy

Now, as Lisa has received her payment, she wants to send the link to her ebook which Bob wants to buy. So
Lisa would create a message and send it to Bob as shown in image –

The Lisa creates a message such as “Here is the link to my ebook which you had requested”, signs it with Bob’s
public key that she has received in Bob’s request message and also encrypts the message using some secret
key which is shared between the two during HTTPS handshake.

Now, Lisa is sure that only Bob can decode the message using the private key that is held by Bob alone. Also,
somebody intercepting the message would not be able to recover its contents because the contents are
encrypted by a secret key held only by Bob and Alice. This guarantees to Lisa that access to her ebook is
granted only to Bob.

Having seen both the features, Authentication and Message Privacy, implied by PKI, let us move ahead to see
how Bitcoin makes use of PKI to secure the public ledger that I mentioned in the chapter “What is Bitcoin?”.

For your knowledge − The most popular PKI algorithms are RSA and ECDSA, Bitcoin uses the latter one.
Digital signatures,
A digital signature is a set of algorithms for determining the authenticity and integrity of
digital messages or documents. It assures the recipient that the message was indeed created
by the expected sender and that the message was not altered during transmission. The sender
cannot deny having sent the message.

When Alice sends a document to Bob, she will follow certain steps to digitally sign the
document, as shown in the following diagram:

These steps are as follows:


1. Calculate the message digest of the document Alice wants to send to Bob with a
cryptographic hash function, usually MD5 or any SHA algorithm.
2. Encrypt the message digest with Alice's private key, append the encrypted message
digest to the original document, and send the combined message out.
3. Once Bob receives the combined message from Alice, he will separate the encrypted
message digest from the document itself. Bob will use Alice's public key to decrypt
the encrypted message digest.
4. At the same time, Bob will calculate the message digest of the received document
and compare the resulting message digest with the decrypted message digest to see
whether there is a match. If yes, Bob is assured that the document originated from
Alice without any tampering.
5.
In blockchain, a digital signature is a way to prove ownership of the underlying
cryptocurrency or electronic coin. When Alice needs to pay Bob 10 BTC, she will digitally sign
a hash of the previous transaction, which can prove that Alice has ownership of the 10 BTC.
In summary, cryptography is one of three foundational pillars in blockchain technology.
Public key cryptography is the basis for blockchain wallets and transactions, and the
cryptographic hash function is a key element underpinning the PoW consensus mechanism.
A digital signature is used as proof of ownership of the underline electronic coins or
cryptocurrency.

Zero-knowledge systems

What is a zero-knowledge proof?

Zero-knowledge proof is defined as an encryption scheme in which a party who is a prover can

prove their case of truth concerning specific data to the other party who is a verifier without

revealing the complete information.

Although the zero-knowledge proof is used to elevate the functionality of the blockchain

platform, this encryption scheme has preceded the innovation of the decentralized blockchain

ecosystem by almost 40 years. The ZKP method was formerly brought in by the renowned

researcher and the founder of Algorand Silvio Micali, along with Charles Rackoff and Shafi

Goldwasser, in the 1980s.

There are two fundamental types of zero-knowledge proofs as mentioned below:

Interactive ZKP
Interactive zero-knowledge proof indulges a constant series of actions or tasks that concerns

the prover’s completion to satisfy the verifier about their specificity of information. The

majority of the tasks performed under the Interactive zero-knowledge proof generally indulge

in the concepts of calculative probability.

Non-Interactive ZKP

There is no need for any interaction between the verifier and prover in the Non-Interactive

ZKP, or the verification can also be shifted to a later stage. These kinds ZKPs need software or

computers to be added to them for better mechanisms.

Irrespective of the differences between the various kinds of zero-knowledge proof, all the

ZKPs require three fundamental prerequisites:

Soundness

Soundness implies that the statement cannot be neglected and falsified, and the situation is

that the verifier cannot be convinced. The prover has the needed input, which they otherwise
cannot have.

Completeness

If the given statement is true on all grounds, the verifier is entitled to certify that they possess

the needed input.

Zero-knowledge

The verifier is not entitled to know anything beyond the statement being false or true. Specifics
of the information and the private data of other parties remain anonymous.
Applications of zero-knowledge proofs in blockchain technology

Users are seeking control and autonomy over their information benefit from ZKPs since they

give flexibility and choice. As a result, it makes sense that when blockchain and ZKPs are

coupled, they may be used for various purposes.

Transactions between individuals (EY and Nightfall)

Numerous privacy and data sovereignty problems prompted consultancy company EY to

develop ZKP and blockchain solutions. EY launched Nightfall, a public ZKP protocol in 2019 that

enables businesses to maintain anonymity while performing private and secure transactions

on public blockchains.

EY will work on Starlight, a ZKP prototype compiler, as part of their $100 million investment in

blockchain-related developments. Starlight supports the wants of complex business

agreements where business logic must be shared between parties at the network level while

maintaining privacy from competitors. Both Nightfall and Starlight seek to increase consumers’

security and privacy when using blockchain apps.

Applications for messaging

Encryption from end to end has been critical in enabling messages to be sent secretly.

Traditional messaging apps, on the other hand, require users to authenticate their identity

with a server. Individuals can establish their identification using ZKPs without disclosing further

personal information.

Documentation is extensive

By combining ZKPs with blockchain, users may securely communicate complicated documents.
ZKPs offer the ability to segment data, enabling users to manage certain blocks and the
accessibility of the information contained inside them, granting access to some users while

restricting access to others.


Like different types of technology, the zero-knowledge proofs have a diverse range of benefits.
ZKPs are simple with no complicated encryption and elevate the security level of users by
eliminating the risk of revealing personal information on the blockchain platform. Hence, the
innovation of zero-knowledge proofs has changed the face of blockchain technology,
maintaining its scalability and security
Blockchain – Centralized vs. Decentralized vs. Distributed
Systems
in the context of a group or set of nodes or computers communicating to each
other for cooperation, coordination, and collaboration in the application
development process at the business intelligence process.

Centralized Systems: Complete reliance on a single point.

● There is a central coordination system, and these nodes can


communicate with the other nodes via the central coordination
system. However, the major problem is that the entire nodes will
be disconnected if the central coordination platform fails. Thus, it
suffers from a single point of failure.
Decentralized Systems: Multiple points of coordination.

● There are few central coordinators rather than a single coordinator,


and all these coordinators cooperate, and the individual nodes are
connected to these coordinators. If a particular coordinator fails in
this particular architecture, service will still be accessible by
another coordinator. This architecture still tolerates multiple
numbers of failures until the network becomes disconnected.
Distributed Systems:

● In this system, everyone collectively executes the job. It has a


complete distributed architecture without any centralized
coordinator. All the nodes participate in the computation or the
information sharing processes or in the application development.
They coordinate with each other and collectively develop the
application or collectively share the information among
themselves.
Pros And Cons Of Centralized, Decentralized & Distributed Systems

Maintenance/Points of Failure

● Centralized systems are easy to maintain as there is only a single


point of failure.
● Decentralized have more but still finite numbers of failures.
● Distributed systems are the most difficult to maintain.
Fault Tolerance/Stability

● Centralized systems can be highly unstable and intolerable due to


single-point failure may ruin the whole working system.
● Decentralized systems are stable systems compared to
centralized systems as if the leader’s failure in decentralized
doesn’t harm the rest of the system. Still, we will have a stable
network working in synchronization.
● Distributed systems are much more stable, and a single point of
failure doesn’t do much harm.
Ease of Development/Creation

Centralized systems can be created rapidly, and an easy way has



to build a central server for commanding/managing the connected
components.
● For Decentralized and Distributed systems, one has to first work
out the lower-level details like resource sharing
(Hardware/Software), trade (Transaction), and communications
(Network), and it imposes a certain level of difficulty in maintaining
these systems to its coherent state.
Max Number of Users Added to the System/Scalability

● Centralized systems: Low scalability


● Decentralized systems: Moderate
● Distributed systems: Infinite
Diversity / Evolution

● As centralized systems shadow a single framework, they don’t


have diversity and grow gradually.
● But for distributed systems and decentralized systems, once the
elementary infrastructure is in place, evolution is remarkable.
Blockchain – Time-stamp a digital Document
The blockchain concept came into the picture in 2011. However, it is not fully
true. This concept was there earlier in one or another form, and it evolved
gradually and became famous when this concept was used to design
cryptocurrencies like Bitcoin.

The first use of this concept of a cryptographically secured chain of


blocks came in 1991 in a paper by Harber and Stornetta. They developed and
presented a mechanism for time-stamping digital documents. A digital
document is created and modified by multiple people, and entire details are
captured and stored in the chain of blocks.

The goal was to maintain a list of timestamps when the document has been first
created, followed by when the document was edited in a subsequent but secure
way such that no one will be able to make a change in the timestamp value.

The timestamp is important for the document management purpose because


many of the time, we want to see when the document was last edited or if some
person claim that he/she has not made any edition in the document, it can easily
verify whether that person has actually edited the document or not.

To solve this particular problem, Harber and Stornetta have used this concept
of a chain of blocks. However, they have not claimed this as a Blockchain, but
the concept is similar to Blockchain.

Let us understand the same with an example:

1. A sequence of timestamps such as TS1, TS2, TS3, TS4,


and so on are denoting when the document is created or
edited.
2. Whenever a client accesses a document, it constructs a
block consisting of a Sequence Number, Client ID, Current
Timestamp, and a previous block hash value.
3. After modification, it takes the above parameters,
generates a new block, and appends with the documents.
The advantage of this hash chain is that if we want to make some change in the
timestamp value. For example, if we want to change the timestamp value TS1,
we need to update all the hash values starting from H2, H3, and H4 all the
subsequent hash values, and people will able to observe that all these values
have been changes. This way, they will be able to detect that someone is trying
to tamper with the document.

This way, the concept of chain of blocks by connecting them by the hash
function, that was used to cryptographically securing the timestamp value of a
digital document, so this particular architecture looks like something similar to
Blockchain where we have multiple blocks of data, and a hash value connects
these blocks of data.
Blockchain – Essence of Bitcoin
Bitcoin is a completely decentralized, peer-to-peer, permissionless
cryptocurrency designed by leveraging the underlying technology
called Blockchain.

• Completely Decentralized:
• No central party for ordering or recording, or controlling
anything such as currencies.
• Compare to the Banking system, which is centralized and
compliant to Government institutions’ rules and
regulations.
• Peer-to-Peer:
• Software that runs on machines of all stakeholders to
form the system.
• We do not have a central system with which all the peers
are connected. Rather, we have a complete
decentralized system where individual peers are
connected, and they share the information among
themselves.
• Permissionless:
• No identity; no need to signup anywhere to use; no
access control – anyone can participate in any role.
• Anyone can join the bitcoin network and performs the
transaction.
• How can we ensure the system’s security, as the persons
who are joining the network are not authenticated? They
can be malicious or perform malicious activity. The
system should have the mechanism to sustain and
preserve integrity in the presence of such kinds of
malicious attacks.
This was the interesting concept that has been put forward in this Bitcoin
architecture.
Bitcoin Value Proposition

Bitcoin
size as per Feb 2021 – Growing exponentially

Bitcoin Price as per Feb 2021


How Bitcoin works

A trivial example of Bitcoin transactions to understand Bitcoin architecture.


As we discussed in the earlier notes about the public ledger, the same thing is
applied here. Now we are storing transaction information in a block. So every
block contains the transaction information. In the above example, blocks contain
single transaction information. Example:

• Block 1: A = 100₹
• Block 2: A -> B 50₹
• Block 3: B -> J 30₹
However, in actual Bitcoin blocks contain multiple transactions. Indeed it may
contain more than 1000 transactions in a single block.

All these blocks are connected using the concept of a hash chain. The
advantage of hash chaining is that it requires re-generation and updation of all
the subsequent transaction hash values to alter a single transaction record from
a block. The blockchain copy is available to every individual party, such
as Alice, Bob, Eve, and Jane. The case of a fraudulent transaction by an
individual can easily detect by others by verifying the old records that existed in
the blockchain.

In general, whenever there is a transaction, those transactions are included in


the existing blockchain, and all the individual parties receive updates from the
other network nodes. So, in the long run, blockchain size will gradually increase.
The Bitcoin Transaction Life Cycle

• Alice wants to send some money to Bob. Alice opens her Bitcoin
wallet, provides Bob’s address, the amount to transfer, and
sends.

• The wallet constructs the transactions, signs (Digital Signature


Scheme) using Alice’s private key and broadcasts it to the network.
• For example, Alice -> Bob 50₹. As the network is Peer-to-Peer,
everyone is connected to each other through some means.
• The network nodes (Alice, Jane, or Eve) validate the transactions
based on the existing Blockchain (Old transaction records) and
propagate the transaction record to the miners.

• The miners are the special node exists in the Blockchain


network.
• The task of the miner is to include the transaction to the next
block to be mined. That means the miner’s task is to collect all the
clients’ transactions, which were there for, say, the last 10
minutes, construct a new block, and then apply a mining
mechanism.
• Mining is a procedure to construct a new block and add this to the
existing blockchain through cryptographic hash computation.
• Every block is connected with the next block through a
cryptographic hash function by miners. However, generating a
specific kind or pattern of the hash value is computationally
difficult and time-consuming. Still, it has to be solved by the
miners; then, only the miner can add this block to the blockchain.
This process is called Proof of Work, and for doing this work, the
miner earns Bitcoins.
• Once one of the miners or sometimes more than one miner
solves the problem, they can connect that block with the existing
blockchain. This is the broad overview of the entire methodology
of Bitcoin.
• The updated blockchain is propagated in the network by the
miner. It means every participating node in the network receives a
copy of this updated blockchain.

• Once they received included Bob. Bob’s wallet software looks into
the updated blockchain and updates the wallet if any legitimate
transaction exists by his name.
Cryptographic Primitives in Blockchain
.

Introduction

Blockchain is a decentralized, distributed ledger that comprises blocks. The Blocks are connected to
form a long chain. Each block comprises an address to the previous block and some information. The
address part is done with the help of hashing. The information comprises data such as transactions
and is encrypted. Blockchain was first implemented in the year 2008 by a group of people named
Satoshi Nakamoto. Blockchain uses strong cryptographic methods to manage the whole network.

Terms Related to Blockchain

Before diving deep into more, let us be familiar with the five most important things: Block, miner,
node, Block Reward and Cryptography.

Block: A block is the unit of blockchain that contains information in encrypted form. The blocks are
connected. It is also called an immutable record as it cannot be reverted once created. There are three
types of Blocks: Genesis Block, Valid Block and Orphan Blocks. Genesis Block is the first block that is
created at the start of the blockchain. Valid Blocks are the blocks validated by miners and added to
the blockchain. Orphan Blocks, as the name suggests, they are not added to any blockchain.

Miner: Blockchain Mining comprises of verification of transactions. Since blockchain is highly


decentralized, no authority can verify and secure the transactions. Miners are the users of the
technology who verify the transactions. After successful verification, they get incentives.

Node: Nodes are devices in which blocks are stored. The nodes also have a database that stores the
history of transactions and is connected.

Block Reward: A block reward is an incentive that is given to miners when they participate in the
validation of the blocking process. It has two parts: block subsidy and transaction fees.

Cryptography: It is a practice used in this technology to encode and decode data. The aim is to protect
data with the help of codes. The techniques used are a part of security protocols to prevent
unauthorized access from third parties. The word is made up of two terms ‘Krypto’ means ‘hidden’
and ‘Graphy’ means ‘written’.

Cryptographic Primitives
Structure of Blockchain

Working of Blockchain

The working is a multistep process, but it involves four phases: the creation of the block, verification
of the block, the addition of the block and updation of the database. The steps are as follows:

An authentic user requests a transaction.

A block is created in which the transaction or any other data is specified.

The block is circulated all over the network. Blockchain protocols do this.

Miners verify the block. Upon successful verification, the miners get incentives.

After the successful transaction, the database is added.

Cryptographic Primitives
Cryptographic Primitives are the tools used to build security protocols, which comprise low-level
algorithms. Security protocols are nothing but algorithms that are developed by Cryptographic
designers using Cryptographic Primitives as tools, and these protocols are executed when certain
conditions are met. Since Blockchain is highly decentralized in nature, the security of data is of utmost
importance. For example: Suppose two users want to exchange information on a public Blockchain. In
Public Blockchain, everybody can see the transaction process. To secure the data, encryption
algorithms are used. For decrypting, the data decryption algorithms are used. These cryptographic
primitives are used to develop these high-level secured algorithms.

Cryptographic Protocols

On Internet, protocols are a set of rules that are used to govern the network. Cryptographic Protocols
are the same. They are the rules that secure the whole blockchain network. The rules are made using
cryptographic primitives as the base. They are transparent as they are programmed. The goal of these
protocols is to provide data integrity, secure the exchange of data, and maintain the security of the
whole network. Hence they are often known as security protocols. Commonly used cryptographic
protocols are Bitcoin, Hyperledger, Ethereum, Corda etc.

Combining Cryptographic Primitives

As we all know, each cryptographic primitive is highly specific, and they are the building blocks of any
crypto protocols. So each crypto protocol performs a single task. The primitives are limited, and
developing them is a tedious task. This is because they are low-level programs and requires complex
mathematical analysis. So designers usually combine one or more cryptographic primitives to establish
strong crypto protocols so that the protocols can at least tackle the other small problems besides the
main problem. For instance, hashing and encryption methods can be combined.
Commonly used Cryptographic Primitives
There are many cryptographic primitives, but we will discuss the most commonly used ones. They are
as follows:

One-way hash function: It is a mathematical function which converts an input of any length to a binary
sequence of fixed length. It cannot be reverted, which means the original string cannot be retrieved
back from the hash. It is to be noted that even a small change in the input can change the meaning of
the whole output. For example, SHA256 is a hash function. It generates 32-byte strings for any input.

Symmetric Key Cryptography: It is a popular encryption algorithm and is also known as symmetric
encryption. The principle of this algorithm is a shared key. For example, a person wants to send some
confidential data. He/She encrypts the data and ‘locks’ it with a key. The same key is used to decrypt
or ‘unlock’ the data when the message is received. This algorithm is mostly used when large amounts
of data are sent. The problem is sharing the key. The sender and receiver parties should have the same
key. Examples of Symmetric key Cryptography are AES, DES, and 3DES.

Asymmetric key cryptography: It is also known as public key cryptography. This method has been
developed to cope with the disadvantage of Symmetric Key Cryptography. Two types of keys are used:
Public key and private key. The public key is used to encrypt the message, whereas the private key
decrypts the message. Examples are: Diffie-Hellman, DSA and RSA

Digital Signature: This is used in blockchains to authenticate transactions or other data. Whenever a
digital signature is used, it establishes that the rightful owner has sent it and the message has not been
altered. The here private key is used as a digital signature by the user, and once it has been sent to
the receivers, the receivers validate the message using the public key.

Private Information Retrieval: This protocol allows users to retrieve information from the database
without other users knowing about it. Here the user can anonymously retrieve the information from
another server.
Conclusion

Cryptographic Primitives are building blocks of Blockchain security. They form the baseline of
the security protocols.
Although complex, these are highly reliable and can be used to develop any security protocols
with certain changes.
The crypto designers must choose and combine the primitives so that there are no flaws and
the whole tech is completely safe and secure.

OR
Blockchain: Common Cryptographic Primitives

There are several key concepts that are crucial to the underlying mechanisms that make up a

blockchain implementation. Those concepts are encryption, asymmetric encryption, public key

signing, hash functions, entropy, and the elliptical curve digital signing algorithm (ECDSA) and
its domain parameters that sometimes differ between blockchain solutions. Those and other

related topics are summarized below:

Encryption (Symmetric)

In cryptographic mechanisms, encryption is the foremost practical application. It ensures

confidentiality by making data incomprehensible without knowing both the cryptographic

algorithm used and a secret key. An encryption key is a random piece of data of varying length

(typically from 128 to 4096 bits), used by encryption algorithms to obfuscate or encrypt

messages. Without possession of the key you cannot decrypt a piece of encrypted data. The

image below depicts symmetric encryption, where the same secret value (a key), is used to

both encrypt and decrypt a message.

Encrypting “Hello!” with a key to create an encrypted message, “f7#E+r”, which is then
decrypted with the same key back to “Hello!”.

Asymmetric Encryption

Symmetric encryption, as shown above, is a cryptographic mechanism where the same secret

key is used both to encrypt and decrypt data. Asymmetric encryption is a mechanism where

there are two keys, a public key and a private key, commonly referred to as a key pair. The

public key is used to encrypt, and the private key is used to decrypt as shown in the image

below. Compromise, or exposure of the private key means that anyone in possession of the

private key will be able to decrypt messages intended for the private key holder. Asymmetric

encryption is commonly referred by the term public key cryptography.


Encrypting “Hello!” with a public key provided by the server to create an encrypted message,
“y6uW$l”, which is then decrypted with the server’s private key back to “Hello!”.

Public Key Signing

Public key signing is known as a digital signature. The process of signing a digital message is

meant to guarantee the integrity of the message itself. A signature is generated by using a
private key against the data to be signed (or usually a hash thereof). This signature is then sent

along with the message where the receiving party will verify the signature by using the public

key that corresponds to the private key that signed the original message. If the signatures

match, then it is safe to assume that the data that was signed by the private key has not been

changed.

The below image illustrates a bank transaction request from Alice, wishing to send $100 from

account ‘558877’ to account ‘998321’. This message is then signed using Alice’s private key to

generate a signature. The signature and the message are then sent to a bank. The bank verifies

the signature by using Alice’s public key. If the signature verification succeeds, then it is safe

to commit the transaction. If the signature fails then the message must be rejected since it was

corrupted or tampered with by a malicious actor (for example someone could have changed

the destination account, the amount or both).


Alice sending a message (transaction) to her bank indicating she wishes to transfer funds from
one account to another. She then signs this message with a private key and sends the message
and the signature to the bank. The bank uses Alice’s’ public key.

Public key signing is one of the main fundamental features utilized by blockchain

implementations since it traces ownership of messages used to commit transactions to the

blockchain.

Hash Function

A hash function takes data as an input and creates an output, a digest, that was derived in a

deterministic way. The input data can be of an arbitrary length up to a pre-defined limit and

the hash function output is typically a fixed size. SHA1 for example takes data of size up to 264
bits in length and creates a message digest with a fixed size of 20 bytes (160 bits).

For example, SHA1 of `abc123` produces a digest of:

`6367c48dd193d56ea7b0baad25b19455e529f5ee`
The digest should be indistinguishable from random data; therefore, the digest should not

provide any clues as to any information regarding the source data provided to the hashing

algorithm.

Proof of Work(PoW)

Proof of Work(PoW) is the original consensus algorithm in a blockchain network. The algorithm is
used to confirm the transaction and creates a new block to the chain. In this algorithm, minors (a
group of people) compete against each other to complete the transaction on the network. The process
of competing against each other is called mining. As soon as miners successfully created a valid block,
he gets rewarded. The most famous application of Proof of Work(PoW) is Bitcoin.

Producing proof of work can be a random process with low probability. In this, a lot of trial and error is
required before a valid proof of work is generated. The main working principle of proof of work is a
mathematical puzzle which can easily prove the solution. Proof of work can be implemented in
a blockchain

by the Hashcash proof of work system.

In the below image, you can see that this block is composed of a block number, data field,
cryptographic hash associated with it and a nonce. The nonce is responsible for making the block valid.

In the puzzle game, bitcoin

software creates a challenge, and there is a game begins. This game involves all miners
competing against each other to solve the challenges, and this challenge will take
approximately 10 minutes to be completed. Every single miner starts trying to find the
solution to that one Nonce that will satisfy the hash for the block. At some specific
point, one of those miners in the global community with higher speed and great
hardware specs will solve the cryptography challenge and be the winner of the game.
Now, the rest of the community will start verifying that block which is mined by the
winner. If the nonce is correct, it will end up with the new block that will be added to
the blockchain. The concept of generating a block provides a clear explanation of proof
of work(PoW).
s

You might also like