ecc part ii smart contracts
play

ECC (Part II) & Smart Contracts Sep. 16, 2019 Overview - PowerPoint PPT Presentation

ECC (Part II) & Smart Contracts Sep. 16, 2019 Overview Cryptography with ECC How to send secret messages Bitcoins Stack Machine scripts Review Limitations Ethereums answer to those limitations


  1. ECC (Part II) & Smart Contracts Sep. 16, 2019

  2. Overview • Cryptography with ECC • How to send secret messages • Bitcoin’s “Stack Machine” scripts • Review • Limitations • Ethereum’s answer to those limitations • Applications • Programming Language “Solidity” • Examples • Advantages/Disadvantages

  3. Elliptic Curve Cryptography (Part II)

  4. Points on elliptic curve • Points can be added � P + Q • Points can be added � times � n nP • Points can be subtracted � P − Q Q P P+Q

  5. 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 � G H = 2 G • Added � times to itself results in point � F = kG k • Points can be added very fast • As a side node, for ECC-based cryptography, everything ‘happens’ � mod n • A point is on a curve i ff y 2 mod n = x 3 + ax + b mod n � • Point arithmetics are still well defined

  6. � Elliptic curve mod p p ∈ PRIMES

  7. � Elliptic curve mod p p ∈ PRIMES

  8. � Elliptic curve mod p p ∈ PRIMES P+Q P Q

  9. � Inverse addition problem � H � G • Given two points, � , find � so that � G , H a ∈ ℤ p H = aG • How often to I need to add � itself to reach � ? p = ( x , y ) q

  10. � Inverse addition problem � H � G • Super hard, we just can’t do it e ffi ciently

  11. � Inverse addition problem � H � G • Super hard, we just can’t do it e ffi ciently • NSA supposedly convinced software vendors to use special random number generators that made points predictable

  12. � Inverse addition problem � H � G • Super hard, we just can’t do it e ffi ciently • NSA supposedly convinced software vendors to use special random number generators that made points predictable • Quantum computer can solve this e ffi ciently

  13. � Inverse addition problem � H � G • Super hard, we just can’t do it e ffi ciently • NSA supposedly convinced software vendors to use special random number generators that made points predictable • Quantum computer can solve this e ffi ciently • For now, we this this is a di ffi cult problem

  14. Notation • We have one operations: combining 2 points • Before we used the symbol “+” for this • � P + Q , H = aG , etc. • We can also re-use the multiplication notation � ⋅ • � g ⋅ h , g a

  15. Notation • ECC math appears in 2 di ff erent notations • adding points, written as addition and multiplication • � P + Q , H = aG , etc. • Usually this goes with the following standard: • Numbers: lowercase characters • Points: uppercase characters • Often in introductory texts, blogs, emails (easy to type) • multiplying points, written as multiplication and exponentiation • � g ⋅ h , g a • Usually this goes with the following standard: • Everything lowercase • exponents (integers) as Greek letters • Often in scientific texts a b mod n • Correlation to other fields better visible (cf. � ) x • Better readability for complex operations, e.g. � ( g a h γ )

  16. Notation “ A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines. With consistency a great soul has simply nothing to do.” — Ralph Waldo Emerson (poet) ⇒ We will use additive and multiplicative notations in this course

  17. Discrete Logarithm • In scientific notation, the hard problem is y = g a mod n Find � , so that � a • called Discrete Logarithm

  18. � Summary ECC Point Math • The entire math of ECC is based on adding points • A point � can be added to itself, the new point is � G H = 2 G • Added � times to itself results in point � k F = kG • Points can be added very fast • Inverse problem: • Given a base point � and a second point � , it is not G R possible to e ffi ciently compute integer � so that r ∈ ℤ p R = rG

  19. RSA & ECC y = g a mod n � • Given � and � g a • compute � : easy y • Given � and � y g • compute � : hard a • Given � and � y a • compute � : hard g

  20. RSA & ECC y = g a mod n � • Given � and � g a • compute � : easy y • Given � and � y g • compute � : hard a • Given � and � y a • compute � : hard g One popular curve (Curve25519) has � points 7.237 ⋅ 10 75 ( 7237005577332262213973186563042994240857116359379907606001950938285455250989 )

  21. � Cryptography with ECC • Known parameters • � for curve a , b ∈ ℤ , n ( y 2 mod n ) = ( x 3 + ax + b mod n ) • starting point � on that curve G • Private key • random number � (does not have to be prime) n ∈ ℕ • Public key • Point � nG

  22. Cryptography with ECC • Di ffi e-Hellman (DH) Key exchange • Alice: sk=a, pk=aG • Bob: sk=b, pk=bG • exchange of public keys • Alice sends aG to Bob • Bob sends bG to Alice Whitfield Di ffi e and Martin Hellman • Alice can now compute a(bG)=(ab)G • Bob can now compute b(aG)=(ba)G • Only Alice and Bob know point (ab)G! No one else does

  23. Cryptography with ECC Alice Bob aG b(aG) • After exchange, Alice and Bob know (ab)G bG a(bG) • Alice can now send the point Q=P+(ab)G to Bob • Bob can extract the point P = Q-(ab)G Q=P+a(bG) Q • Nobody, even when listening to all communication, can compute the point P . All they see is Q P=Q-b(aG)

  24. Cryptography with ECC • Alice can send the point P to Bob • P is known to only Alice & Bob • P is a point (x,y), i.e. all I need to do in to encode my secret message as a point • often used DH to share a di ff erent key for other cryptography systems • One way is to encode message as y coordinate and compute x

  25. Cryptography with ECC Summary • Points on a curve • A method to combine points • Well defined operation, some use “+", others use “*” • Inverse operation (discrete logarithm) is very hard • Di ffi e-Hellman key exchange • Find a new point, only known to Alice and Bob • Usable to send secret messages • Signatures, Arithmetics, Zero-Knowledge • Will be introduces throughout the course

  26. Bitcoin’s Stack Machine • Verify public/private key • Given y=H(pk) , msg • Require sig, pk : verify(pk, msg, sig)=True AND y=H(pk) • Show that you own private key to (the hash of) a public key Program (scriptPubKey) Init state of stack (scriptSig) 1. Duplicate top element public Key 2. Hash top element 3. Push compare value onto stack 4. Verify that the two top elements are equal signature 5. Verify that (sign., pk, transactionData) is valid

  27. Bitcoin’s Stack Machine • Verify preimage of a hash • Given y • Require x: y=H(x) • Pay to whoever knows the preimage of a hash Program (scriptPubKey) Init state of stack (scriptSig) 1. Hash top element 2. Push compare value onto stack 3. Verify that the two top elements are equal data

  28. Bitcoin’s Stack Machine • Require several parties to agree on a transaction • Multi-signature • Pay if all / 3-out-of-5 / n -out-of- m signatures are present Program (scriptPubKey) Init state of stack (scriptSig) 1. Push value n onto the stack (i.e. 2) 2. Push pubKey1 3. Push pubKey2 4. Push pubKey3 5. … one signature 6. Push value m onto the stack (i.e. 3) 7. Check n -out-of- m multiSig another signature

  29. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) Init state of stack (scriptSig) 1. Push value 3 onto the stack 2. Push pubKey1 3. Push pubKey2 4. Push pubKey3 5. Push pubKey4 6. Push pubKey5 7. Push value 5 onto the stack 8. Check n -out-of- m multiSig signature E signature A signature C

  30. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) Init state of stack (scriptSig) 1. Push value 3 onto the stack 2. Push pubKey1 3. Push pubKey2 4. Push pubKey3 5. Push pubKey4 6. Push pubKey5 7. Push value 5 onto the stack 8. Check n -out-of- m multiSig 3 signature E signature A signature C

  31. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) Init state of stack (scriptSig) 1. Push value 3 onto the stack 2. Push pubKey1 3. Push pubKey2 4. Push pubKey3 5. Push pubKey4 6. Push pubKey5 7. Push value 5 onto the stack pubKey1 8. Check n -out-of- m multiSig 3 signature E signature A signature C

  32. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) Init state of stack (scriptSig) 1. Push value 3 onto the stack 2. Push pubKey1 3. Push pubKey2 4. Push pubKey3 pubKey4 5. Push pubKey4 … 6. Push pubKey5 7. Push value 5 onto the stack pubKey1 8. Check n -out-of- m multiSig 3 signature E signature A signature C

  33. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) 1. Push value 3 onto the stack 2. Push pubKey1 pubKey5 3. Push pubKey2 4. Push pubKey3 pubKey4 5. Push pubKey4 … 6. Push pubKey5 7. Push value 5 onto the stack pubKey1 8. Check n -out-of- m multiSig 3 signature E signature A signature C

  34. Bitcoin’s Stack Machine 3-out-of-5 signatures are present Program (scriptPubKey) 5 1. Push value 3 onto the stack 2. Push pubKey1 pubKey5 3. Push pubKey2 4. Push pubKey3 pubKey4 5. Push pubKey4 … 6. Push pubKey5 7. Push value 5 onto the stack pubKey1 8. Check n -out-of- m multiSig 3 OP_CHECKMULTISIG : read m signature E read m public keys read n signature A read n signatures return TRUE if all signatures can be verified signature C (no duplicates)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend