34
Indian Institute of Information Technology, Allahabad Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1 / 34

Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Blockchain: Ethereum Perspective

S.Venkatesan

19/08/2018

S.Venkatesan @IIITABlockchain: Ethereum Perspective 1 / 34

Page 2: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Blockchain

A blockchain is a distributed database that maintains a contin-uously growing list of ordered records called blocks.

Each block contains a timestamp and a link to a previous block.

Since the blocks are cryptographically connected, modificationof the data is not possible.

Regular distributed database vs blockchain

No need to trust all users in the network.It is suitable for the untrusted environment.Record keeping and searching is a complex task.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 2 / 34

Page 3: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Blockchain

Blocks has header and data portion.Unchanged data portion of one block can be used by anotherblock.

Figure: Simple Blockchain Structure

S.Venkatesan @IIITABlockchain: Ethereum Perspective 3 / 34

Page 4: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Merkle Patricia Tree

Blocks in goethereum uses the Merkle Patricia Tree to storethe transaction details, account balances, etc.

It has the advantage to have one value as well as full value.This is not supported by Radix Tree as per many claims.

Every block will not have completely new trie, it will have thelink with other block nodes.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 4 / 34

Page 5: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Merkle Patricia Tree

Figure: MPT

S.Venkatesan @IIITABlockchain: Ethereum Perspective 5 / 34

Page 6: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Address Computation

Start with the public key bytes (a bytestring of length 64)

Of that public key, take the Keccak-256 hash used ubiquitouslyby Ethereum. You should now have a bytestring of length 32.

Drop the first 12 bytes. You should now have a bytestring oflength 20, the Ethereum address associated with your publickey,

S.Venkatesan @IIITABlockchain: Ethereum Perspective 6 / 34

Page 7: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Byzantine Generals Problem

Figure: Byzantine

S.Venkatesan @IIITABlockchain: Ethereum Perspective 7 / 34

Page 8: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Proof of Work (PoW)

This is to control the rate at which blocks can be generated

This is added in the bitcoin to make the miners to do somework before constructing the blocks.

Due to the very low probability of successful generation, thismakes it unpredictable which worker in the network will be ableto generate the next block.

n ≤ 2256/Hd

Proof of Stake (PoS) — Proof of Burn (PoB) — Proof of ElapsedTime (PoE)

To reduce the energy consumption.S.Venkatesan @IIITABlockchain: Ethereum Perspective 8 / 34

Page 9: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Hash Generation with respect to Proof of Work

Table: Hash Computation

Target (<) Real time (s) User time (s) Attempts

2210 > 103146.837 > 397295.636 -

2220 3468.381 13006.832 ∼ 232

2230 15.03 57.378 18960126

2240 0.289 0.356 1050648

2250 0.295 0.328 1033

S.Venkatesan @IIITABlockchain: Ethereum Perspective 9 / 34

Page 10: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Difficulty Calculation

Frontier

block d = parent d+parent d2048 ∗

{1 b timestamp − p timestamp < 13−1 otherwise

(1)Homestead

block d = parent d + parent d2048 ∗ max(1 − b timestamp−p timestamp

10 , −99)+int(2 blocknumber

100000 − 2)(2)

S.Venkatesan @IIITABlockchain: Ethereum Perspective 10 / 34

Page 11: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Sybil Attack

A node with Multiple Identities.

It is not possible because of Proof of Work

S.Venkatesan @IIITABlockchain: Ethereum Perspective 11 / 34

Page 12: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Two Generals Problem

Figure: TGP

S.Venkatesan @IIITABlockchain: Ethereum Perspective 12 / 34

Page 13: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Miner

Generate the blocks

Confirm the transactions and include in blocks

Get reward (newly generated bitcoin) and transaction fee fromthe sender.

Uncle block

Block with same number generated by the multiple minerscannot be added in the main blockchain.One block will be added in the main chain others will be theuncle blocks.Rewards will be provided but no transaction fee.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 13 / 34

Page 14: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

ASIC Resistance

Application Specific Integrated Circuits (ASIC) are resisted byapplying the memory-hard algorithm

ETHash is the algorithm used in goethereum to resist ASIC.

Miners cannot extend their block generation speed by addingASIC.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 14 / 34

Page 15: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Directed Acyclic Graph (DAG)

Figure: DAG

S.Venkatesan @IIITABlockchain: Ethereum Perspective 15 / 34

Page 16: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Gas Limit

Every operation in the blockchain is alloted a gas value

To perform the operation, respective gas will be spent. In casethe gas is not sufficient for the operation then it will be dropped.

Infinite operations will be avoided.

If attacker gives more gas limit for any transaction then minercan decide on choose it or not.

If attacker gives gas limit only for withdrawal not for balancededuction then automatically complete process will be reverted.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 16 / 34

Page 17: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Node Type

Light Node

Full Node

S.Venkatesan @IIITABlockchain: Ethereum Perspective 17 / 34

Page 18: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Centralization Problem

Due to the shortage of memory and computational power, fullnodes may act as light node.

After a period of time, only few full nodes will be in the network.

More than 50% hash power will be with the single node orgroup of node with similar mindset.

Light nodes do not have any way of detecting it immediately.

Of course, at least one honest full node would likely exist, andafter a few hours, information about the fraud would trickle outthrough channels, but it would be too late.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 18 / 34

Page 19: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Comparison with Bitcoin

It is faster.

Limited with gas

S.Venkatesan @IIITABlockchain: Ethereum Perspective 19 / 34

Page 20: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

GHOST

Greedy Heaviest Observed Sub Tree

Stale Block will get the reward of 87.5%

Nephews that includes the state block receives reward of12.5%.

Transaction fees, however, are not awarded to uncles.

It goes down up to 6 levels.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 20 / 34

Page 21: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Recursive Length Prefix (RLP) Encoding

Data serialization is necessary for many complex data forms tobe stored or transmitted in only one formal format.

RLP is an encoding/decoding algorithm that helps Ethereumto serialize data and possible to reconstruct them quickly.

[0x00, 0x7f]: byte; [0x80, 0xbf]: string; [0xc0, 0xff]: list; 0xff]: list

