Bitcoin II & Introduction to Elliptic Curve Cryptography Sep. - - PowerPoint PPT Presentation

bitcoin ii introduction to elliptic curve cryptography
SMART_READER_LITE
LIVE PREVIEW

Bitcoin II & Introduction to Elliptic Curve Cryptography Sep. - - PowerPoint PPT Presentation

Bitcoin II & Introduction to Elliptic Curve Cryptography Sep. 11, 2019 Overview Bitcoin Transactions Elliptic Curve Cryptography Introduction Arithmetics Signature Bitcoin, the protocol A blockchain Each


slide-1
SLIDE 1

Bitcoin II & Introduction to Elliptic Curve Cryptography

  • Sep. 11, 2019
slide-2
SLIDE 2

Overview

  • Bitcoin
  • Transactions
  • Elliptic Curve Cryptography
  • Introduction
  • Arithmetics
  • Signature
slide-3
SLIDE 3

Bitcoin, the protocol

  • A blockchain
  • Each block has a definite history
  • Nonce
  • Proof-of-work to make block building hard
  • The Merkle tree stores a set of transactions
slide-4
SLIDE 4

Bitcoin, the currency

  • A Bitcoin (the currency, ₿) is a number
  • Created when mining blocks (finding nonce)
  • The person finding a nonce so that H(block) < adds a Coinbase

transaction

  • Adding 12.5₿ to his wallet (!?!)
  • amount used to larger, will decrease to 6.25 in May 2020
  • 21 million ₿ in total
  • 17.9M in existence
  • Cap will be reached by 2140
  • Afterwards, miners get rewarded in transaction fees only

ε

slide-5
SLIDE 5

Bitcoin, the currency

  • A Bitcoin (the currency, ₿) is a number
  • Created when mining blocks (finding nonce)
  • The person finding a nonce so that H(block) < adds a Coinbase

transaction

  • Adding 12.5₿ to his wallet (!?!)
  • amount used to larger, will decrease to 6.25 in May 2020
  • 21 million ₿ in total
  • 17.9M in existence
  • Cap will be reached by 2140
  • Afterwards, miners get rewarded in transaction fees only

ε

What does this mean?

slide-6
SLIDE 6

Bitcoin Ownership

  • Ownership is implemented via cryptographic signatures
  • Every person own a public key and a private key
  • Ownership means
  • You have the private key of a signature
slide-7
SLIDE 7

Bitcoin Transactions

  • To transfer money to another person, one needs to show
  • Point to (a set of) input amount
  • Demonstrate that you own the input amounts
  • Know private key of input
  • Publish a set of outputs

₿ ₿

₿ ₿ ₿

Tx

inputs

  • utputs
slide-8
SLIDE 8

Bitcoin Transactions

  • All inputs are completely consumed
  • If output is larger than needed, return the rest to you

₿ ₿

₿ ₿ ₿

Tx

inputs

  • utputs
slide-9
SLIDE 9

Bitcoin Transaction

Out 0 Out 1

  • is fee to miner

∑ inputs − ∑ outputs

transactions where Bitcoin come from

Out 2

  • utputs

ID of this transaction is its hash tx 0xa435… In 0 tx 0x285d… In 3

slide-10
SLIDE 10

Bitcoin Transactions

  • Output field:
  • Value
  • Some requirement that has to be fulfilled to claim the output
  • Can be complicated script or open to anyone
  • Input fields:
  • Transaction ID
  • Which output in that transaction
  • Proof that the conditions are fulfilled
slide-11
SLIDE 11

Transfer money A -> B

  • Input

has information about , public key of A

  • A creates a new script, saying that only someone who

knows the secret key corresponding to the hash of (public key of B) can spend the money

  • provide message + public key

In1 pkA pkB

slide-12
SLIDE 12

Transactions

Input: Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6 Index: 0 scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10 90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6 b241501 Output: Value: 5000000000 scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG

slide-13
SLIDE 13

Transactions

Input: Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6 Index: 0 scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10 90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6 b241501 Output: Value: 5000000000 scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG

Transaction ID showing the funding source Output 0 within that transaction Proof of meeting the requirements of that output Output value (in 1/100,000,000 ₿) Script to unlock the output value

  • This transaction is funded by tx f5d8… output 0, use inputs 3045… and 90db00… as

inputs to that script

  • Pay 5.00₿ to whoever can run the “OP_DUP…” script successfully.
slide-14
SLIDE 14

Transactions

scriptPubKey scriptSig

Output of funding transaction specifies script to execute Input of new transaction provides data for that script

slide-15
SLIDE 15

Transaction scripts

  • Scripts are executed as a stack machine
  • Last In - First Out
  • E.g. OP_PLUS : “Take last to

element on the stack, add them, and put the result back on the stack”

2 5

  • 2

3 1 7

  • 2

3 1

OP_PLUS

slide-16
SLIDE 16

Transaction scripts Stack machine

  • scriptPubKey:

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

Duplicate element on top of stack Hash element on top of stack Push these 20 numbers onto the stack Verify that the top 2 numbers on the stack are identical Check that the signature is correctly signed by public key

slide-17
SLIDE 17

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

  • scriptSig

ae0e854281abd38bacd1aeed3ee3e5tadf73 0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c

slide-18
SLIDE 18

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c ae0e854281abd38bacd1aeed3ee3e5tadf73

slide-19
SLIDE 19

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c ae0e854281abd38bacd1aeed3ee3e5tadf73 ae0e854281abd38bacd1aeed3ee3e5tadf73

slide-20
SLIDE 20

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c ae0e854281abd38bacd1aeed3ee3e5tadf73 404371705fa9bd789a2f

