sfrontori-bitcoin-technical intro-meetup2014

35
Bitcoin Technical Introduction Byte-Code Meetup 2014 Stefano Frontori - [email protected]

Upload: stefano-frontori

Post on 07-Jul-2015

108 views

Category:

Technology


0 download

DESCRIPTION

My Bitcoin presentation during the Byte-Code MeetUP 2014

TRANSCRIPT

Page 1: sfrontori-bitcoin-technical intro-meetup2014

Bitcoin !

Technical Introduction !

Byte-Code Meetup 2014 !

Stefano Frontori - [email protected]

Page 2: sfrontori-bitcoin-technical intro-meetup2014

Alice send money to Bob

Alice Bob

Bank

$

2

Page 3: sfrontori-bitcoin-technical intro-meetup2014

Trusted third party

!-5 Bob payment +150 salary -100 tax - 20 phone bill

Alice Ledger !+5 Alice Income +150 salary -100 tax - 20 phone bill

Bob Ledger

$ $$

3

Page 4: sfrontori-bitcoin-technical intro-meetup2014

2007 2009

Satoshi Nakamoto start of discuss on public ml

Satoshi Nakamoto published the final paper and the code on a public repository

4

Page 5: sfrontori-bitcoin-technical intro-meetup2014

Distributed Ledger

Global Ledger !

Alice 1095 Bob 505 Charly 420 !

!

bitcoin node

5

Page 6: sfrontori-bitcoin-technical intro-meetup2014

Transactions

Alice5 ฿

Bob

A: 1095 B: 505

A: 1100 B: 500

A: 1100 B: 500

A: 1095 B: 505

A: 1095 B: 505

update

6

Page 7: sfrontori-bitcoin-technical intro-meetup2014

Digital Signature provide a kind of contract, a smart contract.

public key

message

฿ Address: 1HYigr99wWvPsQH94o9UpN8cfawrX98DXT

private key

message

signatureCreate Verify

Alice

7

Page 8: sfrontori-bitcoin-technical intro-meetup2014

Ownership expressed in a chain

tnx 159d3… !2 ฿ !

Transaction Message !inputs: (from) ! Frank addrs : 159d341… Mary addrs: a443eb… !!outputs: (to) ! Bob addrs (1C3oAzan…) 5 ฿ ! !!!

tnx a443e… !3 ฿

Alice transaction

UNSPENT UNSPENT

8

Page 9: sfrontori-bitcoin-technical intro-meetup2014

9

Page 10: sfrontori-bitcoin-technical intro-meetup2014
Page 11: sfrontori-bitcoin-technical intro-meetup2014

Alice to Bob 5 ฿

tnx

Time

t=10:00 am t=10:11 amt=10:07 am

Bob: “tnx recived”

ship to Alice

t=10:09 am

Bob product

tnx

Alice to Alice 5 ฿

Check 1-(simple double spending)

11

Page 12: sfrontori-bitcoin-technical intro-meetup2014

Alice to Bob 5 ฿

Alice to Alice 5 ฿

Bob’s tnx - double spent, invalid!

Alice

10:00 am - Alice to Bob

10:11 am - Alice to Alice

t=10:09 am

Check 1-(transaction order)

12

Page 13: sfrontori-bitcoin-technical intro-meetup2014

Blocks

Unconfirmed Unordered tnx

tnx q5ed2…

tnx 159d3…

tnx c3g5a…tnx c32aa…

tnx d3e44…

tnx af5w3…

TimeOrdered tnx

Block #w1q23… ! prev: #3w22e… !tnx 2dsf3… tnx 8yyt5… tnx 975rf3…

t = t +10 min

t

13

Page 14: sfrontori-bitcoin-technical intro-meetup2014

The Block Chain

Block #w2a1q… ! prev: #sd21w… !tnx 012qd… tnx dds55… tnx 9neg2f…

Block #x89dw… ! prev: #w2a1q… !tnx f3gf5… tnx s22wd… tnx 9vfk3…

Block #3w22e… ! prev: #d43al… !tnx f3gf5… tnx s22wd… tnx 9vfk3…

Block #sd21w… ! prev: #3w22e… !tnx sd34r… tnx 55gfe… tnx 29sdf…

t=10:00 am t=10:10 am t=10:20 am t=10:30 am

?Time

14

Page 15: sfrontori-bitcoin-technical intro-meetup2014

Block #w2a1q… ! prev: #sd21w…

Block #x89dw… ! prev: #w2a1q…

Block #3w22e… ! prev: #d43al…

Block #sd21w… ! prev: #3w22e…