S.Venkatesan @IIITABlockchain: Ethereum Perspective 21 / 34

Page 22: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Timestamp Validation

Less than Average timestamp of all the nodes on which therespective nodes connected + 2

Greater than the average of last 12 blocks

S.Venkatesan @IIITABlockchain: Ethereum Perspective 22 / 34

Page 23: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Network

Figure: Differencehttp://www .itrelease.com/2017/11/difference−centralized−decentralized−distributed−processing/

S.Venkatesan @IIITABlockchain: Ethereum Perspective 23 / 34

Page 24: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Kademlia Network

It is a DHT based implementation.

Figure: DHT(http://cse.csusb.edu/tongyu/courses/cs660/notes/distarch.php)

S.Venkatesan @IIITABlockchain: Ethereum Perspective 24 / 34

Page 25: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Eclipse Attack

In an eclipse attack, an attacker takes control of all the con-nections going to and from a targeted victim’s node. This way,an attacker prevents that victim from obtaining full informationabout other parts of the network.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 25 / 34

Page 26: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Address Collision

Hash Collision

Key Collision

S.Venkatesan @IIITABlockchain: Ethereum Perspective 26 / 34

Page 27: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Replacing of chain

Before replacing it checks for the total difficulty.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 27 / 34

Page 28: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Double Spending

Nonce is part of the transaction as well as in the account.

S.Venkatesan @IIITABlockchain: Ethereum Perspective 28 / 34

Page 29: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Application of Blockchain

Internet of Things for authentication

Medical Record Management System

S.Venkatesan @IIITABlockchain: Ethereum Perspective 29 / 34

Page 30: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Genesis Block of goethereum

Figure: Genesis Block

S.Venkatesan @IIITABlockchain: Ethereum Perspective 30 / 34

Page 31: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Transaction

Figure: Transaction

S.Venkatesan @IIITABlockchain: Ethereum Perspective 31 / 34

Page 32: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Transaction Receipt

Figure: Transaction

S.Venkatesan @IIITABlockchain: Ethereum Perspective 32 / 34

Page 33: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

References[1] DR. GAVIN WOOD ETHEREUM: A SECURE DECENTRALISED

GENERALISED TRANSACTION LEDGER Yellow paper.2014.

[2] http://ethereum.stackexchange.com/questions/6415/eli5-how-does-a-merkle-patricia-trie-tree-work

[3] https://en.wikipedia.org/wiki/Blockchain (database)

[4] https://github.com/ethereum/wiki/wiki/Mining

[5] https://github.com/ethereum/go-ethereum

[6] https://i.stack.imgur.com/afWDt.jpg

[7] https://www.investopedia.com/terms/s/smart-contracts.asp#ixzz5Gy2ah8Gy

[8] https://medium.com/coinmonks/data-structure-in-ethereum-episode-1-recursive-length-prefix-rlp-encoding-decoding-d1016832f919

S.Venkatesan @IIITABlockchain: Ethereum Perspective 33 / 34

Page 34: Blockchain: Ethereum Perspective · Blockchain: Ethereum Perspective S.Venkatesan 19/08/2018 S.Venkatesan @IIITA Blockchain: Ethereum Perspective 1/34. Indian Institute of Information

Indian Institute of Information Technology, Allahabad

Thank You!

S.Venkatesan @IIITABlockchain: Ethereum Perspective 34 / 34