Blockchain - Unit I - Chapter 1
Blockchain - Unit I - Chapter 1
Unit I
Chapter 1
With the invention of Bitcoin in 2008, the world was introduced to a new
concept, which is now likely to revolutionize the whole of society. It is
something that promises to have an impact on every industry, including but
not limited to the financial sector, government, media, law, and arts. Some
describe blockchain as a revolution, whereas another school of thought
believes that it is going to be more evolutionary, and it will take many years
before any practical benefits of blockchain reach fruition. This thinking is
correct to some extent, but in my opinion, the revolution has already begun.
Many prominent organizations all around the world are already
writing proofs of concept using blockchain technology, as its disruptive
potential has now been fully recognized. However, some organizations are
still in the preliminary exploration stage, though they are expected to
progress more quickly as the technology matures. It is a technology that has
an impact on current technologies too and possesses the ability to change
them at a fundamental level.
If we look at the last few years, we notice that in 2013 some ideas
started to emerge that suggested usage of blockchain in other areas than
cryptocurrencies. Around that time the primary usage of blockchain was
cryptocurrencies, and many new coins emerged during that time. The
following graph shows a broad-spectrum outline of year wise progression and
adaption trend of blockchain technology. Years shown on the x axis indicate
the range of time in which a specific phase of blockchain technology falls.
Each phase has a name which represents the action and is shown on the x
axis starting from the period of IDEAS & THOUGHTS to eventually
MATURITY & FURTHER
STANDARDIZATION. The y axis shows level of activity, involvement and
adoption of blockchain technology. The graph shows that eventually, roughly
around 2025 blockchain technology is expected to become mature with a
high number of users.
Distributed systems :
who lead different parts of the Byzantine army are planning to attack or retreat
from a city. The only way of communicating among them is via a messenger.
They need to agree to strike at the same time in order to win. The issue is that
one or more generals might be traitors who could send a misleading message.
Therefore, there is a need for a viable mechanism that allows for agreement
among the generals, even in the presence of the treacherous ones, so that the
attack can still take place at the same time. As an analogy to distributed
systems, the generals can be considered nodes, the traitors as Byzantine
(malicious) nodes, and the messenger can be thought of as a channel of
communication among the generals. This problem was solved in 1999 by Castro
and Liskov who presented the Practical Byzantine Fault Tolerance
(PBFT) algorithm, where consensus is reached after a certain number of
messages are received containing the same signed content.
Blockchain was introduced with the invention of Bitcoin in 2008. Its practical
implementation then occurred in 2009.
Electronic cash
Just as understanding the concepts of distributed systems is necessary in order to understand
blockchain technology, the idea of electronic cash is also essential to appreciate the first and
astonishingly successful application of blockchain: the bitcoin, or broadly cryptocurrencies.
Theoretical concepts in distributed systems such as consensus algorithms provided the basis of
the practical implementation of Proof of Work algorithms in bitcoin; moreover, ideas from
different electronic cash schemes also paved the way for the invention of cryptocurrencies,
specifically bitcoin.
In 2009 the first practical implementation of a cryptocurrency named bitcoin was introduced; for
the very first time it solved the problem of distributed consensus in a trustless network. It uses
public key cryptography with hashcash as PoW to provide a secure, controlled, and decentralized
method of minting digital currency. The key innovation is the idea of an ordered list of blocks
composed of transactions and cryptographically secured by the PoW mechanism.
Introduction to blockchain :
There are various definitions of blockchain; it depends on how you look at it. If you look at it
from a business perspective it can be defined in that context, if you look at it from a technical
perspective one can define it in view of that.
From a business point of view a blockchain can be defined as a platform whereby peers can
exchange values using transactions without the need for a central trusted arbitrator. This is a
powerful concept and once readers understand it they will realize the tsunamic potential of
blockchain technology. This allows blockchain to be a decentralized consensus mechanism
where no single authority is in charge of the database.
This is shown in a simple block diagram as follows. This is a general depiction of a block;
The structure of a block
Blockchain is a data structure; it is basically a linked list that uses hash pointers instead of
normal pointers. Hash pointers are used to point to the previous block.
The structure of a generic blockchain can be visualized with the help of the following diagram:
Generic elements of a
blockchain
ADDRESSES
Addresses are unique identifiers that are used in a transaction on the blockchain to denote
senders and recipients. An address is usually a public key or derived from a public key. While
addresses can be reused by the same user, addresses themselves are unique. In practice, however,
a single user may not use the same address again and generate a new one for each transaction.
This newly generated address will be unique. Bitcoin is in fact a pseudonymous system. End
users are usually not directly identifiable but some research in de-anonymizing bitcoin users
have shown that users can be identified successfully. As a good practice it is suggested that users
generate a new address for each transaction in order to avoid linking transactions to the common
owner, thus avoiding identification.
TRANSACTION :
BLOCK :
A block is composed of multiple transactions and some other elements such as the previous
block hash (hash pointer), timestamp, and nonce.
PEER-TO-PEER NETWORK :
As the name implies, this is a network topology whereby all peers can communicate with each
other and send and receive messages.
This element performs various operations on a transaction. Transaction scripts are predefined
sets of commands for nodes to transfer tokens from one address to another and perform various
other functions. Turing complete programming language is a desirable feature of blockchains;
however, the security of such languages is a key question and an area of important and ongoing
research.
VIRTUAL MACHINE :
This is an extension of a transaction script. A virtual machine allows Turing complete code to be
run on a blockchain (as smart contracts) whereas a transaction script can be limited in its
operation. Virtual machines are not available on all blockchains; however, various blockchains
use virtual machines to run programs, for example Ethereum Virtual Machine (EVM) and
Chain Virtual Machine (CVM).
STATE MACHINE :
A blockchain can be viewed as a state transition mechanism whereby a state is modified from its
initial form to the next and eventually to a final form as a result of a transaction execution and
validation process by nodes.
NODES :
A node in a blockchain network performs various functions depending on the role it takes. A
node can propose and validate transactions and perform mining to facilitate consensus and secure
the blockchain. This is done by following a consensus protocol. (Most commonly this is PoW.)
Nodes can also perform other functions such as simple payment verification (lightweight nodes),
validators, and many others functions depending on the type of the blockchain used and the role
assigned to the node.
SMART CONTRACTS :
certain conditions are met. The smart contract feature is not available in all blockchains but is
now becoming a very desirable feature due to the flexibility and power it provides to the
blockchain applications.
Features of a blockchain :
DISTRIBUTED CONSENSUS :
TRANSACTION VERIFICATION :
Any transactions posted from nodes on the blockchain are verified based on a predetermined set
of rules and only valid transactions are selected for inclusion in a block.
PLATFORMS FOR SMART CONTRACTS :
A blockchain is a platform where programs can run that execute business logic on behalf of the
users. As explained earlier, not all blockchains have a mechanism to execute smart contracts;
however, this is now a very desirable feature.
Blockchain enables the transfer of value between its users via tokens. Tokens can be thought of
as a carrier of value.
GENERATING CRYPTOCURRENCY :
This is an optional feature depending on the type of blockchain used. A blockchain can generate
cryptocurrency as an incentive to its miners who validate the transactions and spend resources in
order to secure the blockchain.
SMART PROPERTY :
For the first time it is possible to link a digital or physical asset to the blockchain in an
irrevocable manner, such that it cannot be claimed by anyone else; you are in full control of your
asset and it cannot be double spent or double owned. Compare it with a digital music file, for
example, which can be copied many times without any control; on a blockchain, however, if you
own it no one else can claim it unless you decide to transfer it to someone. This feature has far
reaching implications especially in Digital Rights Management (DRM) and electronic cash
systems where double spend detection is a key requirement. The double spend problem was first
solved in bitcoin.
PROVIDER OF SECURITY :
Blockchain is based on proven cryptographic technology that ensures the integrity and
availability of data. Generally, confidentiality is not provided due to the requirements of
transparency. This has become a main barrier for its adaptability by financial institutions and
other industries that need privacy and confidentiality of transactions. As such it is being
researched very actively and there is already some good progress made. It could be argued that in
many situations confidentiality is not really needed and transparency is preferred instead. For
example, in bitcoin confidentiality is not really required; however, it is desirable in some
scenarios. Research in this area is very ripe and already major progress has been made towards
providing confidentiality and privacy on blockchain. A more recent example is Zcash, which will
be discussed in more detail in later chapters. Other security services such as nonrepudiation and
authentication are also provided by blockchain as all actions are secured by using private keys
and digital signatures.
IMMUTABILITY :
This is another key feature of blockchain: records once added onto the blockchain are
immutable. There is the possibility of rolling back the changes but this is considered almost
impossible to do as it will require an unaffordable amount of computing resources. For example,
in much desirable case of bitcoin if a malicious user wants to alter the previous blocks then it
would require computing the PoW again for all those blocks that have already been added to the
blockchain. This difficulty makes the records on a blockchain practically immutable.
UNIQUENESS :
This feature of blockchain ensures that every transaction is unique and has not been spent
already. This is especially relevant in cryptocurrencies where much desirable detection and
avoidance of double spending are a key requirement.
SMART CONTRACTS :
Blockchain provides a platform to run smart contracts. These are automated autonomous
programs that reside on the blockchain and encapsulate business logic and code in order to
execute a required function when certain conditions are met. This is indeed a revolutionary
feature of blockchain as it allows flexibility, programmability, and much desirable control of
actions that users of blockchain need to perform according to their specific
business requirements.
BLOCKCHAIN 1.0
This was introduced with the invention of bitcoin and is basically used for cryptocurrencies.
Also, as bitcoin was the first implementation of cryptocurrencies it makes sense to categorize
Generation 1 of blockchain technology to only include cryptographic currencies. All alternative
coins and bitcoin fall into this category. This includes core applications such as payments and
applications.
BLOCKCHAIN 2.0
Generation 2.0 blockchains are used by financial services and contracts are introduced in this
generation. This includes various financial assets, for example derivatives, options, swaps, and
bonds. Applications that are beyond currency, finance, and markets are included at this tier.
BLOCKCHAIN 3.0
Generation 3 blockchains are used to implement applications beyond the financial services
industry and are used in more general-purpose industries such as government, health, media, the
arts, and justice.
GENERATION X (BLOCKCHAIN X)
This is a vision of blockchain singularity where one day we will have a public blockchain service
available that anyone can use just like the Google search engine. It will provide services in all
realms of society. This is a public open distributed ledger with general-purpose rational agents
(Machina Economicus) running on blockchain, making decisions and interacting with other
intelligent autonomous agents on behalf of humans and regulated by code instead of law or paper
contracts.
Types of blockchain :
Based on the way blockchain has evolved over the last few years, it can be divided into multiple
types with distinct but sometimes partly overlapping attributes.
Public blockchains :
As the name suggests, these blockchains are open to the public and anyone can participate as a
node in the decision-making process. Users may or may not be rewarded for their participation.
These ledgers are not owned by anyone and are publicly open for anyone to participate in. All
users of the permission-less ledger maintain a copy of the ledger on their local nodes and use a
distributed consensus mechanism in order to reach a decision about the eventual state of the
ledger. These blockchains are also known as permission-less ledgers.
Private blockchains :
Private blockchains as the name implies are private and are open only to a consortium or group
of individuals or organizations that has decided to share the ledger among themselves.
Semi-private blockchains :
Here part of the blockchain is private and part of it is public. The private part is controlled by a
group of individuals whereas the public part is open for participation by anyone.
Sidechains :
More precisely known as pegged sidechains, this is a concept whereby coins can be moved from
one blockchain to another and moved back. Common uses include the creation of new altcoins
(alternative cryptocurrencies) whereby coins are burnt as a proof of adequate stake. There are
two types of sidechain. The example provided above for burning coins is applicable to a one-way
pegged sidechain. The second type is called a two-way pegged sidechain, which allows the
movement of coins from the main chain to the sidechain and back to the main chain when
required.
Permissioned ledger :
A permissioned ledger is a blockchain whereby the participants of the network are known and
already trusted. Permissioned ledgers do not need to use a distributed consensus mechanism,
instead an agreement protocol can be used to maintain a shared version of truth about the state of
the records on the blockchain. There is also no requirement for a permissioned blockchain to be
private as it can be a public blockchain but with regulated access control.
Distributed ledger :
As the name suggests, this ledger is distributed among its participants and spread across multiple
sites or organizations. This type can either be private or public. The key idea is that, unlike many
other blockchains, the records are stored contiguously instead of sorted into blocks. This concept
is used in Ripple.
Shared ledger ;
This is generic term that is used to describe any application or database that is shared by the
public or a consortium.
Fully private and proprietary blockchains :
These blockchains perhaps have no mainstream application as they deviate from the core idea of
decentralization in blockchain technology. Nonetheless in specific private settings within an
organization there might be a need to share data and provide some level of guarantee of the
authenticity of the data. These blockchains could be useful in that scenario. For example, for
collaboration and sharing data between various government departments.
Tokenized blockchains :
These blockchains are standard blockchains that generate cryptocurrency as a result of a
consensus process via mining or via initial distribution.
Tokenless blockchains :
These are probably not real blockchains because they lack the basic unit of transfer of value but
are still valuable in situations where there is no need to transfer value between nodes and only
sharing some data among various already trusted parties is required. In the next section, the idea
of consensus from a blockchain perspective will be discussed. Consensus is the backbone of a
blockchain and provides decentralization of control as a result through an optional process
known as mining. The choice of consensus algorithm is also governed by the type of blockchain
in use. Not all consensus mechanisms are suitable for all types of blockchains. For example, in
public permissionless blockchains it would make sense to use PoW instead of some basic
agreement mechanism that perhaps is based on proof of authority. Therefore it is essential to
choose a consensus algorithm appropriately for a blockchain project.
Consensus in blockchain :
Consensus is basically a distributed computing conceptthat has been used in blockchain in order
to provide ameans of agreeing to a single version of truth by allpeers on the blockchain network.
Roughly, the following two categories of consensusmechanism exist:
.
PROOF OF WORK
This type of consensus mechanism relies on proof that enough computational resources have
been spent before proposing a value for acceptance by the network. This is used in bitcoin and
other cryptocurrencies. Currently, this is the only algorithm that has proven
astonishingly successful against Sybil attacks.
PROOF OF STAKE
This algorithm works on the idea that a node or user has enough stake in the system; for example
the user has invested enough in the system so that any malicious attempt would outweigh the
benefits of performing an attack on the system. This idea was first introduced by Peercoin and is
going to be used in the Ethereum blockchain. Another important concept in Proof of Stake
(PoS) is coin age, which is a derived from the amount of time and the number of coins that have
not been spent. In this model, the chances of proposing and signing the next block increase with
the coin age.
DELEGATED PROOF OF STAKE
Delegated Proof of Stake (DPOS) is an innovation over standard PoS whereby each node that
has stake in the system can delegate the validation of a transaction to other nodes by voting. This
is used in the bitshares blockchain.
PROOF OF ELAPSED TIME
Introduced by Intel, it uses Trusted Execution Environment (TEE) to provide randomness and
safety in the leader election process via a guaranteed wait time. It requires the Intel SGX
(Software Guard Extensions) processor in order to provide the security guarantee and for it to
be secure.
DEPOSIT-BASED CONSENSUS
Nodes that wish to participate on the network have to put in a security deposit before they can
propose a block.
PROOF OF IMPORTANCE
This idea is important and different from Proof of Stake. Proof of importance not only relies on
how much stake a user has in the system but it also monitors the usage and movement of tokens
by the user to establish a level of trust and importance. This is used in Nemcoin.
FEDERATED CONSENSUS OR FEDERATED BYZANTINE CONSENSUS
Used in the stellar consensus protocol, nodes in this protocol keep a group of publicly trusted
peers and propagates only those transactions that have been validated by the majority of trusted
nodes.
REPUTATION-BASED MECHANISMS
As the name suggests, a leader is elected on the basis of the reputation it has built over time on
the network. This can be based on the voting from other members.
PRACTICAL BYZANTINE FAULT TOLERANCE
Practical Byzantine Fault Tolerance (PBFT) achieves state machine replication, which
provides tolerance against Byzantine nodes. Various other protocols, including but are not
limited to PBFT, PAXOS, RAFT, and
Federated Byzantine Agreement (FBA), are also being used or have been proposed for use in
many different implementations of distributed systems and blockchains.
CAP theorem and blockchain :
Strangely, it seems that the CAP theorem is violated in blockchain, and especially in the most
successful implementation: bitcoin, but this is not the case. In blockchains consistency is
sacrificed in favor of availability and partition tolerance. In this scenario, Consistency (C) on the
blockchain is not achieved simultaneously with Partition tolerance (P) and Availability (A),
but it is achieved over time. This is called eventual consistency, where consistency is achieved as
a result of validation from multiple nodes over time. For this purpose, the concept of mining was
introduced in bitcoin; this is a process that facilitates the achievement of consensus by using a
consensus algorithm called PoW. At a higher level, mining can be defined as a process that is
used to add more blocks to the blockchain.
As with any technology there are challenges that need to be addressed in order to make a system
more robust, useful, and accessible. Blockchain technology is no exception; in fact a lot of effort
is being made in Academia and Industry to overcome the challenges posed by blockchain
technology. A selection of the most sensitive challenges are presented as follows:
Scalability
Adaptability
Regulation
Relatively immature technology
Privacy