UNIT 2 Consensus Algorithms
UNIT 2 Consensus Algorithms
UNIT 2
Verifiable: Everyone can check the validity of information because each node
maintains a copy of the transactions.
Permanent: Once a transaction is done, it is persistent and can’t be altered.
Contents of a Block
Blockchain starts with a block called genesis block. Each block stores the following
information in it:
Time stamp: The time when that particular block was created.
Hash: Numeric value that uniquely identifies data just like our fingerprints.
Previous hash: Hash value of the previous block. For genesis block, this value is 0.
Nonce: It is a number used to find a valid hash. To generate this number, the
processing power is used.
1
SITB3011 BLOCKCHAIN TECHNLOGIES – UNIT 2
Mechanism of Blockchain
• Any small change in the data value can affect the hash value. Hence, affecting
• All the replicas need to be updated with the last mined block.
2
SITB3011 BLOCKCHAIN TECHNLOGIES – UNIT 2
Block header
6. the nonce
• The version number of the software: The software version number does not
matter in most cases. However, a miner with a particular version number can signal
which protocol decisions he supports.
• The hash of the previous block: The hash of the previous block is, so to speak,
the chain of blockchains. Because the hash of the previous block is contained in
the hash of the new block, the blocks of the blockchain all build on each other.
Without this component, there would be no connection and chronology between
each block.
• The root hash of the Merkle tree: All transactions contained in a block can be
aggregated in a hash. This is the root hash of the Merkle tree.
• The time in seconds since 1970–01–01 T00: 00 UTC: A timestamp in the block
itself. The time is given in seconds since 1.1.1970.
• The goal of the current difficulty: The goal indicates how small the new hash
must be to claim validity. In other words, every hash has a size in bits. The lower
the goal in bits is, the harder it is to find a matching hash. A hash with many zeros
at the beginning is smaller than a hash without zeros. Find out more about the
difficulty of the proof of work.
3
SITB3011 BLOCKCHAIN TECHNLOGIES – UNIT 2
• The Nonce: The nonce is the variable incremented by the proof of work. In this
way, the miner guesses a valid hash, a hash that is smaller than the target.
The six components form the block header. The block header plays a
fundamental role in Bitcoin because it connects all blocks together. You can
imagine it like the cockpit of a truck. Here are the important papers with which the
truck comes through the controls of the network.
Block Body
The block body is conceivable as the loading space of a truck. It contains all
transactions that are confirmed with the block.
The variable is the nonce. A nonce is a number raised by one. Then the
miner hashes the data and checks if the data results in a hash that is below the
searched target value. If the hash value is greater than the target, the miner repeats
the process; So it increases the nonce by one, hashes and checks again. It repeats
this until it finds a hash below the target, or it gets another block from another
networker whose hash is below the target. Then takes this new block and uses it as
4
the basis for the next block (using the new hash as the “hash of the previous block”).
The special feature of this process is that the special hash can only be found by
guessing. This rate costs computing power and therefore energy. A look at the special
hash is enough to see that it is special because it begins with zeros.
000000000000000000094bfa4edb1245c347e42452e4418e9fe5a1d24e335b16
5
S&P requirements Corresponding S&P Corresponding S&P
Supported in bitcoin techniques techniques
S&P properties
Resistance to
Prevention of Signature and
double-spending
double-spending verification
attacks
Public key as
Anonymity Pseudonymity
pseudonyms
Mitigation Methods
• Performing Static Analysis testing (SAST) - analyze the source code to identify
security loopholes.
• Performing Dynamic Analysis testing (DAST) eliminate vulnerabilities during
software development
6
Figure 3.19 bitcoin mining process
Public key cryptography uses a pair of a public key and a private key to perform
different tasks. Public keys are widely distributed, while private keys are kept secret. Using a
person’s public key, it is possible to encrypt a message so that only the person with the private
key can decrypt and read it. Using a private key, a digital signature can be created so that anyone
with the corresponding public key can verify that the message was created by the ownerof the
private key and was not modified since.
7
Figure 3.21 Digital signature flow diagram
Public-key algorithms are asymmetric algorithms and, therefore, are based on the use of two
different keys, instead of just one. In public-key cryptography, the two keys are called the
private key and the public key
Private key: This key must be know only by its owner.
Public key: This key is known to everyone (it is public)
Relation between both keys: What one key encrypts, the other one decrypts, and vice versa.
That means that if you encrypt something with my public key (which you would know, because
it's public :-), I would need my private key to decrypt the message.
• In a basic secure conversation using public-key cryptography, the sender encrypts the
message using the receiver's public key.
• Remember that this key is known to everyone. The encrypted message is sent to the
receiving end, who will decrypt the message with his private key.
8
Only the receiver can decrypt the message because no one else has the private key.
Also, notice how the encryption algorithm is the same at both ends: what is encrypted
with one key is decrypted with the other key using the same algorithm.
9
Figure 3.22 public-key cryptography
Another important advantage is that, unlike symmetric algorithms, public-key systems
can guarantee integrity and authentication, not only privacy. The basic communication seen
above only guarantees privacy. We will shortly see how integrity and authentication fit into
public-key systems. The main disadvantage of using public-key systems is that they are not as
fast as symmetric algorithms.
Digital signatures: Integrity in public-key systems
Integrity is guaranteed in public-key systems by using digital signatures.
A digital signature is a piece of data which is attached to a message and which can be used to
find out if the message was tampered with during the conversation (e.g. through the
intervention of a malicious user)
10
and (2) Even the slightest change in the message produces a different digest. The message
digest is generated using a set of hashing algorithms.
The message digest is encrypted using the sender's private key. The resulting encrypted
message digest is the digital signature. The digital signature is attached to the message,
and sent to the receiver. The receiver then does the following:
Using the sender's public key, decrypts the digital signature to obtain the message
digestgenerated by the sender. Uses the same message digest algorithm used by the sender
to generatea message digest of the received message. Compares both message digests (the
one sent by thesender as a digital signature, and the one generated by the receiver). If they
are not exactly thesame, the message has been tampered with by a third party. We can be
sure that the digital signature was sent by the sender (and not by a malicious user) because
only the sender's publickey can decrypt the digital signature (which was encrypted by the
sender's private key; remember that what one key encrypts, the other one decrypts, and vice
versa). If decrypting using the public key renders a faulty message digest, this means that
either the message or themessage digest are not exactly what the sender sent.
Using public-key cryptography in this manner ensures integrity, because we have a
wayof knowing if the message we received is exactly what was sent by the sender. However,
notice how the above example guarantees only integrity. The message itself is sent
unencrypted. Thisis not necessarily a bad thing: in some cases we might not be interested
in keeping the data private, we simply want to make sure it isn't tampered with. To add
privacy to this conversation,we would simply need to encrypt the message as explained in
the first diagram.
Authentication in public-key systems
The above example does guarantee, to a certain extent, the authenticity of the
sender. Since only the sender's public key can decrypt the digital signature (encrypted with
the sender'sprivate key). However, the only thing this guarantees is that whoever sent the
message has theprivate key corresponding to the public key we used to decrypt the digital
signature. Althoughthis public key might have been advertised as belonging to the sender,
how can we be absolutelycertain? Maybe the sender isn't really who he claims to be, but just
someone impersonating thesender. Some security scenarios might consider that the 'weak
authentication' shown in the previous example is sufficient. However, other scenarios
might require that there is absolutelyno doubt about a user's identity. This is achieved with
digital certificates, which are explainedin the next page.
11
2.2 DISTRIBUTED CONSENSUS
Consensus is the process by which peers agree to the addition of next block
in the block chain. Distributed Consensus ensures that different nodes in the
network see the same data at nearly the same point of time. Hence in case of any
failure, the system can still provide a service as the data is decentralised. To
maintain anonymity in this large network, the permission less protocol is used
where you don’t need to record your identity while participating in the consensus.
Consensus Algorithms
only because of the presence of the consensus protocol which is a core part of any
Blockchain network.
Now, we will discuss various consensus algorithms and how they work.
The idea for Proof of Work (PoW) was first published in 1993 by Cynthia
12
Dwork and Moni Naor and was later applied by Satoshi Nakamoto in the Bitcoin
paper in 2008. Proof of Work consensus is the mechanism of choice for the
majority of cryptocurrencies currently in circulation. The term “proof of work”
was first used by Markus Jakobsson and Ari Juels in a publication in 1999.
All the transactions in the new block are then validated and the new block is
then added to the blockchain. Note that, the block will get added to the chain
which has the longest block height (see blockchain forks to understand how
multiple chains can exist at a point of time). Miners (special computers on the
13
new block to the last block in the valid blockchain. When a miner finally finds the
right solution, the node broadcasts it to the whole network at the same time,
receiving a cryptocurrency prize (the reward) provided by the PoW protocol. At
the time of writing this article, mining a block in the bitcoin network gives the
winning miner 12.5 bitcoins. The amount of bitcoins won halves every four years
or so (thats how the bitcoin network is designed). So, the next deduction in the
amount of bitcoin is due at around 2020-21(with the current rate and growth).
With more miners comes the inevitability of the time it takes to mine the
new block getting shorter. This means that the new blocks are found faster. In
order to consistently find 1, block every 10 minutes (That is the amount of time
that the bitcoin developers think is necessary for a steady and diminishing flow of
new coins until the maximum number of 21 million is reached (expected some
time with the current rate in around 2140)), the Bitcoin network regularly changes
the difficulty level of mining a new block.
The fact that Block GFG1 is connected to Block GFG2 through its hash
number is important. The significance lies in the fact that this ‘hash number’
connects new block to the last block in the valid blockchain. If, on the other hand,
the Block GFG1 Hash number on Block GFG2 had a different hash number than
Block GFG1 they would not match up, and Block GFG2 would not be verified.
First block in the blockchain is called the Genesis Block and has no Prev Block Hash value.
Changing a block (which can only be done by making a new block containing the
14
same predecessor) requires regenerating all successors and redoing the work they
contain
Bitcoin uses the Hashcash Proof of Work system as the mining basis. The ‘hard
mathematical problem’ can be written in an abstract way like below:
Given data A, find a number x such as that the hash of x appended to A results is a
number less than B.
The miners bundle up a group of transactions into a block and try to mine.
To mine it, a hard mathematical problem has to be solved. This problem is called
the proof of work problem which has to be solved to show that the miner has done
some work in finding out the solution to the problem and hence the mined block
must be valid. The answer to the problem needs to be a lower number than the
hash of the block for it to be accepted, known as the ‘target hash’. A target hash is
a number that the header of a hashed block must be equal to or less than for a new
block, along with the reward, to be awarded to a miner. The lower a target is, the
more difficult it is to generate a block.
15
Features of Proof of Work system:
There are mainly two features that have contributed to the wide popularity of this consensus
protocol and they are:
\The Proof-of-Work consensus mechanism has some issues which are as follows:
• The 51% risk: If a controlling entity owns 51% or more than 51% of nodes in
the network, the entity can corrupt the blockchain by gaining the majority of the
network.
• Time consuming: Miners have to check over many nonce values to find the right
solution to the puzzle that must be solved to mine the block, which is a time-
consuming process.
• Resource consumption: Miners consume high amounts of computing power in
order to find the solution to the hard mathematical puzzle. It leads to a waste of
precious resources (money, energy, space, hardware). It is expected that the
0.3% of the world’s electricity will be spent to verify transactions by the end of
2018.
• Transaction confirmation takes about 10–60 minutes. So, it is not an
instantaneous transaction; because it takes some time to mine the transaction
and add it to the blockchain thus committing the transaction.
• Litecoin
• Ethereum
• Monero coin
• Dogecoin
Need of Proof-of-Stake:
Proof-of-Stake:
• Coin-age based selection: The algorithm tracks the time every validator
candidate node stays a validator. The older the node becomes, the higher the
chances of it becoming the new validator.
17
A typical PoS based mechanism workflow:
1. Nodes make transactions. The PoS algorithm puts all these transactions in a
pool.
2. All the nodes contending to become validator for the next block raise a stake.
This stake is combined with other factors like ‘coin-age’ or ‘randomized
block selection’ to select the validator.
3. The validator verifies all the transactions and publishes the block. His stake
still remains locked and the forging reward is also not granted yet. This is so
that the nodes on the network can ‘OK’ the new block.
4. If the block is ‘OK’-ed, the validator gets the stake back and the reward too.
If the algorithm is using a coin-age based mechanism to select validators,
the validator for the current block’s has its coin-age reset to 0. This puts him
in a low-priority for the next validator election.
5. If the block is not verified by other nodes on the network, the validator loses
its stake and is marked as ‘bad’ by the algorithm. The process again starts
from step 1 to forge the new block.
Features:
There is only a finite number of coins that always circulate in the network.
There is no existence of bringing new coins into existence (as in by mining in case
of bitcoin and other PoW based systems). Note that the network starts with a finite
number of coins or
‘Initially starts with PoW, then shifts to PoS’ in some cases. This initiation with PoW is
meant to bring coins/cryptocurrency in the network.
18
Impracticality of the 51% attack:
To conduct a 51% attack, the attacker will have to own 51% of the total
cryptocurrency in the network which is quite expensive. This deems doing the
attack too tedious, expensive and not so profitable. There will occur problems
when amassing such a share of total cryptocurrency as there might not be so much
currency to buy, also that buying more and more coins/value will become more
expensive. Also validating wrong transactions will cause the validator to lose its
stake, thereby being reward-negative.
Advantages of PoS:
• Energy-efficient: As all the nodes are not competing against each other to
attach a new block to the blockchain, energy is saved. Also, no problem has to
be solved (as in case of Proof-of-Work system) thus saving the energy.
• Decentralization: In blockchains like Bitcoin (Proof of Work system to achieve
distributed consensus), an extra incentive of exponential rewards are in place to
join a mining pool leading to a more centralized nature of blockchain. In the
case of a Proof-of-Stake based system (like Peercoin), rewards are
proportional(linear) to the amount of stake. So, it provides absolutely no extra
edge to join a mining pool; thus, promoting decentralization.
• Security: A person attempting to attack a network will have to own 51% of the
stakes (pretty expensive). This leads to a secure network.
Weakness of a PoS mechanism:
• New technology: PoS is still relatively new. Research is ongoing to find flaws,
fix them and making it viable for a live network with actual currency
transactions.
19
• The ‘Nothing at Stake’ problem: This problem describes the little to no
disadvantage to the nodes in case they support multiple blockchains in the event
of a blockchain split (blockchain forking). In the worst-case scenario, every fork
will lead to multiple blockchains and validators will work and the nodes in the
network will never achieve consensus.
• Peercoin
• Nxt
Variants of Proof-of-Stake:
• Regular Proof-of-Stake
• Delegated Proof-of-Stake
• Leased Proof-of-Stake
Proofs of space are very similar to proofs of work (PoW), except that
instead of computation, storage is used to earn cryptocurrency. Proof-of-space is
different from memory-hard functions in that the bottleneck is not in the number of
memory access events, but in the amount of memory required. the release of
Bitcoin, alternatives to its PoW mining mechanism were researched and PoS was
studied in the context of cryptocurrencies. Proofs of space are seen as a fairer and
greener alternative by blockchain enthusiasts due to the general-purpose nature of
20
storage and the lower energy cost required by storage, but have been criticized for
increasing demand for storage. Several theoretical and practical implementations of
PoS have been released and discussed, such as SpaceMint, Burstcoin, and Chia.
Concept Description
The verifier then asks the prover to open several random locations in the commitment.
Proof of Authority
In blockchain platforms, consensus mechanisms can be divided into permissionless (eg., Ethereum, Bitcoin)
and permissioned (eg Hyperledger, Ethereum Private). Unlike permissionless blockchain where anyone can
become node, in permissioned blockchain all nodes are pre-selected. This allows to use consensus types with
high scalability and bandwidth. One of these consensus types is Proof-of-Authority (PoA) consensus which
provides high performance and fault tolerance. Term was proposed in 2017 by co-founder of Ethereum and
Parity Technologies Gavin Wood.
Working of PoA :
• In PoA, rights to generate new blocks are awarded to nodes that have proven their authority to do so.
These nodes are referred to as “Validators” and they run software allowing them to put transactions in
blocks. Process is automated and does not require validators to be constantly monitoring their
computers but does require maintaining the computer uncompromised. PoA is suited for both private
networks and public networks, like POA Network, where trust is distributed.
• PoA consensus algorithm leverages value of identities, which means that block validators are not
staking coins but their own reputation instead. PoA is secured by trust on the identities selected.
1. PoA mechanism makes it possible to defend against this attack because network nodes are
21
pre-authenticated, block generation rights can be granted only to nodes that can withstand DoS
attacks.
51%attack:
In PoA consensus, 51% attack requires an attacker to obtain control over 51% of network nodes. This is
different from 51% attack for the Proof-of-Work consensus types where an attacker needs to obtain 51% of
network computational power. Obtaining control of the nodes in permissioned blockchain network is much
harder than obtaining computational power.
With PoA, individuals earn right to become validators, so there is an incentive to retain position that
they have gained. Validators are incentivized with reputation which lets them retain their authority as
a node. PoA only allows non-consecutive block approval from any one validator, meaning that the
risk of serious damage is centralized to the authority node.
• PoA consensus may vary according to different implementation but generally they are applied
through the following conditions :
• A candidate must be willing to invest money and put his reputation at stake. A tough process
reduces risks of selecting questionable validators and incentivize long-term commitment to
the blockchain.
• Identity of validators must be verified to maintain integrity of blockchain. Some sort of process
should be their to select honest validators.
• High risk tolerance as long as 51% of the nodes are not acting maliciously.
• Interval of time at which new blocks are generated is predictable. For PoW and PoS
consensuses, this time varies.
• Far more sustainable than algorithms like Proof of Work which require computational power.
Limitations :
• PoA is not decentralized but is just an effort to make centralized systems more efficient.
• PoA validators are visible to anyone. Knowing validators identities could potentially lead to
third-party manipulation.
• PoA consensus algorithm may be applied in variety of scenarios and is deemed great option
for logistical applications such as supply chains.
• Proof of Authority model enables companies to maintain their privacy while availing benefits
of blockchain technology. Microsoft Azure is another example where PoA is being
22
implemented. Azure platform provides solutions for private networks, with system that does
not require native currency like ether ‘gas’ on Ethereum, since there is no need for mining.
Azure nodes are pre-selected.
As we know, the idea of Proof of Work was by Cynthia Dwork and Moni Naor. This
permissionless consensus uses double SHA 256 which makes it secure from hackers.
With proof of work, miners compete with each other to complete the transaction and
get the bounty. Even it has many advantages like solving the double-spending
problem and very difficult to tamper it, but it is not impossible to tamper if the hacker
has high computational power.
There are two major attacks by which PoW based systems can crash.They are :
1. Sybil Attacks
Sybil Attacks:
In Sybil attacks, the attacker attempts to fill the network with the clients under
its control. When this thing happens, the attacker can actually control or get a
monopoly over the network and these clients can do different kinds of actions based
on the instruction from the attacker. They can refuse to relay the valid blocks or they
can only relay the blocks which are generated by the attackers and those blocks can
lead to double-spending.
In Simple language, the attacker can include multiple nodes in the network who can
collectively compromise the Proof of Work mechanism.
Solution –
To prevent Sybil attacks, we have to diversify the connections i.e allowing outbound connection to
one IP per / 16 IP address. So, by diversifying the network it is expected that if the attacker
generates multiple false miners the attacker will generate them within the same clustered network
23
or subnet. Denial of Service (DOS) Attacks:
In this attack, the attacker sends a lot of data to a particular node so that node
will not able to process normal Bitcoin transactions. As a result, the metabolism of the
mining procedure will get delayed which wastes the power for computation and in that
meantime, the attacker can also send new nodes to the network resulting in a
monopoly which is nothing but a Sybil attack.
Solution –
To prevent DOS attacks there are several rules bitcoin have which are:
• Plus, they can’t willingly change the price of the mangoes. If one person sells a mango
for $10 then the buyer can simply buy it from someone who is selling mangoes for $5.
Monopoly
• A monopoly is the polar opposite of a perfect competition.
25
• This is a market place which is dominated by one corporation and the barriers to entry
are so high that nobody else can enter it.
• De beers diamonds are a great example of a monopolistic market. Monopolistic
Competition
• This is a marketplace which has a lot of sellers and very low barriers. Their products
are similar but not really identical.
• Think of the pizza delivery service. Now, dominoes and pizza hut have the same
product with subtle differences.
• Obviously one can slightly price their product a little higher based on factors like
customer preferences. However, if dominoes price their pizzas way too high, then
people will simply go over to pizza hut.
• Consequently, if dominoes and pizza hut both start overcharging, since the barriers to
entry is so low, another player can come in and take all the customers. Oligopoly
• Oligopolies are market places which are dominated by a few markets and the barriers
to entry are high.
• One of the best examples of an oligopoly is the smartphone market. The market is
dominated by few number of companies like Samsung, Apple, and Huawei. Much like
monopolistic competitions, the products are similar but not identical.
• If tomorrow, Apple decides to price their iPhones at $4000, apart from the Apple
fanatics, most will simply opt for an Android phone.
• Obviously, they can always get together and decide as a group to mutually increase the
prices, but this is called “collusion” and is illegal in many countries, including the
United States.
• So, when they can’t compete by changing prices, how can they get that edge over their
competitors? They do so by “non-price competition”, which means competing without
changing the price.
• How do they do that? They do so by changing the look and style of their products and
giving a unique experience. However, the most recognizable form of non-price
competition is advertising.
• Advertising is one of the most effective ways of showing unique qualities of your
products and to introduce new products.
• But then again, there is a problem. How many of the advertisements do you watch
actually stick? Chances are that you have been bombarded by tons of ads today itself,
26
how many of them do you actually remember? If you are a player in an oligopoly and you keep
blindly advertising, you are going to be spending a lot of money.
• As a result of that, in order to make up all that money, you are going to invariably have
to increase the price of your products.
• If that happens, your buyers are simply going to go to your competitors. So how do you
go about this? How do you advertise your products without losing out on your
customers?
• You will have to basically take decisions based on the actions that your competitors
will take. In order to do that, you will have to use Game Theory.
What is the Game theory?
Game theory is the study of strategic decision making. This is how many corporations
make decisions while keeping in mind the actions that their competitors will take. Game theory
was devised by John Van Nuemann and Osker Morgenstern in 1944 and was considered a
breakthrough in the study of oligopoly markets. Since then the game theory has found a life of
its own and has seen widespread implementations in various other technologies and fields.
A game theory model has at least 3 components:
Players: The decision makers. Eg. The managers in the firms. Strategies: The
decisions they want to take to further their companies.Payoff: Outcome of the
strategies.
In game theory, there are two types of games.
Zero sum game: It is a game in which the gain of one player comes at the expense of anotherplayer.
Non zero sum game: A game where the gain of one player doesn’t come at the expense of
another player. So, how does one apply game theory? Let’s go back to what we were discussing
again, should or shouldn’t a company advertise a particular aspect of their product. Suppose
there are two firms A and B.
Table 3.3 Pay-off matrix
The table that you see above is called a “payoff matrix”. The table basically reads like this:
27
If Firm A and B both decide to advertise then the payoff for both of them is 4 and three
respectively.
If Firm A doesn’t advertise and B decides to advertise, then the payoff is 2 and 5.
If Firm A advertises and B doesn’t advertise then the payoff is 5 and 1.
If both Firms A and B don’t advertise then the payoff is 3 and 2.
Firstly, let’s look at Firm B.
Case 1: If Firm A advertises
Then Firm B has a payoff of 3 if they advertise and one they don’t advertise. So,
obviously, their best payoff lies in advertising.
Case 2: If Firm A doesn’t advertise
Then Firm B has a payoff of 5 if they advertise and 2 if they don’t advertise. In thiscase
their best payoff lies in advertising.
Conclusion: Regardless of what Firm A does, Firm B should advertise.
Now, let’s look at Firm A.
Case 1: If Firm B advertises
The Firm A has a payoff of 4 if they advertise and 2 if they don’t advertise. So, once
again, their best payoff lies in advertising.
Case 2: If Firm B doesn’t advertise
In this case, Firm A has a payoff of 5 if they advertise and a payoff of 3 if they don’t
advertise. Once again, their best payoff lies in advertising.
Conclusion: Regardless of what Firm B does, Firm A’s best strategy lies in advertising.
So, in this example, for both Firm A and Firm B, their most stable state will be if they both
advertise, which is: For both Firm A and Firm B, this is their dominant strategy. A dominant
strategy is the best course of action for a player regardless of what the opponent does. In this
example, (4,3) is also the Nash Equilibrium.
28
Nash Equilibrium
• The Nash equilibrium is a solution to a game where each player chooses their optimal
strategy given the strategy was chosen by the other and they have nothing to gain by
shifting their strategy.
• This was formulated by John F Nash who was portrayed by Russell Crowe in the movie,
“A Beautiful Mind”.
• This has humongous implications in a distributed computer system like the blockchain.
In fact, the blockchain is “cheat-free” because the entire protocol is in a Nash
Equilibrium.
A block is a series of blocks which contains individual transactions in it. Each block
also contains the hash of the previous block and this, in turn, links each subsequent block to
the previous block making a chain. Hence the term, “blockchain.” This is a rough visual
representation of a blockchain.
29
Figure 3.25 Chain of blocks
Some terms:
• Genesis block: The first block of the blockchain is called a “genesis” block.
• Proof of work: The amount of computational work required to create the block.
• Parent block: The block that immediately precedes a block is the parent block of that
block. So in the diagram above, Block 50 is the parent block of Block 51.
• Every block in the blockchain has a scoring function. Score(genesis) = 0.
• Score(Block) = Score (parent block) + Proof of work
• The current state of the chain is the block with the highest score.
• In a system based on blockchain bitcoin there are two players:
• Users.
• Miners.
Users, in bitcoin, have only two functions available to them:
• Send coins.
• Receive coins.
• In order to do that they need two keys, the public, and the private key.
• What miners do is that they authenticate the transactions AND they do the process of
mining.
• Mining is how new blocks are discovered and added to the blockchain. Block Mining
• Through a series of computations, miners find a block and add it to the blockchain.In
Ethereum, adding the block gives the miner(s) a reward of 5 ether and In bitcoin, the
mining reward is 25 BTC (both as of writing).
• Miners have a lot of power in the blockchain system and if they do choose to cheat for
their own personal gain, they can cause havoc in the system.
• To mitigate that, the blockchain uses game theory mechanics to keep the system
bulletproof.
30
• In order to understand how game theory keeps the miners honest, let’s take a look at
another peer-to-peer system which has allowed its users to, time and again, get away
with cheating.
• Torrenting is one most popular peer to peer systems in the world.
• While using torrents, users have two roles: downloading and seeding.
• After downloading a file, they are supposed to share it the network via a method called
seeding.
• However, they get no compensation for seeding the said file and hence more often than
not they refuse to do so.
• Most torrent users are “cheats” because they do not seed their files.
• They can get away with cheating because the system doesn’t have a “punishment
model” the way blockchain does.
How can miners cheat? – Cryptocurrency Game Theory
• They can include an invalid transaction and give themselves extra coins.
• Add blocks randomly without worrying about Proof of work.
• Mine on top of invalid blocks to get more BTC.
• Mine on top of a sub-optimally scoring block.
• Let’s take an example. Consider the block below:
31
• Creates a new chain (fork) from block 50 and in the alternate block 51, he doesn’t do
the litecoin transaction.
• In the end, he comes out with his original 20 BTC and 500 new litecoins.
• What just happened here is called “double spending.” Obviously now miners can,
theoretically, mine on top of the new red chain and keep double spending and mining
extra bitcoins.
• As you can imagine, this can destroy the bitcoin system.
• The blockchain was designed in a way that it is a self-enforcing Nash Equilibrium.
The reason why that happens is that mining has a recursive punishment
system.
• If a miner creates an invalid block then others won’t mine on top of it because of a rule
that has been defined in blockchain mechanics.
• Any block that is mined on top of an invalid block becomes an invalid block.
• Using this rule, miners will simply ignore the invalid block and keep on mining on top
of the main chain aka the blue chain in the diagram.
• This similar logic stands for sub-optimally scoring block. Look at the diagram again.
• No miner will want to mine on Red Block 52 because the Blue Block 53 will have a
higher score than the red block.
• Both of these scenarios get mitigated because miners., as a group will choose the most
stable state aka the state with a Nash Equilibrium.
• Obviously, you can make all the miners mine on the red block and make it the new
blockchain.
• As the co-ordination game states, if a majority of the people in the group are not
changing their state, the minority will not have any incentive to stay in the new state.
• Seeing this, why will a miner spend all their computation power and risk ostracization
in a futile cause?
Why will users use the main chain instead of the other chain?
So, now that we have seen the reason WHY miners will prefer the blue chain…What
about the users? In the blockchain game, there are two players, miners, and users. Why will
users prefer the blue chain over the red chain? Once again, game theory mechanics come into
play. The first thing that you need to keep in mind is that cryptocurrency has value is because
32
the people give it value. So, why will a normal user assign a value to coins coming out of the
blue chain and not to the coins coming out of the red chain? The reason is simple. The main
chain is a Schelling point from the users perspective. They give it value because the main chain
seems natural and special to them.
Bounded Rationality: Another reason why users will value the main chain more is that they
are simply used to it. Like bounded rationality states, people will simply opt for the simplest
solution every time. Moving through a newer chain needlessly complicates things.
• Vitalik Buterin gave a great example of the Takeover problem and we are going to
expand on it. Suppose, someone makes a hypothetical smart contract for an activity.
The terms of the contract go like this:
• Any miner can join the activity by sending a very large deposit into the contract.
• The miners must send shares of the partially completed blocks that they have mined
into the contract and the contract verifies it and also verifies that you are a miner and
that you have sufficient hash power.
• Before 60% of the miners in the system join you can leave anytime you want.
• After 60% of the miners join, you will be bound to the contract until the 20 blocks have
been added to the hard fork chain aka the red chain.
• Yes, it is indeed very diabolical and you can see the problem that this attack can have.
• Not only will the new chain grow bigger and longer, since 60% of the entire miners are
bound contractually to this new chain this will quickly make the original older chain
aka the blue chain irrelevant. This will make double spends all over the place and the
value of the currency will fall fast.
33
Longest Chain Rule
• A blockchain is a list of blocks linked by hash values with each block containing a
batch of ordered transactions.
• To make all participants agree on the same chain of blocks, NC leverages two
components: the Proof-of-Work (PoW) mechanism and the longest chain rule (LCR).
• Each participant collects valid and unconfirmed transactions from the network, orders
and packs these transactions into a block.
• In addition, a valid block needs to contain a proof of work, i.e., its owner needs to find
a value of the nonce (i.e., a changeable data field) such that the hash value of this block
has required leading zeros.
• The length of leading zeros is also known as the mining difficulty, which can be tuned
by the system so that new blocks are mined every ten minutes on average.
• In reality, two new blocks might be mined around the same time, leading to a fork in
which two ‘‘child’’ blocks share a common ‘‘parent’’ block.
• To resolve such a fork, an honest miner always accepts the longest chain as the valid
one. See Fig. 1 for an illustration. Block B3 is a forking block, which will be abandoned
by the honest miners according to the longest chain rule.
• In Bitcoin, a block miner will receive a block reward (if its block is eventually included
in the longest chain) as well as transaction fees as another type of reward.
• In Bitcoin, the mining of blocks has two functionalities: (1) electing leaders (i.e., the
owners of valid blocks) by miners, and (2) ordering and verifying transactions.
• Transaction fee is used to incentivize miners to include transactions in their blocks.
• Therefore, the higher the transaction fee is, the more miners try to include the
transaction into the latest block.
• The results show that about 77.8% transactions have a quite small fee (less than
34
0.0001 BTC).
Selfish Mining
• NC is designed to fairly reward miners according to their contributions to the system
(i.e., miners’ revenue is proportional to their devoted computation power).
• the studies show that a selfish miner can gain more revenue than its fair share by
deviating from the protocol.
• This mining attack is called selfish mining. In this attack, a selfish miner can keep its
newly generated blocks secret, mine on top of these blocks, and create forks on purpose
when necessary.
35
• In particular, when some honest miner generates a new block, a selfish miner will
publish one secret block to match this honest block as a competition or publish two
blocks to override this honest block because honest miners follow LCR.
Forks
• The Nakamoto consensus does not guarantee that the blockchains of all miners are the
same at all points in time.
• Thus, some conflicting chains may form, known as forks.
• When a fork occurs, these blocks are usually created by different creators, and these
creators are in competition; thus, only the creator in the longest chain can win the
reward.
36
• In the Nakamoto consensus, miners only admit the blocks in the longest chain, and the
transactions in other forks are invalid.
• In addition, when the longest chains are not unique, miners usually follow the highest
block they received first.
The above figure shows an example of a blockchain with the Nakamoto consensus. In this
example, the longest chain is from the genesis block (A0) to the black leaf block (A8), and
other blocks in shorter forks are colored white. In this example, the miners follow block (A8).
Preventing Double-spending
Bitcoin Network
37
• Nodes express their acceptance by working on creating the next block in the
chain, using the hash of the accepted block as the previous hash.
Tie breaking
38
Maliciousness on the Internet encompasses identity theft, fraud, and network or system
intrusions. Blockchain can help in preventing frauds involving assets other than currency and
credit. Smart contracts used to ensure transacting parties comply with contracts, reducing
defaults by buyers or poor service by providers. blockchain technology can prevent several
types of malicious attacks and reduce many associated risks, it cannot eliminate all attacks.
Blockchain technology: unavoidable attacks The
51% Attack
• Occur when a single minor node that is having more computational resources than the
rest of the network nodes.
• In such a situation, this node dominates the verification and approval of transactions
and controls the content of a blockchain.
• As it possesses more than half (51%) of the network’s processing power, the dominant
node can outpace all other nodes.
• Thus, it can manipulate the blockchain, insert fraudulent transactions, double-spend
funds, or even steal an asset from others. Identity Theft
• Although blockchain can preserve anonymity and privacy, the security of assets
depends on safety of the private key, a form of digital identity.
• If one’s private key is acquired or stolen, no third party can recover it.
Illegal Activities
• Blockchain technology can become a venue for illegality.
• Crypto-currency that uses blockchain technology may also facilitate money laundering.
Using Detection Technologies
• blockchain technology prevents fraudulent behavior, it is not able to detect fraud by
itself.
• Implementing innovative techniques and methods that are needed to detect attacks.
• Use of machine learning and data-mining algorithms for creating new applications for
detecting fraud and intrusions in blockchain-based transactions.
• Implementation of techniques such as profiling, monitoring, and detecting behavioral
patterns based on people’s transaction histories.
• Development of supervised machine learning approaches that can help in detecting
outlier behaviors.
Establishing Identity In Blockchain Technology
• Loss of a key is equal to the loss of identity on the network.
39
• Solution : building an identity and reputation system using a blockchain that can record
“fingerprint” events.
• This can also track life events such as the opening of bank accounts, car purchases, etc.
• It is difficult to steal because it is unforgetable, publicly monitored, and time-stamped.
Mitigating Denial-of-Service (DDoS) Attacks
• A distributed denial-of-service attack occurs when a network is intentionally flooded
with unsustainable amounts of traffic or specific information that triggers a crash.
• These attacks are typically not aimed at acquiring personal information or holding a
system for ransom
• Attackers generally unleash such attacks simply to claim credit for the mayhem.
• The IoT is a primary reason why DDoS attacks were up 91% last year.
• BlockArmor – Leveraging blockchain technology to increase network size and make
DDoS attacks more difficult.
The CIA security triad model, composed of three areas;
(1) Confidentiality,
(2) Integrity
(3) Availability
• Authentication, Authorization and Audit (AAA), and Non Repudiation, fundamental
security aspects for protecting information and designing / managing new systems and
networks
Confidentiality
The property that sensitive information is not disclosed to unauthorized individuals,
entities, or processes.
• Network Access
• Data Access & Disclosure
Integrity
Integrity is defined as the “guarding against improper information modification or
destruction, and includes ensuring information non-repudiation and authenticity
Immutability
• The combination of sequential hashing and cryptography along with its decentralized
structure makes it very challenging for any party to tamper with it in contrast to a
standard database
• Right to be Forgotten
• Traceability
40
• Smart Contracts
• Data Quality
Availability
• Ensuring timely and reliable access to and use of information.
• No Single Point of Failure
• Operational Resilience
Redundancies in blockchain Network
In a blockchain network, for every node to be processed, it has to traverse and process every
intermediate node independently to reach the target node. Thus, the redundancy involved in
blockchain technology affects its performance.
41
• Scalability Is An Issue
• transactions are completed depending on the network congestion.
• Some Blockchain Solutions Consume Too Much Energy
• high energy consumption is what makes these complex mathematical problems.
• Blockchain Cannot Go Back — Data is Immutable
• He will be unable to remove its trace from the system when he doesn’t want it there.
• Blockchains are Sometimes Inefficient
• storage problems - ledger can easily cross 100’s of GBs
• Not Completely Secure
• 51% attack, Double-spending, DDoS’s attack:
Users Are Their Own Bank: Private Keys
Make sure that they do not share it with anyone else. If they fail to do so, their wallet
isin danger. Also, if they lose the private key, they will lose access to the wallet forever.
• Cost And Implementation Struggle
• Expertise Knowledge
• Maturity
o It is only a decade old and it requires time to mature.
• Interoperability
• Legacy Systems
if they want to adopt blockchain technology, they need to completely get rid of theirsystems
and change to blockchain technology
42