Blockchain in Depth

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 103

Building Blocks of

Blockchain

Infosys Blockchain Academy


The Blockchain Advantage
Distributed P2P network
Provenance tracking
which keeps the copies
in a heterogeneous
of the “true”
eco system transactions history

Immutable The Smart Contracts


Complicated and avoid conflicting or
time consuming double transactions and
Inter-org processes transactions occur
Programmable Encrypted
automatically.

Single data storage Blockchain Immutable and


vulnerable to hacks, irreversible transaction
leaks etc records secured with
Distributed Cryptography.
Transparent

The transaction data


Digital identity is stored in the blocks
and Data security Consensus
and are Shared in all
the nodes.

Expensive Trust between untrusted


Intermediaries parties in the network
required to achieved using
establish Trust Distributed Consensus
Blockchain: How Does It Work?

3
Immutable

Programmable Encrypted

Blockchain Transparency in Blockchain


Distributed Transparent

Consensus

4
Blockchain Explained
Alice and Bob want to play
Chess through chat
How does this work?

Transactions
• Alice sends Bob 1 e4
(Pawn to e4)
• Bob sends back 1 .e5 • First of all both needs to agree on the state of the board
(Pawn to e5) • Both know the starting positions of the board
• Alice sends 2 Nf3 • Both know the sequence of messages so far
(Kinght to f3) • So they can reconstruct the state of the board
• How does this work?
If we agree on Initial state + history = we agree on the Current State of the System
We don’t want a trusted arbiter of the state of the World
We want some level of decentralization – not a single point of failure or compromise
We want the functionality of a trusted arbiter …. Without needing a trusted arbiter
“He who controls the past , controls the future”
A Network view of Blockchain

Users / Nodes

