-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
552 lines (462 loc) · 20.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<!doctype html>
<html lang="en" ng-app="presentation">
<head>
<meta charset="utf-8">
<title>Elliptic Curve Intro</title>
<meta name="description" content="Presentation Template">
<meta name="author" content="Chad Cravens">
<link rel="stylesheet" target="_blank" href="css/index.css">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<img class="logo" src="./img/logo.png">
<div class="slides">
<section class="intro">
<h1 class="title">An Introduction to Elliptic Curve Cryptography</h1>
<hr>
<div class="med">Chad Cravens</div>
<div class="med">Open Source Systems</div>
</section>
<section>
<h1 class="title">Section 1 - A (very) brief introduction to cryptography</h1>
</section>
<section class="pivotal">
<h2>About This Presentation</h2>
<ol>
<li class="fragment">I am not a designer</li>
<li class="fragment">I am not a mathematician</li>
<li class="fragment">I am not a NSA cryptographer</li>
<li class="fragment">Focus on practical use cases for software developers</li>
</ol>
<div class="fragment">Oh yah, and this is not a presentation, but instead a discussion.</div>
</section>
<section class="pivotal">
<h2>3 Pivotal Moments in Human History</h2>
<ol>
<li class="fragment">Man Discovered Fire</li>
<li class="fragment">Man Invented the Wheel</li>
<li class="fragment">Man Invented Asymmetric Crypto Systems</li>
</ol>
<div class="fragment">ECC Is an Asymmetric Crypto System</div>
</section>
<section class="crypto">
<h2>What is Cryptography?</h2>
<div class="fragment">Cryptography is the practice and study of techniques for secure communication in the presence of third parties called adversaries.</div>
<div class="fragment">The process of hiding information is called "enciphering" or "encrypting".</div>
<div class="fragment">The process of revealing information is called "deciphering" or "decrypting".</div>
</section>
<section class="enciphering">
<h2>How is Encryption Done?</h2>
<img src="img/crypto-process.png">
<div class="small">
<a target="_blank" target="_blank" href="https://www.skyhighnetworks.com/cloud-security-university/tokenization-vs-encryption/">https://www.skyhighnetworks.com/cloud-security-university/tokenization-vs-encryption/</a>
</div>
</section>
<section class="vs">
<h2>3 Primary Types of Crypto Systems</h2>
<ol>
<li class="fragment">Hash Functions
<div>One-Way Functions</div>
</li>
<li class="fragment">Symmetric (Same Key, Block / Stream Ciphers)
<div>AES, 3DES, Blowfish</div>
</li>
<li class="fragment">Asymmetric
<div>RSA, ECC</div>
</li>
</ol>
</section>
<section class="symmetric">
<h2>Symmetric</h2>
<div>Uses the same key for enciphering as deciphering</div>
<img src="img/crypto-process.png">
</section>
<section class="problem">
<h2>What's the Problem?</h2>
<div class="fragment">Key Sharing</div>
<img src="img/key-exchange.png">
</section>
<section class="asymmetric">
<h2>What's the Solution? - Asymmetric</h2>
<div>Uses two different keys for enciphering and deciphering</div>
<ol>
<li class="fragment">Public Key</li>
<li class="fragment">Private Key</li>
</ol>
<div class="fragment">But why would we need this?</div>
</section>
<section class="asymmetric">
<h2>How is this done?</h2>
<div class="fragment">One-Way Trapdoor Function</div>
<div class="fragment">Easy to compute in one direction, but tough to reverse, unless you have special information (trap door)</div>
<div class="fragment">Modular Exponentiation</div>
<div class="fragment">$$ m^e mod(n) = C $$</div>
<div class="fragment">Given only C, n and e, how do we find m?</div>
</section>
<section class="asymmetric">
<h2>Example</h2>
<div class="fragment">$$ m^e mod(n) = C $$</div>
<div class="fragment">$$ 5^2 mod(7) = C $$</div>
<div class="fragment">Tell me C</div>
<div class="fragment">4!</div>
<div class="fragment">$$ m^3 mod(4) = 0 $$</div>
<div class="fragment">Now tell me m</div>
<div class="fragment">Give up...?</div>
<div class="fragment">it's 4!</div>
</section>
<section class="asymmetric">
<h2>But where's the trapdoor?</h2>
<div class="fragment">$$ m^e mod(n) = C $$</div>
<div class="fragment">We need to raise C to some exponent to "undo" what was done and get m, let's call it "d"</div>
<div class="fragment">$$ C^d mod(n) = m $$</div>
<div class="fragment">m^e^d mod(n) == m == m^ed mod(n)</div>
<div class="fragment">e is the encryption key, d is the decryption key</div>
<div class="fragment">need to construct e,d where it's difficult to find d</div>
</section>
<section class="asymmetric">
<h2>Creating the Trapdoor</h2>
<div class="fragment">Use a One-Way function to generate d from e</div>
<div class="fragment">"Hard" is defined in terms of time complexity (and energy usage)</div>
<div class="fragment">Use Prime factorization!</div>
<div class="fragment">Find prime factors of 12... go!</div>
<div class="fragment">4 x 3</div>
<div class="fragment">(2 x 2) x 3</div>
</section>
<section class="asymmetric">
<h2>Creating the Trapdoor (cont)</h2>
<div class="fragment">Find 2 prime numbers and multiply them to create N (easy)</div>
<div class="fragment">$$ P1 x P2 = N $$</div>
<div class="fragment">$$ 3 x 7 = 21 $$</div>
<div class="fragment">Hide N (21)</div>
<div class="fragment">Use a function that depends on knowing the factorization of N - Phi</div>
<div class="fragment">$ \phi $ (Euler's totient function) measures the "breakability" of a number</div>
<div class="fragment">$ \phi(N) $ Gives how many integers less than or equal to N that do not share any common factors with N</div>
</section>
<section class="asymmetric">
<h2>Creating the Trapdoor (cont)</h2>
<div class="fragment">$ \phi(8) $ = 4 [1,3,5,7]</div>
<div class="fragment">$ \phi(P) $ = P-1 for any prime number!</div>
<div class="fragment">$ \phi $ is also multiplicative</div>
<div class="fragment">$ \phi(AB) = \phi(A) \phi(B) $</div>
<div class="fragment">Therefore (remember our 2 primes e,d that we multiply and got N)</div>
<div class="fragment">$ \phi(N) = (e-1) * (d-1) $</div>
<div class="fragment">$ \phi(21) = (3-1) * (7-1) = 2 * 6 = 12 $</div>
</section>
<section class="asymmetric">
<h2>Creating the Trapdoor (cont)</h2>
<div class="fragment">How to connect phi function to modular exponentiation</div>
<div class="fragment">Use Euler's theorem - Congruency</div>
<div class="fragment">$ m^\phi(n) = 1 mod(n) $</div>
<div class="fragment">m = 5, n = 8</div>
<div class="fragment">$ 5^\phi(8) = 1 mod(8) $</div>
<div class="fragment">$ 1^k = 1 1*k = k $</div>
<div class="fragment">m^(k*phi(n) + 1) = m mod(n)</div>
<div class="fragment">Therefore it's easy to calculate d, only if the factorization of e is known (private key)</div>
</section>
<section class="vs">
<h2>Digital Signing</h2>
<div class="fragment">Assuming private key is private (core assumption)</div>
<img src="./img/digital-signature.png">
</section>
<section class="vs">
<h2>Key Sharing (Diffie Hellman)</h2>
<div class="fragment">Generating Shared Secret Key</div>
<row>
<div class="col-md-6">
<img src="./img/diffie-hellman.png">
</div>
<div class="col-md-6">
<img src="./img/key-share.png">
</div>
</row>
</section>
<section class="vs">
<h2>Challenge</h2>
<div>Use Crypto to Prove Your Identity</div>
</section>
<section>
<h1 class="title">Section 2 - Elliptic Curve Cryptography</h1>
</section>
<section class="curve">
<div>What is an Elliptic Curve?</div>
<div>$y^2 = x^3 + ax + b$</div>
<div>$a$ = -1, $b$ = 1
<div id="elliptic"></div>
</section>
<section class="enciphering">
<h2>More Concise</h2>
<div>$$\left\{ (x, y) \in \mathbb{R}^2\ |\ y^2 = x^3 + ax + b,\ 4 a^3 + 27 b^2 \ne 0 \right\}\ \cup\ \left\{ 0 \right\}$$</div>
<div class="small">This condition guarantees that the curve will not contain any singularities</div>
<img src="img/curves.png">
<div class="small">
<a target="_blank" href="http://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/">https://www.skyhighnetworks.com/cloud-security-university/tokenization-vs-encryption/</a>
</div>
</section>
<section class="enciphering">
<h2>How is this used for Crypto?</h2>
<div class="fragment">Define Group (Addition) $P + Q$</div>
<ol>
<li class="fragment">Closure: $a$, $b$, $a + b$ is a member of $\mathbb{G}$</li>
<li class="fragment">Associativity: $(a + b) + c = a + (b + c)$</li>
<li class="fragment">Identity Element: $a + 0 = 0 + a = a$</li>
<li class="fragment">Inverse: for every $a$ there exists $b$ such that $a + b = 0$</li>
<li class="fragment">Commutativity: $a + b = b + a$</li>
</ol>
<div class="fragment">Abelian Group</div>
</section>
<section class="">
<div>Applied to Elliptic Curves</div>
<ol class="fragment">
<li>Identity Element: point at infinity 0</li>
<li>Inverse: of point P is symmetric about x-axis</li>
</ol>
<div class="fragment">Addition is Given Points $P$,$Q$,$R$ their sum is $P + Q + R = 0$</div>
<div class="fragment">Therefore: $P + Q = -R$</div>
<row class="fragment">
<div class="col-md-6">
<img src="./img/ec-points.png">
</div>
<div class="col-md-6">
<img src="./img/animation-point-doubling.gif">
</div>
</row>
</section>
<section class="">
<div>Fast Addition</div>
<div>Ignoring corner cases such as P/Q=0, P=-Q, P=Q, etc</div>
<div>Scalar Multiplication: $$nP = P + P + \cdots + P$$</div>
<p>$$\begin{array}{rcl}
151 & = & 1 \cdot 2^7 + 0 \cdot 2^6 + 0 \cdot 2^5 + 1 \cdot 2^4 + 0 \cdot 2^3 + 1 \cdot 2^2 + 1 \cdot 2^1 + 1 \cdot 2^0 \\
& = & 2^7 + 2^4 + 2^2 + 2^1 + 2^0
\end{array}$$</p>
<p>$$151 \cdot P = 2^7 P + 2^4 P + 2^2 P + 2^1 P + 2^0 P$$</p>
</section>
<section class="curve">
<div>Elliptic Curve Types</div>
<div>a, b, p</div>
<ul class="fragment">
<li>a = -3</li>
<li>b = 41058363725152142129326129780047268409114441015993725554835256314039467401291</li>
<li>modulo p = 2^256 - 2^224 + 2^192 + 2^96 - 1</li>
</ul>
<div class="fragment">NIST P-256</div>
<img class="fragment" src="./img/skeptical.png">
</section>
<section class="curve">
<div>More Curve Types</div>
<ul>
<li>secp256k1</li>
<li>Curve25519</li>
<li>Curve383187</li>
<li>Curve41417</li>
</ul>
<div>For More Info on Safe Curve Types</div>
<a target="_blank" href="https://safecurves.cr.yp.to/">https://safecurves.cr.yp.to/</a>
</section>
<section class="keygen" ng-controller="ECCController">
<row>
<div class="col-sm-12">
Generating Key Pairs
</div>
</row>
<row>
<div class="col-sm-6">
<pre>
<code class="language-javascript">
var ec = new EC('secp256k1');
var key = ec.genKeyPair();
$scope.private = key.getPrivate('hex');
var pub = key.getPublic().encode('hex');
$scope.public = pub.substring(2,pub.length);
</code>
</pre>
</div>
<div class="col-sm-6">
<button ng-click="genKeypair()">Generate KeyPair</button>
<div>Private Key: {{ private.length }}</div>
<div class="small">{{ private }}</div>
<div>Public Key: {{ public.length }}</div>
<div class="small">{{ public }}</div>
</div>
</row>
<row>
<div class="col-sm-12 key">
Elliptic - <a target="_blank" target="_blank" href="https://github.com/indutny/elliptic">https://github.com/indutny/elliptic</a>
</div>
</row>
</section>
<section class="curve">
<div>Elliptic Curve Protocols</div>
<ol>
<li class="fragment">Elliptic Curve Diffie Hellman (ECDH)</li>
<li class="fragment">Elliptic Curve Digital Signature Algorithm (ECDSA)</li>
</ol>
</section>
<section class="curve">
<div>Elliptic Curve Diffie Hellman (ECDH)</div>
<p style="font-size: .5em;">is an anonymous key agreement protocol that allows two parties, each having an elliptic-curve public–private key pair, to establish a shared secret over an insecure channel.</p>
<ol>
<li class="fragment">Agree on parameters (curve type)</li>
<li class="fragment">Generate Keypair</li>
<li class="fragment">Share Public Key over Public Channel</li>
<li class="fragment">Generate Shared Secret</li>
</ol>
</section>
<section class="keygen" ng-controller="ECDHController">
<row>
<div class="col-sm-12">
ECDH
</div>
</row>
<row>
<div class="col-sm-6">
<pre>
<code class="language-javascript">
var ec = new EC('secp256k1');
var alicekp = ec.genKeyPair();
var bobkp = ec.genKeyPair();
$scope.alice = alicekp.derive(bobkp.getPublic()).toString(16);
$scope.bob = bobkp.derive(alicekp.getPublic()).toString(16);
</code>
</pre>
</div>
<div class="col-md-6">
<button ng-click="genSharedSecret()">Generate Shared Key</button>
<div>Alice</div>
<div class="small">{{ alice }}</div>
<div>Bob</div>
<div class="small">{{ bob }}</div>
</div>
</row>
</section>
<section class="keygen" ng-controller="ECDSAController">
<row>
<div class="col-sm-12">
ECDSA
</div>
</row>
<row>
<div class="col-sm-6">
<pre>
<code class="language-javascript">
var ec = new EC('secp256k1');
var kp = ec.genKeyPair();
$scope.msg = "Message Being Sign";
var signature = kp.sign($scope.msg);
$scope.derSign = signature.toDER();
var pubPoint = kp.getPublic();
var x = pubPoint.getX();
var y = pubPoint.getY();
var pub = pubPoint.encode('hex');
var key = ec.keyFromPublic(pub, 'hex');
$scope.valid = key.verify($scope.msg, signature);
</code>
</pre>
</div>
<div class="col-md-6">
<button ng-click="verifySignature()">Verify Signature</button>
<div class="med">Message: "{{ msg }}"</div>
<div class="med">Valid: {{ valid ? 'valid' : 'not valid' }}</div>
</div>
</row>
</section>
<section>
<h1 class="title">Section 3 - Elliptic Curve Implementations</h1>
</section>
<section class="curve">
<div>ECC Pros</div>
<ol>
<li class="fragment">Smaller Key Sizes / Efficiencies</li>
<li class="fragment">Suggested "Next Gen" Crypto System at BlackHat / by NSA</li>
</ol>
<div class="fragment">ECC Cons</div>
<ol>
<li class="fragment">Proprietary Technologies</li>
<li class="fragment">Complexity</li>
<li class="fragment">Not Proven</li>
<li class="fragment">Known Exploits (NSA)</li>
</ol>
</section>
<section class="curve">
<div>Key Size Comparison</div>
<table style="margin: auto; width: 25%">
<tr>
<th>RSA (bits)</th>
<th>ECC (bits)</th>
</tr>
<tr>
<td>1024</td>
<td>160</td>
</tr>
<tr>
<td>2048</td>
<td>224</td>
</tr>
<tr>
<td>3072</td>
<td>256</td>
</tr>
<tr>
<td>7680</td>
<td>384</td>
</tr>
<tr>
<td>15360</td>
<td>521</td>
</tr>
</table>
</section>
<section class="curve">
<div>Sony PS3 Hack</div>
<div class="fragment">Applications have to be signed before running on Playstation consoles (signed by Sony PS)</div>
<div class="fragment">Sony reused a random number to generate the signature</div>
<div class="fragment">A well known attack was used to derive private key, this key was published</div>
<a target="_blank" href="https://events.ccc.de/congress/2010/Fahrplan/events/4087.en.html">https://events.ccc.de/congress/2010/Fahrplan/events/4087.en.html</a>
</section>
<section class="curve">
<div>NSA Backdoor - Dual_EC_DRBG</div>
<div class="fragment">Algorithm presented as a cryptographically secure PRNG</div>
<div class="fragment">NIST SP 800-90A Standard from 2006 - 2014, when it was redacted</div>
<div class="fragment">A backdoor was revealed with the Edward Snowden leaks</div>
</section>
<section class="curve">
<div>Bitcoin</div>
<div class="fragment">Bitcoin uses ECC</div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/bBC-nXj3Ng4" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</section>
<section class="curve">
<div>Cloudflare - Lava Lamps</div>
<div class="fragment">Importance of Random Numbers for ECC</div>
<div class="fragment">Wall of Lava Lamps protects about 10% of the Internet's traffic</div>
<img class="logo" src="./img/lava-lamps.png">
</section>
<section class="curve">
<div>Notes from Developer to Developer</div>
<ol>
<li class="fragment">Choose your curve wisely</li>
<li class="fragment">"Randomness" is important!</li>
<li class="fragment">Just because government endorses it, doesn't mean you can trust it!</li>
<li class="fragment">Just keep learning!</li>
</ol>
</section>
<section class="curve">
<div>Resources</div>
<a class="med" target="_blank" href="https://www.johannes-bauer.com/compsci/ecc/">https://www.johannes-bauer.com/compsci/ecc/</a>
<a class="med" target="_blank" href="http://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/">http://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/</a>
<a class="med" target="_blank" href="https://www.edn.com/design/consumer/4368066/The-Sony-PlayStation-3-hack-deciphered-what-consumer-electronics-designers-can-learn-from-the-failure-to-protect-a-billion-dollar-product-ecosystem">https://www.edn.com/design/consumer/4368066/The-Sony-PlayStation-3-hack-deciphered-what-consumer-electronics-designers-can-learn-from-the-failure-to-protect-a-billion-dollar-product-ecosystem</a>
<a class="med" target="_blank" href="https://en.wikipedia.org/wiki/Dual_EC_DRBG">https://en.wikipedia.org/wiki/Dual_EC_DRBG</a>
</section>
</div>
</div>
<script src="js/bundle.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</body>
</html>