Slide 1

Slide 1 text

Basics of blockchain and decentralized applications - Koshik Raj

Slide 2

Slide 2 text

Agenda ● Blockchain background and basics ● Basics of decentralization using Distributed Ledger Technology ● Bitcoin consensus algorithm and transactions

Slide 3

Slide 3 text

When did it all start?

Slide 4

Slide 4 text

Bitcoin history ● Several cypherpunks attempted to implement cryptocurrencies in 1990s. ○ Bit gold, DigiCash ● "Bitcoin: A Peer-to-Peer Electronic Cash System" a paper was published by Satoshi Nakamoto. ● It was implemented as a decentralized accounting system.

Slide 5

Slide 5 text

Why was it created?

Slide 6

Slide 6 text

Centralization concerns in the past ● Cyber attacks on major institutions. ○ Sony pictures, JP Morgan Chase data breach. ○ Target customer confidential data breach. ● Expensive transaction fee. ● Subprime mortgage crisis in 2008.

Slide 7

Slide 7 text

Decentralization ?

Slide 8

Slide 8 text

Byzantine generals’ problem

Slide 9

Slide 9 text

Decentralization problem ● Trustless entities ● How to believe on single truth?

Slide 10

Slide 10 text

How Bitcoin solved it?

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Distributed Ledger Technology (DLT) Each node holds a copy of the blockchain Blockchain + p2p+ Consensus algorithm = DLT

Slide 13

Slide 13 text

Cryptography in blockchain ● Hashing ● Digital signatures

Slide 14

Slide 14 text

Blockchain Hash value Previous block hash value

Slide 15

Slide 15 text

Blockchain 1234 1234 1235 1235 1237

Slide 16

Slide 16 text

Blockchain

Slide 17

Slide 17 text

Consensus mechanism ● Algorithm to reach a global truth ● Consensus mechanism solves the byzantine generals’ problem. ● Bitcoin’s proof-of-work is the first and well known consensus algorithm.

Slide 18

Slide 18 text

Consensus algorithm: proof-of-work ● Uses hash puzzle to do work ● Incentivizes miner for their work from transaction fee + new coins ● Hash cash proposed in 1997 by Adam Back ● Reduce email spam and DOS attacks

Slide 19

Slide 19 text

Hash puzzle Find a hash value which is less than a specified value 0000000000000756af69e2ffbdb930261873cd71

Slide 20

Slide 20 text

Peer-to-peer network Decentralized network is achieved with the peer-to-peer protocol. Every node in the network has equal responsibility.

Slide 21

Slide 21 text

Achieving consensus Each node has to perform a few tasks to achieve the consensus. ● Validate each incoming block ● Select the longest blockchain ● Create a valid block

Slide 22

Slide 22 text

Bitcoin addresses ● Bitcoin uses asymmetric cryptography to generate public-private key pair ● Public key is used to generate the public address ● Private key is used to sign the transactions ○ bitcoin-cli getnewaddress 1JK1yCXbP2WkwgzbAUqpWTeo9rQkA9seNg ○ bitcoin-cli dumpprivkey 1JK1yCXbP2WkwgzbAUqpWTeo9rQkA9seNg L2NAKvQsbkeQZyhfPRWw1juQ19ohxGCFbdr8izQSHEmKWYFtVjXK

Slide 23

Slide 23 text

Bitcoin transactions ● Bitcoin does bookkeeping with a transaction based ledger ● Every transaction must be validated by the node ● Every transaction consists of inputs and outputs ● Transaction fee must be paid for every transaction created ● Unconfirmed transactions are maintained in mempool: https://www.blockchain.com/btc/unconfirmed-transactions

Slide 24

Slide 24 text

Transaction verification ● Bitcoin uses Turing incomplete stack-based language called "Script" ● Uses locking and unlocking scripts ○ Locking: 4 OP_ADD 6 OP_EQUAL ○ Unlocking: 2

Slide 25

Slide 25 text

Smart contracts ● protocol that allows contracts to be verified and enforced in a self-executing manner.

Slide 26

Slide 26 text

Ethereum basics ● Ethereum is a widely-used platform for creating decentralized applications (https://www.stateofthedapps.com/stats) ● Ethereum houses its own distributed virtual machine, and scripting language called Salidity

Slide 27

Slide 27 text

Ethereum VM and Solidity ● EVM provides a runtime environment to execute smart contracts ● EVM runs on a node that is isolated from the Ethereum network ● Only the smartcontract output can be inserted to the blockchain ● EVM executes the compiled Solidity bytecode ● Solidity is a contract-oriented programming language influenced by C++, Python and JavaScrip

Slide 28

Slide 28 text

Let's build a DApp

Slide 29

Slide 29 text

Contact me: Koshik Raj linkedIn: koshikraj GitHub: koshikraj twitter: rajkoshik [email protected] www.koshik.me “keep calm and create DApps”