Blockchain Applications (smart Contracts • Initial State of the system is agreed upon by
the participating nodes
State machine • The Transactions between nodes are
broadcasted and verified
Consensus
• The verified transactions are added to Block
Blocks
• The block is validated with Distributed
Transactions Consensus and added to the blockchain
• The New State of the system is agreed upon
by the participating nodes
P-2-P Network

The Internet

6
Typical Blockchain Transaction Flow
Transaction Requested Transaction Broadcasted Transaction Verified Transaction Added to Pool

Transaction
Block Verified New Block Added to Blockchain Transaction Completed
Added to Block
Blockchain Nodes

Initiates Transaction

Verifies Transaction

Creates and validates Blocks


Who runs the Distributed Network?
Simple Blockchain application/ Full copy of Blockchain capability for
client that can initiate transaction. Full copy of Blockchain &
verification.
Need not have the entire Capability of high hashing
Can initiate and verify transactions
Blockchain downloaded rate

Miner /
Node Light Node Full Node Validator node

User Developer Miner/ Validator


People
• Can create a new Block
End User Blockchain developer community • Relies on mining software and
Installing client and submit Responsible for designing the PoW/PoS
transactions protocol and implementing it into • Validate the blocks
software • Play an important role in governing the
system
Immutable

Programmable Encrypted

Blockchain
Cryptography in Blockchain
Distributed Transparent

Consensus

10
Security Mechanisms
Hash Function
• Three basic building blocks are used:
– Checksums/hash algorithms
• They are used to provide integrity
protection, can provide authentication

– Encryption 010
1100
010101
• It is used to provide confidentiality, can 110101

provide authentication and integrity


protection

– Digital signatures
• They are used to provide authentication,
integrity protection, and non-repudiation
Cryptographic functions used in Blockchain

Hash Functions PK Encryption Digital Signature

Initiation and Broadcasting of • Digital Signatures


Transaction • Private / Public Keys

Chaining of Transaction • Hash Functions


Hash Function

13
Hash Function 1/3
• A cryptographic hash function is a one-way function that converts input data of arbitrary length and
produces a fixed-length output.
• The output is usually termed “hash value” or “message digest.”
Hash Function
Message of Hash Value of
Arbitrary Length Fixed Length

SHA256 – 256 bits


SHA1 (Secure Hash Algorithm) MD5 (Message Digest Algorithm)
SHA384- 384 bits
produce a hash value of 160 bits produce a hash value of 128 bits
SHA512- 512bits
Hash Functions 2/3 - Length of output always the same
Digital Hash Value
Input Data
Fingerprint

Hash
16 MB pdf Function
contract

Hash One output of


2GB image
Function predetermined
fixed length

200 bytes log Hash


file entry Function
Hash Functions 3/3
One output of
One Input, Hash Value of specific
a string of Data predetermined
Function digit number fixed length
arbitrary
length

Hash
12345678 90 e807f1fc
Function
1. Defined range
Much difference 2. Determinstic
by small change 3. Discontinuous
4. Uniformity
5. Non-invertible
12345678 91 Hash 0f7e44a92
Function

One way
Encryption

17
Encryption Basics
• Encryption takes plain text and turns it into cipher text by using a key or a key pair
• The result is a meaningless message, unless you have a key
• http://atom.smasher.or/bgp

http://www.networkdls.com/articles/keylength.pdf http://ietf.org/rfc/rfc2828.txt
18
Symmetric Encryption
Shared Key Shared Key

Alice Bob

To To To
+++_% +++_%
&&x&x &&x&x
++ +-x ++ +-x
Bob Bob Bob
%&+= %&+=
Top Secret Top Secret Top Secret
Encryption
Algorithm Decryption
Input Plain Text Algorithm Output Plain Text
Encrypted Text

• Symmetric-key cryptography is also known as Secret-key cryptography


• In Symmetric-key encryption identical private keys are allocated to both sender and recipient.
• Need to exchange the shared key by both parities using a secured channel
• Robust to resist brute force attack
• Computationally easy to generate
• Can compromise the key, the vulnerability increases as the users having the same shared key increases
Symmetric Encryption Demo

20
Asymmetric Encryption
Encryption Key Decryption Key

Alice Bob

To To To
+++_% +++_%
&&x&x &&x&x
++ +-x ++ +-x
Bob Bob Bob
%&+= %&+=
Top Secret Top Secret Top Secret
Encryption
Algorithm Decryption
Input Plain Text Algorithm Output Plain Text
Encrypted Text
• Asymmetric Encryption consists of separate encryption and decryption keys, with users only being able to
decrypt an encrypted message if they have the appropriate decryption key.
• The asymmetric nature of public-key cryptography allows it a sizable advantage over symmetric-key algorithms
• Computationally more expensive
• It can be used for
– Encrypted Communications
– Authenticated Communications
– Confidential and Authenticated Communications
Asymmetric Encryption - Encrypted Communications
Only Bob should Alice Bob
be able to view
this message
Alice’s Bob’s
Public Bob’s
Public Private
Alice’s Key Key Key
Private Key
Plain Text Plain Text

Encrypted
communication
uses Recipient's
Encrypt Key Pair Decrypt

Encrypted Encrypted
Text
Text
Eve
Asymmetric Encryption
Encrypted Communications Demo

23
Asymmetric Encryption - Authenticated Communications
This could have
Alice Bob only been from
Alice
Alice’s Bob’s
Public Bob’s
Public Private
Alice’s Key Key Key
Private Key
Plain Text Plain Text

Authenticated
communication
uses Sender’s
Encrypt Key Pair Decrypt

Encrypted Encrypted
Text
Text
Eve
Asymmetric Encryption
Authenticated Communications Demo

25
Asymmetric Encryption - Confidential and Authenticated Communications
This could have
Alice Bob only been from
Alice
Alice’s Bob’s
Public Bob’s
Alice’s Public Private
Private Key Key Key
Key Plain Text Plain Text

Encrypt with Decrypt with


Sender’s Authenticated Sender’s
private key Public key
and Encrypted
communication Decrypt with
Encrypt with
Recipient’s uses Both Key Recipient’s
Private key
Public key Pairs

Encrypted Encrypted
Text
Text
Eve
Asymmetric Encryption
Confidential and Authenticated Communications
Demo

27
Digital Signature
Digital Signature
A digital signature is a method to ensure the authenticity of electronically transmitted documents
like e-mail, spreadsheet, text file, etc. Authentic means that you know who created the document
and you know that it has not been altered in any way since that person created it.
Digital Signature - Explained
Alice Bob

Alice needs to send a contract agreement to Bob

To avoid legal troubles, we'd like this communication of


contracts to have
• the property of non-repudiation
— Bob should be assured that Alice can't claim that she never sent
the contract and back out of the deal.
• the property of integrity
— Alice should be assured that Bob wouldn’t modify the contract and
claim that the modified version is what Alice sent him.
Digital Signature Creation
The contract document The Digital Finger Print
Alice needs to The contract document is
is hashed to generate a is encrypted with Alice’s
send a contract signed with the Digital
unique Digital Finger Private Key to generate
agreement to Bob Signature and sent to Bob
Print the Digital Signature

Alice Bob

HASH ENCRYPT
Alice’s
Digital Private Digital Digitally
Contract Signature
Finger Key Signed
Document
Print Document
The contract document
Digital Signature - Verification is hashed to generate a
unique Digital Finger
Print If both hash are the
same , the document
is not tampered and is
HASH sent by Alice

Contract
Bob

Compare
Document

Digitally
Signed
Document
DECRYPT

Digital
Signature
The Digital Signature is
Decrypted to get the
Digital Finger Print
Verifying data using Digital signature

Hash

Hello World Hello World Hello World 7F83B165

Digital signature Digital signature


Hash Hash
$58769- $58769-
7F83B165 7F83B165
hhfwfbaj104 hhfwfbaj104
188aff88fa0 188aff88fa0

Private key Public key


Creating Signature • Authenticity Verifying Signature
• Data Integrity
• Non-repudiation
Digital Signature Demo

35
Immutable

Consensus Encrypted

Blockchain
Blocks and Chains
Programmable Transparent

Distributed
Blocks and Chains
• Data can be any type of data stored in the
Blockchain.
Data • Hash is digital fingerprint of Block
• Hash output of the previous block will be
served as one of the input to the next
Hash block

Hash of
Pervious Hash Hash
Output
Output
Block

Data
Blocks can store any values could represent transactions, contracts, assets,
identities, or practically anything that can be described in digital form.
Chaining the Blocks

Block # 1 Block # 2 Block # 3

Prev Hash : 00000000000000000000000000000000 Prev Hash : 000015783b764259d382017d91a36d2 Prev Hash : 000012fa9b916eb9078f8d98a7864e69


00000000000000000000000000000000 06d0600e2cbb3567748f46a33fe9297cf 7ae83ed54f5146bd84452cdafd043c19

Data : Data : Data :

Hash : 000015783b764259d382017d91a36d2 Hash : 000012fa9b916eb9078f8d98a7864e69 Hash : 0000b9015ce2a08b61216ba5a0778545


06d0600e2cbb3567748f46a33fe9297cf 7ae83ed54f5146bd84452cdafd043c19 bf4ddd7ceb7bbd85dd8062b29a9140bf
Genesis Block
Genesis Block of Bitcoin

Genesis block was


created on 3rd Jan
2009 by Satoshi
Nakamoto, it is
hard coded.
Block and how it is chained

Block n Block n+1 Block n+2


Block ID Timestamp Nonce Timestamp Nonce
Block ID
Block ID Timestamp Nonce
Prev Block Hash Merkle Root Prev Block Hash Merkle Root
Prev Block Hash Merkle Root
Block header n Block header n+1
Block header n+2

**** **** **** **** **** ****


STR STR STR STR STR STR

Transactions
Transactions
Transactions

**** **** **** **** **** ****


STR STR STR STR STR STR

**** **** **** **** **** ****


STR STR STR STR STR STR
**** **** **** **** **** ****
STR STR STR STR STR STR
Block Body n

S-sender, R- Receiver , T - transaction


Block Header
• It must contain unique block id
• Its time stamp is after the time stamp of the preceding Blockheader
• It must contain a valid hash reference to a previous block
• It must contain a valid root of a Merkle tree containing transaction data
• It contain a nonce

Block ID Timestamp Nonce


Previous Block Hash Merkle Root

42
Timestamp
Digital Timestamp in Blockchain

• Timestamp
– A timestamp is a sequence of characters or encoded information identifying when a certain event occurred, usually
giving date and time of day, sometimes accurate to a small fraction of a second.
– This data is usually presented in a consistent format, allowing for easy comparison of two different records and
tracking progress over time; the practice of recording timestamps in a consistent manner along with the actual data
is called timestamping.
– Examples of timestamps: We need timestamp
• Wed 01-01-2009 6:00 to prevent
• 2005-10-30 T 10:45 UTC double spending.
• 1985-W15-5 T 10:15 UTC (year 1985, week 15, day 5 = 12 April 1985) - Satoshi Nakamoto
• 20180203073000 (02/03/2018 7:30:00)

• In Blockchain
– Each block contains a Unix time timestamp. In addition to serving as a source of variation for the block hash, they
also make it more difficult for an adversary to manipulate the block chain.
– A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the
network-adjusted time + 2 hours.

44
Trusted Timestamping

• Trusted timestamping is the process of securely keeping track of the creation and modification time of a
document.
• Security here means that no one—not even the owner of the document—should be able to change it
once it has been recorded provided that the timestamper's integrity is never compromised.
• It allows interested parties to know, without a doubt, that a document in question existed at a particular
date and time.
• By including a cryptographic digest of a file you can later certify that the data existed at that time.

Unique fingerprint for each revision

Digital Fingerprint includes:


• The title of the document
• The content
• The date
• The fingerprint of its previous
10 days ago 2 days ago Today revision

45
Merkle Root
Hash Tree or Merkle Tree
Hash 12345678 Merkle Root

Hash 1234 Hash 5678


Merkle Node
- Hash of hashes of Data Block

Hash 12 Hash 34 Hash 56 Hash 78

Hash 1 Hash 2 Hash 3 Hash 4 Hash 5 Hash 6 Hash 7 Hash 8 Merkle Leaf
- Hash of Data block

D1 D2 D3 D4 D5 D6 D7 D8 Data Block

47
Blocks Using Merkle Tree
Block 20 Block 21 Block 22

Block ID Timestamp Nonce Block ID Timestamp Nonce Block ID Timestamp Nonce

Previous Block Hash Tx_root Previous Block Hash Tx_root Previous Block Hash Tx_root

Merkle Root
• Merkle root verifies a set of transactions.
• Transaction IDs are hashes of the transaction. Hash 12 Hash 34 Using a Merkle tree is
And the Merkle tree is constructed from these preferable over a
transactions. hash chain or
• Merkle root is cryptographic proof of which Hash 2 Hash 3 concatenated
Hash 1 Hash 4
transactions because
transactions are in the block, and which order it is easier to track a
they are in. transaction in a
• For odd number of transactions the last particular transaction
transaction ID (hash) is repeated Tx1 Tx2 Tx3 Tx4 is included in the set.

Merkle Tree
48
Merkle Tree - Data tampered

Hash 12345678

Hash
Hash 1234
1234 Hash 5678

Hash 12 Hash 34 Hash 56 Hash 78

Hash 1 Hash 2 Hash 3 Hash 4 Hash 5 Hash 6 Hash 7 Hash 8

D1 D2 D3 D4 D5 D6 D7 D8

tampered

49
Merkle Root Comparison

Hash 12345678 Hash 12345678 Hash 12345678

Peer A Peer B Peer C

50
Identifying the Tampered Data

Hash 12345678

Hash 1234 Hash 5678


Hash 5678

Hash 12 Hash 34
Hash 34 Hash 56 Hash 78

Hash 1 Hash 2 Hash 3 Hash 4 Hash 5 Hash 6 Hash 7 Hash 8

D1 D2 D3 D4 D5 D6 D7 D8

tampered

51
Nonce

52
Tampering with a Block in Blockchain

Block # 1 Block # 2 Block # 3

Prev Hash : 00000000000000000000000000000000 Prev Hash : 2ca96e269bc36612004bcb85f77b5f3250


000015783b764259d382017d91a36d2 Prev Hash : 16f010289bc709a553cf9ca05f06cef4b797
000012fa9b916eb9078f8d98a7864e69
00000000000000000000000000000000 ef969a9b6266c3173ab2f8112b99b4
06d0600e2cbb3567748f46a33fe9297cf 049316c0b2f7aafcb3312af203bb
7ae83ed54f5146bd84452cdafd043c19

Data : tamper Data : Data :

Hash : 2ca96e269bc36612004bcb85f77b5f325
000015783b764259d382017d91a36d2 Hash : 16f010289bc709a553cf9ca05f06cef4b79
000012fa9b916eb9078f8d98a7864e69 Hash : 0a56e7b99f43ec93838439ce4b0b6ef13b
0000b9015ce2a08b61216ba5a0778545
0ef969a9b6266c3173ab2f8112b99b4
06d0600e2cbb3567748f46a33fe9297cf 7049316c0b2f7aafcb3312af203bb
7ae83ed54f5146bd84452cdafd043c19 60309771128a72bcf9ecc0d94c3bda
bf4ddd7ceb7bbd85dd8062b29a9140bf
Partial Hash Inversion
Finding hash is very easy but the reverse is almost impossible. But what about partial hash inversion?
In other words to find an input which gives out a hash which lies in a specified range.
Total range of possible hash values

Range of hash values considered valid


Block n

Block ID Timestamp Nonce


Previous Block Hash TX Hash

To create a new block, miners need to show “Nonce” value that together will other block header inputs
produces a hash value with in a valid range
Finding the Nonce

Pick a random
nonce

No
Compute the hash of
Yes Correct Version Timestamp Nonce
Hash Difficulty Level Time Stamp
Previous Block Hash TX Hash

00000000000000000003be1274ecad6192bca1241
Blockchain Challenge - nonce

Block # 1 Block # 2 Block # 3

Prev Hash : 00000000000000000000000000000000 Prev Hash : 0000a178a13b2aeadb06b40c574945b50


000015783b764259d382017d91a36d2 Prev Hash : ea14a74bc5ba237df584555151c7a099aa
000012fa9b916eb9078f8d98a7864e69
00000000000000000000000000000000 831d8210484e1ce903322cb0a0222f7
06d0600e2cbb3567748f46a33fe9297cf c3d724458a527bdba1191e50e0b92c
7ae83ed54f5146bd84452cdafd043c19

Data : Data : Data :


Nonce 43039 Nonce 74948 Nonce 12937

Data : tamper Data : Data :

Hash : 000015783b764259d382017d91a36d2 Hash : 000012fa9b916eb9078f8d98a7864e69 Hash : 0000b9015ce2a08b61216ba5a0778545


06d0600e2cbb3567748f46a33fe9297cf 7ae83ed54f5146bd84452cdafd043c19 bf4ddd7ceb7bbd85dd8062b29a9140bf

Hash : 0000a178a13b2aeadb06b40c574945b5 Hash : ea14a74bc5ba237df584555151c7a099a Hash : 385289ebb42496a83a6d0d4ea330499be


0831d8210484e1ce903322cb0a0222f7 ac3d724458a527bdba1191e50e0b92c 6830a18f531d8f9937e436de28fd093
Blockchain Challenge - nonce

Block # 1 Block # 2 Block # 3

Prev Hash : 00000000000000000000000000000000 Prev Hash : 0000a178a13b2aeadb06b40c574945b50


000015783b764259d382017d91a36d2 Prev Hash : 00009281c30c5334830bc4f7e3c9da355fe
000012fa9b916eb9078f8d98a7864e69
00000000000000000000000000000000 831d8210484e1ce903322cb0a0222f7
06d0600e2cbb3567748f46a33fe9297cf 490e6e74ed46f7bd783e9473e5454
7ae83ed54f5146bd84452cdafd043c19

Data : Data : Data :


Nonce 43039 Nonce 144670 Nonce 12937

Data : tamper Data : Data :

Hash : 000015783b764259d382017d91a36d2 Hash : 000012fa9b916eb9078f8d98a7864e69 Hash : 0000b9015ce2a08b61216ba5a0778545


06d0600e2cbb3567748f46a33fe9297cf 7ae83ed54f5146bd84452cdafd043c19 bf4ddd7ceb7bbd85dd8062b29a9140bf

Hash : 0000a178a13b2aeadb06b40c574945b5 Hash : 00009281c30c5334830bc4f7e3c9da355f Hash : 77feab8145606d7445db0029ceecbef696


0831d8210484e1ce903322cb0a0222f7 e490e6e74ed46f7bd783e9473e5454 8604c072c2bb26c17c4130b93c47f7
Blockchain Challenge - nonce

Block # 1 Block # 2 Block # 3

Prev Hash : 00000000000000000000000000000000 Prev Hash : 0000a178a13b2aeadb06b40c574945b50


000015783b764259d382017d91a36d2 Prev Hash : 00009281c30c5334830bc4f7e3c9da355fe
000012fa9b916eb9078f8d98a7864e69
00000000000000000000000000000000 831d8210484e1ce903322cb0a0222f7
06d0600e2cbb3567748f46a33fe9297cf 490e6e74ed46f7bd783e9473e5454
7ae83ed54f5146bd84452cdafd043c19

Data : Data : Data :


Nonce 43039 Nonce 144670 Nonce 143682

Data : tamper Data : Data :

Hash : 000015783b764259d382017d91a36d2 Hash : 000012fa9b916eb9078f8d98a7864e69 Hash : 0000b9015ce2a08b61216ba5a0778545


06d0600e2cbb3567748f46a33fe9297cf 7ae83ed54f5146bd84452cdafd043c19 bf4ddd7ceb7bbd85dd8062b29a9140bf

Hash : 0000a178a13b2aeadb06b40c574945b5 Hash : 00009281c30c5334830bc4f7e3c9da355f Hash : 0000f8c48eaa76459618471ca2da696b27


0831d8210484e1ce903322cb0a0222f7 e490e6e74ed46f7bd783e9473e5454 5927032091556f8ed2150048a6b87d
Tampering with a Block – Distributed ledger

PEER A

PEER B

PEER C
Immutable

Consensus Encrypted

Blockchain
Distributed Consensus
Distributed Transparent

Programmable

60
Decentralized system raises many questions
• Who runs the Distributed Ledger? Answer
• Who decides which blockchain transactions are valid?
• Who creates new blocks?
• Who validates the Blocks
Typical Blockchain Transaction Flow
Transaction Requested Transaction Broadcasted Transaction Verified Transaction Added to Pool

Transaction
Block Verified New Block Added to Blockchain Transaction Completed
Added to Block
Who creates the new Blocks?
Block I D Times tamp Nonce
Block I D Times tamp Nonce
Previous Block Hash TX Has h
Previous Block Hash TX Has h
**** ****
STR STR
**** ****
STR STR
New **** ****

Transactions
STR STR
Block **** ****

Transactions
STR STR
****
STR
**** New
STR
**** ****
Block STR STR
**** ****
Block I D Times tamp Nonce Block I D Times tamp Nonce STR STR
Block I D Times tamp Nonce **** ****
STR STR
Previous Block Hash TX Has h Previous Block Hash TX Has h
Previous Block Hash TX Has h
**** **** **** ****
STR STR **** **** STR STR
STR STR
**** **** **** **** ? What will be the next valid block?
Transactions

Transactions
**** ****
Transactions
STR STR STR STR
Block n Block n+1
STR STR
Block n+2
**** **** **** ****
STR STR **** **** STR STR
STR STR
**** **** **** **** Block I D Times tamp Nonce Block I D Times tamp Nonce
STR STR **** **** STR STR
STR STR
Previous Block Hash TX Has h Previous Block Hash TX Has h

**** **** **** ****


STR STR STR STR

New **** **** New **** ****

Transactions

Transactions
STR STR STR STR
Block Block
Memory Pool (“Mempool”) Miners pick up transactions ****
STR
****
STR
****
STR
****
STR

All unconfirmed transactions posted to and aggregate them into **** **** **** ****
STR STR STR STR
next block
the blockchain network
The Mining Process

Find the
Transactions Miner Aggregate Blocks
2 Miner creates Nonce
transactions, compute Miner solves the
1 a Block puzzle (Nonce)
Merkle root, and fill other 3
inputs needed for the block and shows PoW
Proof of
Work
~10 minutes of transactions
are broadcast to the network
Successful miner broadcasts
PoW to the network 4
Newly created block
is appended to the
existing blockchain Miners Verify PoW 5
6 Adding the
new block Verification
Process starts all over again
What do the Miners get?

Miners are rewarded with


cryptocurrencies for
each new block created
and validated by solving
the cryptographic puzzle

Miner Reward = Block reward + sum of all Transaction fees inside the block
• Process and confirm Transactions
• Solve specific math problems in competition
• Cryptocurrency awarded to winner
The Bitcoin Example
• Bitcoin miner creates a new block at every 10 minutes and gets 6.25 BTC as reward
• In every 21000 transactions, difficulty level of solving the cryptographic puzzle is adjusted to
maintain the time (10’)
• The reward will be halved every 210000 blocks
• There are currently 16million BTC in circulation and there is a cap of 21M BTC as per the rules
and the cap will be reached by 2140 AD
Elements of Consensus in General
• Consensus is the process of building agreement among a group of mutually distrusting participants
• There are the four elements that must be considered:
1. Investment of the validator or miner, the nodes that process the consensus algorithm on behalf of the network.
– Investment is the level of investment needed to be made on the part of the miner or validator.
– What does the potential validator or miner have to invest in order to be able to process transactions and verity blocks?
2. Selection process of the Validator or Miner
Investment by the
– The process of electing the leader / miner / validator Hashing power, tokens Validator
– Some sort of lottery to randomly select the miner to validate Validator
Random, round robin, election etc
– Raw elections and perform round robin selection Selection Process
3. Proof Element PoW, PoS, PoA, PBFT Proof Element
– PoW, PoS, Proof of Capacity, PBFT, Proof of elapsed time, Prof of Burn, Proof of activity, Ripple protocol etc.
Public / Private/ Federated Level of trust
4. Level of Trust
– The level of trust between the nodes , it varies considerably with different types of Blockchain.
Objective of different Consensus Algorithm
• There are four additional goals that a consensus algorithm will consider:
1. Performance
– How many transitions per second (tps)?
2. Scalability
– Number of concurrent users supported by the blockchain network within acceptable performance.
3. Threat resistance against potential outside attacks
– Various threat models need to be considered in order for the Blockchain to be able to fend off an
attack.
– If the attack cannot be completely prevented, the blockchain needs to make the cost of mounting an
attack more expensive to attempt than the potential benefit of being an honest miner/validator of a
Blockchain.
– 51% attack – immutability can be compromised
– Sybil attack - an attempt to control the peer network by creating multiple fake identities
4. Failure model
– Network failures , what % of nodes can be disconnected or down without affecting the operation of
the blockchain network
– For bitcoin it is 33%, means 33 % of the node failures can be tolerated while the system can continue
to process the block normally
Different Consensus Algorithms

69
Consensus Mechanisms compared
PoW requires validators to solve difficult cryptographic puzzles
Pros: Works in Permissionless Blockchain (untrusted networks)
Cons: Relies on energy use, slow to confirm transactions
Ex: Bitcoin and Ethereum
Proof of Work
PoS requires validators to hold currency in escrow
Pros: Works in Permissionless Blockchain (untrusted networks)
Cons: Requires cryptocurrency, “Nothing at stake” problem
Ex: Nxt
Proof of Stake
Wait time in a trusted execution environment randomizes block
generation
Pros: Efficient
Cons: Requires Processor extensions
Proof of Elapsed
Ex: Hyperledger Sawtooth
Time

70
Consensus Mechanisms compared
Validators apply received transactions without Consensus
Pros: Very quick , suited to development
Cons: No consensus; can lead to divergent chains
Ex: Hyperledger Fabric V1
Solo / No ops
Practical Byzantine Fault tolerant implementations
Pros: Reasonably efficient and tolerant against attacks
Cons: Validators and known are totally connected
Ex: Hyperledger Fabric V 0.6
PBFT Based
Ordering service distributes blocks to peers
Pros: Efficient and fault tolerant
Cons: Does not guard against malicious activity
Ex: Hyperledger Fabric 1
Zookeeper

71
Trust Model
Hunter
Gatherer
• Old Old Trust Model – Show me your armies
• Old Trust Model – Show me your reputation and relationships
• Current Trust Model – Show me your license
• New Trust Model – Show me your code Civilized
Society

Blockchain Spectrum of Trust


Increasing Trust required

Public Public Private Private Centralized


Permissionless Permissioned Permissionless Permissioned Database

Increasing Computation Load

As the level of trust increases, the need for resource usage as a measure of generating
trust decreases.
Forking

73
Forking 74

Forking
• A Fork takes place when a Blockchain splits into two different paths forward.
• Changes and modifications to the blockchain software need to be approved by consensus
• If a group of nodes modify their software without consensus, those nodes then invalidate
a rule held by the rest of the network and create their own fork of the blockchain.
• Hard Fork - Broadening or removing the rules Temporary Intentional
(split in consensus) (Change in rules)
– Introduces a change that forces every one to upgrade
• Soft fork – Tightening the rules
– Introduces a change that is backward compatible, does not need to upgrade

Hard Fork Soft Fork

Original Version (follows old rules)


Old
Shared History Rules
100

New
Rules
Alternative Version (follows New Rules)
75
Soft Fork, Hard Fork and Source Code Fork
1. Soft Fork • Hard Fork - Broadening or removing the rules
History Bitcoin cash
100 Original Version – Introduces a change that forces every one to
upgrade
Soft Fork • Soft fork – Tightening the rules Segwit

– Introduces a change that is backward


2. Hard Fork New Version
compatible, does not need to upgrade
Shared History Original Version (follows old rules)
100 Hard fork Soft fork Source Code
Fork
Change Large Small Small or
Copy of Protocol
Large
Copies of Yes Yes Yes
Alternative Version (follows New Rules)
original
3. Source Code Fork codebase
Original Blockchain
100 Original Version Continued(Bitcoin) Backward No yes No
compatible

No connection between these Blockchains Split Permanent Temporary Permanent


Original Source
Code is copied Example Bitcoin Segwit Litecoin
No Shared History Brand New Blockchain (Litecoin) Cash
Temporary Forking / Split in Consensus
• A fork can also be generated temporarily in the Bitcoin Blockchain in such cases as multiple
nodes in a P2P network almost simultaneously succeed in PoW, (due to network latency)
• In such a case, a chain that becomes longer thereafter is judged as the authentic one.
• To finalize a transaction, it is necessary to confirm that the relevant blockchain does not fork after
the transaction data is incorporated in the block and multiple blocks are created thereafter.
• When approximately six blocks are additionally created, the relevant blockchain is considered to
be the authentic one.

Longer chain is considered authentic

There may be temporary disagreement if two proposals occur at the same time; eventually, with
very high probability, one proposal will be established by picking the longest blockchain

76
Immutable

Consensus Encrypted

Blockchain Smart Contracts


Programmable Transparent

Distributed

77
What are SMART CONTRACTS?
In 1996, Nick Szabo described a smart contract as “a set of promises, specified in digital form,
including protocols within which the parties perform on these promises.”

“a set of promises”
“specified in digital form”
THE CONTRACT
“protocols”
THE CONTRACT IN THE CODE
“within which the parties perform”
THE RULES
THE AUTOMATED PERFORMANCE

78
Smart Contracts Defined
Smart contracts are computer programs that can automatically
executes the terms of a contract

Lend me Rs 1,000 . Everyone in Infosys must pay RS 500 before


I will pay back next month 30th of every month

Blockchain provides Smart contracts gives distributed trustworthy


distributed trustworthy computations - running programs which are self
storage / transactions executing and self enforcing
Contract Account & Smart Contracts

SMART GARAGE Smart Contract Executed in Blockchain to change car


SMART GARAGE
ownership from Dave to Claire on receipt of payment

✓ Owner
Owner Dave OwnerClaire
Dave

Dave wants ✓ ✓ Claire wants


to sell a car to buy a car

✓ ✓
6453899 PD 3452654 PC

✓ ✓


How Does Smart Contract Work?
6
5
4 NETWORK
UPDATES
3 EXECUTION &
PROCESSING
2 ENCRYPTION &
BLOCKCHAIN
CODE THE TECHNOLOGY
1 SET
BUSINESS
LOGIC
CONDITIONS
IDENTIFY
AGREEMENT

83
How Smart Contract is Different
Traditional Contracts Smart Contracts
AUTOMATIC Manual Automated
Remittance Remittance

SMART CONTRACT Traditional Contracts Smart Contracts


DIRECT
Intermediary No Intermediary
necessary

Traditional Contracts Smart Contracts


FAST 1 – 3 Days Minutes

Traditional Contracts Smart Contracts


CHEAP Expensive Fraction of Cost

Traditional Contracts Smart Contracts


TRANSPARENT Lawyers necessary No Lawyers
necessary

84
Smart Contract – A few examples

85
Crypto Assets

86
Cryptocurrency Types

Crypto Coins Crypto Tokens

Cryptocurrency that has its own Cryptocurrency that is built on


separate, standalone top of an existing blockchain.
blockchain.
Crypto Coins

Blockchain Derived
from Bitcoin
A crypto coin is a digital
or virtual currency on
decentralized networks Native Blockchain
based on blockchain - Not Derived
technology and is from Bitcoin
secured by cryptography

Mining-Based Stablecoins
Fiat-Collateralized Stablecoin

Crypto-Collateralized Stablecoin

Non-Collateralized Stablecoin
(algorithmic)
Types of Crypto Tokens

The Utility token hands over to users


future access to a product or a
service.

Cryptographic tokens
represent programmable
assets or access rights,
managed by a smart
contract and an A security token is a digital asset
underlying distributed that derives its value from an
ledger. external asset that can be traded.
Crypto Coin vs. Crypto Token

Crypto Coin Crypto Token

A coin is a digital currency similar to the A token is a digital asset issued on a particular
physical currency project
Coin operates on its own Blockchain with its Token does not operate on its own
own protocol Blockchain
Coins are purely used as source of payments Tokens are used for payments and signing
digital agreements
Crypto coins are mined in the Blockchain Crypto tokens are created by Smart contract
network by miners and used by DApps

“You can buy a token with a coin, but not a coin with a token.”
Crypto Wallets
Crypto Wallet / Blockchain Wallet

Privacy is maintained
Exchange of Funds

Digital pocket to hold cryptocurrency

Transactions Accessible from web


are secured or mobile devices

• Allows to hold and exchange more than one type of cryptocurrency


• Allows to issue digital transactions that are secured on the blockchain.
• Accessible through web devices or mobiles
• The Privacy of the wallet owner is maintained
Blockchain Wallet Transaction

Blockchain Wallet in transaction


• When the blockchain transaction is being processed your
private key in your wallet must match the public key that
the currency is assigned to.
Private Key • When both the keys match, the ownership of the currency
- private to the user is signed off to your wallet’s address.
• The transaction is recorded on a blockchain network and
the balance stored in your wallet.

Pros and Cons


• The main advantages of blockchain are its trust and
distribution.
• However, it is a double-ended sword. If you lose your
email password it’s not such a big deal as you can
regenerate a new password, which is not the case when
Public Key you lose your private key.
- Shared with all
Types of Blockchain Wallets
• Run through internet online accounts
Online Wallet • Can be accessed from anywhere
• Private keys are managed by some third party

• Available on Mobile Devices


Mobile Wallet • Can be accessed from a Wallet App on the mobile
• Private keys are managed by some third party

• Private keys are stored in the desktop


Desktop Wallet • Can transact offline and then submit it by login online
• Can be accessed only from the desktop it is downloaded

• Cold storage device like USB


Hardware Wallet • Portable
• Needs to be plugged in to a physical device to transact

• Printed on paper as a QR code


Paper Wallet • Secure because it cannot be hacked into
• Works with a software wallet

94
Crypto Wallet Security
• Level 1
– allows email verification and back up phrase / password hint to recover password
– This is to prevent users from losing access to their account
• Level 2
– Enable 2 step authorization by linking phone numbers and authenticate via OTPs
– To prevent unauthorized access
• Level 3
– Allows users to block tor requests
In Short….

Immutable

Consensus Encrypted

Blockchain

Programmable Transparent

Distributed

96
Do you need Blockchain?
98
Prerequisites for a Blockchain Solution
Multiple parties share data 4 Intermediaries add complexity
1 Multiple parties need a common view of
Removal of dependencies on
intermediaries can reduce cost and
the information at hand
complexity

Multiple parties update data


Multiple participants take actions that Interactions are time sensitive
2 changes the data , which needs to be 5 Reducing delay has business benefit
recorded

Requirement for verification Transactions interact


3 Participants need to trust that the actions 6 Transactions generated by different
that recorded are valid participants interact with each other

If the 1s t condition is correct and three out of the remaining considered is desired , then blockchain
may be an effective solution to the problem
I need a Blockchain but which one?
Transaction Processing:
Public Data access: Private or Public Permissioned or Permission less

Permissionless Public Permissioned Public


Proof of Stake
Proof of Work
(Ethereum after Casper)
(Bitcoin, Ethereum, Zcash…)
Anyone who meets certain pre-defined
Do we know their identity?

Anonymity Anyone can download the protocol &


criteria can download the protocol &
validate transactions
of BC validate transactions
Nodes
Permissionless Private Permissioned Private

FBA: Federated Byzantium agreement? PBFT Multi-signature


IPDB Only member if consortium can validate
Private/ transactions
Federated Do we trust them?
99 Permissionless Trust Validators Permissioned
Drivers for adoption
Decentralization/
Disintermediation
Information visibility
across ecosystem
Authenticity verification,
Traceability
Rights
management
Automated settlements/
autonomous networks
Drivers for adoption
Decentralization/ Information Authenticity Rights Automated
Disintermediation visibility across verification, management settlements/
ecosystem Traceability autonomous
networks
Question Example Recommendation
Are there resources that are exchanged/transacted? Currency, energy, Blockchain optionally with Smart Contracts could be a
- Is the resource digital or can it be digitized? health records fit
- Can the resource be digitally represented and controlled?
- Can the resource be digitally represented but not controlled? Physical assets If resource is internal to business, permissioned
Blockchain would be an option. Physical transactions
have to be managed externally
Do the transactions happen within the business or its Health records Permissioned Blockchain may be considered
immediate ecosystem?
Are central bodies or third party trust agencies necessary for Swift network Blockchain might help to eliminate the third party
the transaction?
- Is the third party a registry/ custodian of records or facilitator?
- Is the third party a regulatory requirement? Central banks Blockchain could be a fit, but regulatory changes may be
required to leverage Blockchain
Drivers for adoption
Decentralization/ Information Authenticity Rights Automated
Disintermediation visibility across verification, management settlements/
ecosystem Traceability autonomous
networks

Question Example Recommendation


Are records or information shared across Supply chain - Blockchain can help make shared data
internal departments or value chain? Component or raw securely and readily available across the
Is inventory sharing/visibility within or with material source, value chain
the ecosystem useful? production date etc. Blockchain can be used to make dynamic
Is traceability of information or audit trails Inventory information inventory data available to all for decision
required or useful? making
Drivers for adoption
Decentralization/ Information Authenticity Rights Automated
Disintermediation visibility across verification, management settlements/
ecosystem Traceability autonomous
networks

Question Example Recommendation


Is history of ownership of an Property, Art, Blockchain can be used to make the
asset/resource required or useful? Diamond provenance of the asset available for
Is there need for or value in Quality any interested party
authentication of a physical or virtual certificates, Blockchain can be used to make the
resource ? Academic/Skill stamp of authentication from multiple
certificates sources available securely
Drivers for adoption
Decentralization/ Information Authenticity Rights Automated
Disintermediation visibility across verification, management settlements/
ecosystem Traceability autonomous
networks

Question Example Recommendation


Are there shared or licensed assets IP – Documents/ Blockchain with Smart Contracts can be
involved? Music used to track, monitor and control
Is there need for information usage of the asset
access across the ecosystem? Patent information Information can be put on the
Blockchain to make them available
widely and reliably with traceability
Drivers for adoption
Decentralization/ Information Authenticity Rights Automated
Disintermediation visibility across verification, management settlements/
ecosystem Traceability autonomous
networks

Question Example Recommendation


Are there settlements or billing or Shares settlement, Blockchain with Smart Contracts can
contract fulfilment required? payment contracts be used for settlements and fulfilling
contracts based on satisfaction of pre-
conditions
Are the nodal points of the network Internet of things The networks can be made
smart devices or things on the autonomous using smart contracts for
internet? transaction decisions & execution
Thank You

© 2018 InfosysLimited, Bengaluru, India. All Rights Reserved. Infosys believes the information in this document is accurate as of its publication date; such
information is subject to change without notice. Infosys acknowledges the proprietary rights of other companies to the trademarks, product names and
such other intellectual property rights mentioned in this document. Except as expressly permitted, neither this documentation nor any part of it may be
reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, printing, photocopying, recording or
otherwise, without the prior permission of Infosys Limited and/ or any named intellectual property rights holders under this document.

You might also like