Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Just Enough Math to Understand Elliptic Curve Cryptography

Just Enough Math to Understand Elliptic Curve Cryptography

Elliptic Curve Cryptography is used in many real world protocols like TLS, SSH, IPsec, Whatsapp, Bitcoin and many more.

Trying to build an understanding of how it works, however, can be fairly daunting for anyone who doesn't have a deep mathematics background. This talk walks through just enough math needed to understand how the most common Elliptic Curve Cryptography primitives work.

Mrinal Wadhwa

March 04, 2020
Tweet

More Decks by Mrinal Wadhwa

Other Decks in Programming

Transcript

  1. Elliptic Curve Cryptography Mrinal Wadhwa @mrinal Just enough math, to

    understand: Ockam ockam.io/team
  2. Banking, Commerce, Communication … The systems, we build, rely on

    various cryptographic protocols to ensure integrity and confidentiality of data that flows within them. Systems
  3. Banking, Commerce, Communication … PKI, TLS, SSH, Wiregaurd, Signal, Bitcoin

    … The systems, we build, rely on various cryptographic protocols to ensure integrity and confidentiality of data that flows within them. Systems Protocols
  4. Banking, Commerce, Communication … These protocols are, in turn, constructed

    by combining well defined cryptographic primitives - key agreement, signatures etc. PKI, TLS, SSH, Wiregaurd, Signal, Bitcoin … ECDH, EcDSA, EdDSA, Schnorr … Systems Protocols Primitives
  5. Banking, Commerce, Communication … The primitives themselves often need a

    hard to reverse operation, which with elliptic curves is usually scalar multiplication. PKI, TLS, SSH, Wiregaurd, Signal, Bitcoin … ECDH, EcDSA, EdDSA, Schnorr … Scalar Multiplication Systems Protocols Primitives Hard to reverse operation
  6. Banking, Commerce, Communication … Scalar multiplication involves two group operations

    - point addition and doubling. PKI, TLS, SSH, Wiregaurd, Signal, Bitcoin … ECDH, EcDSA, EdDSA, Schnorr … Scalar Multiplication Point Addition, Point Doubling Systems Protocols Primitives Hard to reverse operation Group Operations
  7. Systems Banking, Commerce, Communication … Protocols PKI, TLS, SSH, Wiregaurd,

    Signal, Bitcoin … Primitives ECDH, EcDSA, EdDSA, Schnorr … Hard to reverse operation Scalar Multiplication Group Operations Point Addition, Point Doubling Modular Arithmetic Addition, Subtraction, Multiplication and Inversion.
  8. Most number sets, that we’re used to, are infinite -

    natural numbers, real numbers etc. Elliptic Curve Cryptography, however, relies on arithmetic within a finite set of numbers.
  9. {, , , , } For example we may want

    the result, of adding any two numbers in this set, to also be in this set.
  10. {, , , , } 1+3 =4 is easy because

    the result 4 is in our set. + =
  11. {, , , , } But, 3+4=7 is not in

    the set. + =
  12. Modular Arithmetic. Modular arithmetic is way of keeping the result

    in our finite set.
  13. {, , , , } + ≡ mod Perform regular

    integer arithmetic as long as the result is smaller than 5.
  14. {, , , , } + ≡ Perform regular integer

    arithmetic, if the result is greater than 5, divide the result by 5. This remainder is the new result.
  15. None
  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. Calculating a multiplicative inverse.

  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. ≡ + + mod Elliptic Curve over a Finite Field.

  37. ≡ + + mod Elliptic Curve over a Finite Field.

  38. None
  39. Curve P-256 / NIST P256 / secp256r1 / prime256v1

  40. None
  41. Group Operations Point Addition & Doubling

  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. Scalar Multiplication Multiply a Point with a scalar.

  49. Really means ADD a point to itself scalar times.

  50. None
  51. None
  52. None
  53. Diffie-Hellman Key Exchange

  54. None
  55. None
  56. None
  57. ECDH - Elliptic Curve Diffie-Hellman

  58. ECDH - Elliptic Curve Diffie-Hellman

  59. ECDH - Elliptic Curve Diffie-Hellman

  60. ECDH - Elliptic Curve Diffie-Hellman

  61. ECDH - Elliptic Curve Diffie-Hellman

  62. Systems Banking, Commerce, Communication … Protocols PKI, TLS, SSH, Wiregaurd,

    Signal, Bitcoin … Primitives ECDH, EcDSA, EdDSA, Schnorr … Hard to reverse operation Scalar Multiplication Group Operations Point Addition, Point Doubling Modular Arithmetic Addition, Subtraction, Multiplication and Inversion.
  63. None
  64. Use: Tink, Golang Crypto, Rust Crypto, BearSSL, dalek-cryptography … Don’t

    use any of this code in your app! https://gist.github.com/mrinalwadhwa/1b3c0a6c6da74065d2baf755a8fc90e8 ECDH - Elliptic Curve Diffie-Hellman key exchange implemented from scratch with everything we learnt in this talk
  65. Mrinal Wadhwa Ockam @mrinal Cryptography Meetup @CryptographySF meetup.com/Cryptography-Meetup ockam.io/team