slide-21
SLIDE 21

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c ae0e854281abd38bacd1aeed3ee3e5tadf73 404371705fa9bd789a2f 404371705fa9bd789a2f

slide-22
SLIDE 22

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6c ae0e854281abd38bacd1aeed3ee3e5tadf73

slide-23
SLIDE 23

Transaction scripts Stack machine

  • scriptPubKey

OP_DUP OP_HASH160 PUSHDATA(20)404371705fa9bd789a2f OP_EQUALVERIFY OP_CHECKSIG

OK if signature

  • public key = ae0e…
  • message = Hash(this transaction)
  • signature = 0e88ff…

is correct

slide-24
SLIDE 24

Transaction Chain

slide-25
SLIDE 25

Transactions

  • Pay-to-Pubkey-Hash
  • Provide a public key and a signature to claim money
  • Pay-to-Script-Hash
  • Provide input to arbitrary script
  • preimage (given y, pay to whoever knows x with y=H(x))
  • Long list of other operators

Code Description OP_1ADD 1 is added to the input. OP_1SUB 1 is subtracted from the input. OP_2MUL The input is multiplied by 2.disabled. OP_HASH256 The input is hashed two times with SHA-256. OP_CHECKSIG The signature must be a valid signature hash(tx) and public key. OP_CHECKMULTISIG Compares the first signature against each public key

slide-26
SLIDE 26

Elliptic Curve Cryptography

A basic introduction

slide-27
SLIDE 27

What is an elliptic curve

  • Consider the polynom

x3 + ax + b

slide-28
SLIDE 28

What is an elliptic curve

  • Consider the polynom
  • For

and we get

  • x3 + ax + b

a = − 2 b = 2 y = x3 − 2a + 2

slide-29
SLIDE 29

What is an elliptic curve

  • For which points on the xy-plane do we have
  • For

and we get

  • y2 = x3 + ax + b

a = − 2 b = 2 y2 = x3 − 2a + 2

slide-30
SLIDE 30

Points on an elliptic curve

  • Any point

for which is a point

  • Easy to verify

p = (x, y) y2 = x3 + ax + b

slide-31
SLIDE 31

Adding points

  • Given 2 points

and

p = (x, y) q = (u, v)

slide-32
SLIDE 32

Adding points

  • Given 2 points

and

  • Draw a line crossing those points

p = (x, y) q = (u, v)

slide-33
SLIDE 33

Adding points

  • Given 2 points

and

  • Draw a line crossing those points
  • Mark the 3 point of intersection with the curve

p = (x, y) q = (u, v)

slide-34
SLIDE 34

Adding points

  • Given 2 points

and

  • Draw a line crossing those points
  • Mark the 3 point of intersection with the curve
  • Flip the point up/down

p = (x, y) q = (u, v)

slide-35
SLIDE 35

Adding points

  • Given 2 points

and

  • Draw a line crossing those points
  • Mark the 3 point of intersection with the curve
  • Flip the point up/down

p = (x, y) q = (u, v)

=

+

slide-36
SLIDE 36

Adding points

  • Given 2 points

and

  • Draw a line crossing those points
  • Mark the 3 point of intersection with the curve
  • Flip the point up/down

p = (x, y) q = (u, v)

slide-37
SLIDE 37

Adding points

  • Given 2 points

and

  • Draw a line crossing those points
  • Mark the 3 point of intersection with the curve
  • Flip the point up/down

p = (x, y) q = (u, v)

slide-38
SLIDE 38

Adding points

  • Definition not complete
slide-39
SLIDE 39

Adding points

  • Definition not complete
  • => add ±∞
slide-40
SLIDE 40

Adding points

?

  • Definition not complete
slide-41
SLIDE 41

Adding points

?

  • Definition not complete
  • Limit of getting closer and closer to that point
slide-42
SLIDE 42

Adding points

?

  • Definition not complete
  • Limit of getting closer and closer to that point
slide-43
SLIDE 43

Adding points

  • To add a point to itself, take the limit of 2 points getting

closer and closer (the tangent of the curve at that point)

The same point twice

slide-44
SLIDE 44

Adding points

  • Let’s add a point

2 times to itself

p = (x, y)

p 2p

slide-45
SLIDE 45

Adding points

  • Let’s add a point

3 times to itself

p = (x, y)

p 2p 3p

slide-46
SLIDE 46

Adding points

  • Let’s add a point

4 times to itself

p = (x, y)

p 3p 4p

slide-47
SLIDE 47

Adding points

  • Let’s add a point

5 times to itself

p = (x, y)

p 5p 4p

slide-48
SLIDE 48

Point arithmetic on elliptic curve

  • Using this definition, addition is well defined
  • P+Q = Q+P
  • P+(Q+R) = (P+Q)+R
  • P+0 = P

, point 0 is the one at

  • This is the reason we “mirror” the point on the x-axis
  • -P = defined similarly

±∞

slide-49
SLIDE 49

Adding points

  • Point subtraction p − q

p q

slide-50
SLIDE 50

Adding points

  • Point subtraction p − q

p q

slide-51
SLIDE 51

Adding points

  • Point subtraction p − q

p q p − q

slide-52
SLIDE 52

Points on elliptic curves

  • The entire math of ECC is based on adding points
  • A point

can be added to itself, the new point is

  • Added times to itself results in point
  • Points can be added very fast
  • As a side node, for ECC-based cryptography, everything ‘happens’
  • A point is on a curve iff
  • Point arithmetics are still well defined

G H = 2G k F = kG mod n y2 mod n = x3 + ax + b mod n