t=10:00 t=10:10 t=10:20 t=10:30 Time

Block #c72ss… ! prev: #w2a1q…

Block #29dd2… ! prev: #w2a1q…

Existing block

Potential next block

t=10:40

Alice to Bob 5 ฿

Alice to Alice 5 ฿

Block

Block

BlockBlock

BlockBlock

Block

Check 2 - (flood the end of the chain)

15

Page 16: sfrontori-bitcoin-technical intro-meetup2014

Block ID #

# prev Block

# Merkle root (tnx hashtree)

# next Block

Nonce value (random guess)

New Block

f.hash (block header) < target !

output of this function is a cryptographic hash SHA-256

!difficulty (target threshold) is adjusted by the network every 2016 block !10 min per block * 2016 = 2 weeks

Proof-of-Work - (hashing)

3345125676… 7452357854… 2048238545… 7535322244…

!!

9754535353…!5746353532…

?

(difficulty)

16

Page 17: sfrontori-bitcoin-technical intro-meetup2014

Distribution of probability to validate Blocks

prob

abili

ty

time to solve a Block

17

Page 18: sfrontori-bitcoin-technical intro-meetup2014

Block

Block #w2a

Block #x89d

Block #3w2

Block #sd21

Block #c72s

Block #29dd

Time

tnx back to the Unconfirmed pool

Check 3 - (last block recived)

18

Page 19: sfrontori-bitcoin-technical intro-meetup2014

Block

Block #w2a

Block #x89d

Block #c72s

Block #29dd

Time

Block

Check 3 - (last block recived)

19

Page 20: sfrontori-bitcoin-technical intro-meetup2014

Block Chain Branches - iteration 0

Node 1 Node 2 Node 3

branches branchesbranches

switch on the longest branch!

20

Page 21: sfrontori-bitcoin-technical intro-meetup2014

Block Chain Branches - iteration 1

Node 1 Node 2 Node 3

nB 1

nB 1

nB 1

branches branchesbranches

21

Page 22: sfrontori-bitcoin-technical intro-meetup2014

Node 1 Node 2 Node 3

nB1

nB1

nB1

branches branchesbranches

nB2

nB2

nB2

Block Chain Branches - iteration 2

22

Page 23: sfrontori-bitcoin-technical intro-meetup2014

Block Chain Branches - iteration 3

Node 1 Node 2 Node 3

nB2

nB1

nB2

branches branchesbranches

nB1

nB2

nB1

23

Page 24: sfrontori-bitcoin-technical intro-meetup2014

Check 5 - Double Spending with proof of work

Block 1 Block 2 Block 3 Block 4

Block 2A Block 3A Block 4A Block 5A

฿ A B

฿ A A

TimeBob box ship to Alice

Alice is trying to double spend her money

Alice self made chain

24

Page 25: sfrontori-bitcoin-technical intro-meetup2014

Check 5 - transaction order protected by race condition

Alice

Finish (validate)find x such that

f.hash (Block + x) < t

Time

10min

25

Page 26: sfrontori-bitcoin-technical intro-meetup2014

Where do bitcoins come from?

26

Page 27: sfrontori-bitcoin-technical intro-meetup2014

Mining - Incentive

BlBlock #w1q23… ! prev: #3w22e… !tnx 2dsf3… tnx 8yyt5… tnx 975rf3…

+ 25 ฿+ 50 ฿

+ 12.5 ฿+ 6.25 ฿

+ 0 ฿

27

Page 28: sfrontori-bitcoin-technical intro-meetup2014

28

Page 29: sfrontori-bitcoin-technical intro-meetup2014

Bitcoin miner address

29

Page 30: sfrontori-bitcoin-technical intro-meetup2014

30

Page 31: sfrontori-bitcoin-technical intro-meetup2014

Mining pool

31

Page 32: sfrontori-bitcoin-technical intro-meetup2014

Mining profitability?

mining hw cost + electricity cost (+ hw failures) -

mining reward =

profitability

32

Page 33: sfrontori-bitcoin-technical intro-meetup2014

bitcoin currency - (global info)

Last bitcoin will be mine on 2140 !

Total number bitcoin = 21.000.000 BTC !

Smallest unit (transferable)= 0.00000001 BTC !

6 Block in the chain confirmed, (1h) = tnx confirmed permanently

33

Page 34: sfrontori-bitcoin-technical intro-meetup2014

!!

TRUST 3rd party authority

CRYPTOGRAPHIC PROOF

NO Trust is needed

Recap

… ?

34

Page 35: sfrontori-bitcoin-technical intro-meetup2014

Questions ?

35