Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
暗号技術を支える素数
Search
Shohei Yamasaki
September 07, 2015
Programming
2
3k
暗号技術を支える素数
2015/9/4 プログラマのための数学勉強会で発表したスライドです。
Shohei Yamasaki
September 07, 2015
Tweet
Share
More Decks by Shohei Yamasaki
See All by Shohei Yamasaki
AMPで爆速WEBサイト
shoyan
0
160
ハフマン木の作成
shoyan
0
13k
PHPコーディング規約とサポートするツール
shoyan
2
3.4k
コンピュータと数学
shoyan
0
1.5k
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
630
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
React への依存を最小にするフロントエンド設計
takonda
7
1.6k
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
Outline View in SwiftUI
1024jp
1
340
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
みんなでプロポーザルを書いてみた
yuriko1211
0
280
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
GitHub's CSS Performance
jonrohan
1030
460k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Speed Design
sergeychernyshev
25
620
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Adopting Sorbet at Scale
ufuk
73
9.1k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Designing Experiences People Love
moore
138
23k
Transcript
҉߸ٕज़Λࢧ͑Δૉ ϓϩάϥϚͷͨΊͷֶษڧձ@Ԭ 2015.09.04 @shoyan
4IPIFJ:BNBTBLJ !TIPZBO • ϓϩάϥϚʔ • 2ࣇͷ • GMOϖύϘ
࣍ • ҉߸ٕज़ʹ͍ͭͯ • ެ։伴҉߸ʹ͍ͭͯ • RSA҉߸ͷ҆શੑʹ͍ͭͯ • ҉߸ֶతͳʹ͍ͭͯ •
·ͱΊ
҉߸ٕज़ʹ͍ͭͯ
Πϯλʔωοτͷ • ใͷ౪ௌ • ใͷվ͟Μ • ͳΓ͢·͠
͜ΕΒͷΛղܾ͢ΔͨΊʹ ҉߸ٕज़͕ΘΕ͍ͯΔ
҉߸ٕज़ͭʹྨ͞ΕΔ
ใΛಡΉ͜ͱ͕Ͱ͖ͳ͍Α͏ʹ ͢ΔͨΊͷ҉߸ٕज़ • ౪ௌऀ͕ใΛݟͯɺ༰͕Θ͔Βͳ͍Α ͏ʹ͢Δ • SSL / TLS •
SSH • IPsec
ใ͕վ͟Μ͞Ε͍ͯͳ͍͜ͱΛ֬ ೝ͢ΔͨΊͷ҉߸ٕज़ • ૹΒΕ͖ͯͨใ͕ਖ਼͍͠ใ͔Ͳ͏͔Λ νΣοΫ͢ΔʹɺϋογϡνΣοΫΛ༻͍ Δ • SHA-1 • MD5
ใΛૹͬͨ૬खΛ֬ೝ͢ΔͨΊͷ ҉߸ٕज़ • ใΛૹ৴ͨ͠૬ख͕ਖ਼͍͠૬ख͔Ͳ͏͔Λ νΣοΫ͢Δɻిࢠॺ໊ͱݺΕΔํ๏͕͋ Δ • ೝূہʹిࢠূ໌ॻΛൃߦͯ͠Β͏ • https௨৴Ͱར༻͞Ε͍ͯΔ
ެ։ݤ҉߸ʹ͍ͭͯ
ެ։ݤ҉߸ • ΠϯλʔωοτͰ࠷ΘΕ͍ͯΔ҉߸ٕज़ • ใͷ౪ௌΛ͙҉߸ٕज़ిࢠূ໌ॻͷੜ ʹΘΕ͍ͯΔ
ެ։ݤ҉߸ • ެ։伴Λͬͯ҉߸Խ͢Δ • ൿີ伴Λͬͯ෮߸Խ͢Δ • ड৴ऀ͋Β͔͡Ίެ։伴Λૹ৴ऀʹ͓ͯ͠ ͘ • ެ։伴Ͱ෮߸ԽͰ͖ͳ͍ͷͰ౪ௌ͞Εͯ
ͳ͍
ެ։ݤ҉߸ํࣜͰ࠷ීٴ͍ͯ͠Δ 34" • ϚανϡʔηοπՊେֶͷRon Rivestɺ Adi ShamirɺLeonard Adlemanͷ3ਓ͕։ൃ • 3ਓͷ։ൃऀͷ಄จࣈ͔ΒRSA҉߸ํࣜͱ໋໊
͞Εͨ
ެ։ݤͱൿີݤͷੜ • ൿີ伴ͱެ։伴ϖΞʹͳ͍ͬͯΔඞཁ͕͋ Γɺ͜ͷ2ͭͷΩʔͷ͜ͱΛΩʔϖΞͱݺͿ
ΩʔϖΞͷੜखॱ PͱQΛͬͯNΛܭࢉ͢Δ PͱQΛͬͯLΛܭࢉ͢Δ LΛͬͯEΛܭࢉ͢Δ EͱLΛͬͯDΛܭࢉ͢Δ
1ͱ2Λͬͯ/Λܭࢉ͢Δ • ʮPʯͱʮQʯͷ2ͭͷૉΛ४උ͢Δ • ͕খ͗͢͞Δͱղಡ͕༰қʹͳͬͯ͠·͏ • ͕େ͖͗͢Δͱॲཧʹ͕͔͔࣌ؒΔ • 1024 -
4096Ϗοτ(10ਐͰ300-1000ܻఔ) ͕ਪ͞Ε͍ͯΔ
ૉͱ • ૉͱ1ͱࣗࣗҎ֎ʹਖ਼ͷΛ࣋ͨͳ ͍ࣗવͰɺ1Ͱͳ͍ͷ͜ͱ ҎԼͷૉ • 2, 3, 5, 7,
11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
Τϥτεςωεͷ;Δ͍ • ࢦఆ͞ΕͨxҎԼͷશͯͷૉΛൃݟ͢Δ ΞϧΰϦζϜ • ݹΪϦγϟͷՊֶऀɺΤϥτεςωε͕ ߟҊͨ͠ • ͍·ݱͰΘΕ͍ͯΔํ๏
/ /VNCFS ͷܭࢉࣜ N = P ✖ Q N =
13 ✖ 17 N= 221 • ʮPʯΛʮ13ʯɺʮQʯΛʮ17ʯͱͯ͠ʮNʯ Λܭࢉ͢Δ
1ͱ2Λͬͯ- -$.-FBTU $PNNPO.VMUJQMF Λܭࢉ͢Δ L = lcm(P - 1, Q
- 1) • ʮP - 1ʯͱʮQ - 1ʯͷ࠷খެഒΛٻΊΔ • LͷܭࢉͰɺNͷܭࢉͰͬͨPͱQΛ͏
-ͷܭࢉ݁Ռ L = lcm(13 - 1, 17 - 1) L
= 48 • 12(13 - 1) ͱ16(17 - 1) ͷ࠷খެഒʮ48ʯ
-Λͬͯ& &ODSZQUJPO Λ ܭࢉ͢Δ Eͷܭࢉࣜ 1 < E < L
god(E, L) = 1 • ʮEʯʮ1ʯΑΓେ͖͘ɺLΑΓখ͍͞ • ʮEʯͱʮLʯͷ࠷େެ͕1ͱͳΔ(ޓ͍ʹૉ)
&ͷܭࢉ݁Ռ • 48ͱૉʹͳΔʮEʯΛٻΊΔ • ʮEʯͷෳಘΒΕΔͷͰɺ͜ͷத͔ΒૉΛ1ͭ બ͢Δ god(E, 48) = 1
E = 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47
&ͱ-Λͬͯ% %FDSZQUJPO Λ ܭࢉ͢Δ • ʮEʯͱʮDʯΛֻ͚߹Θͤɺʮmod LʯΛ ܭࢉ͕ͨ͠1ʹͳΔΑ͏ͳʮDʯͷΛٻΊ Δ E
✖ D mod L = 1 Dͷܭࢉࣜ
%ͷܭࢉ݁Ռ • ʮEʯͷΛʮ5ʯɺʮLʯͷΛʮ48ʯͱ͠ ͯܭࢉͨ͠߹ 5 ✖ D mod 48 =
1 D = 29
࡞͞ΕͨΩʔϖΞ ެ։伴ʮEʯͱʮNʯ E = 5 N = 221 ൿີ伴ʮDʯͱʮNʯ D
= 29 N = 221
34"ͷ҉߸Խॲཧ • ฏจΛʮEʯ͠ɺͦͷ݁ՌͷΛʮNʯͰׂ Γɺ༨ΓͷΛٻΊΔɻ • ʮEʯͱʮNʯ͕ެ։伴 ҉߸จ = ฏจ mod
N E
҉߸Խॲཧͷܭࢉ • ฏจͷ͕ʮ12ʯɺʮEʯͷ͕ʮ5ʯɺ ʮNʯͷ͕ʮ221ʯͷ߹ ҉߸จ = 12 mod 221 ҉߸จ
= 207 5
34"ͷ෮߸Խॲཧ • ҉߸จʮDʯͯ͠ɺͦͷ݁ՌͷΛʮNʯͰ ׂΓɺ༨ΓͷΛٻΊΔɻ • ʮDʯͱʮNʯ͕ൿີ伴 ฏจ = ҉߸จ mod
N D
෮߸Խॲཧͷܭࢉ • ҉߸จͷ͕ʮ207ʯɺʮDʯͷ͕ʮ29ʯɺ ʮNʯͷ͕ʮ221ʯͷ߹ ฏจ = 207 mod 221 ҉߸จ
= 12 29
34"҉߸ͷ҆શੑʹ͍ͭͯ
҉߸จΛղಡ͢Δͧʂ • ҉߸จʮDʯͱʮNʯ͕Θ͔Ε෮߸Ͱ͖Δ • ʮNʯͱʮEʯ౪ௌ͢Δ͜ͱ͕Ͱ͖Δ • N = P ✖
Q • ΩʔϖΞ ʮPʯͱʮ Qʯ͔Β࡞͞Ε͍ͯ Δ
ʮ/ʯΛʮ1ʯͱʮ2ʯʹղ ͢Ε҉߸ΛղಡͰ͖Δʂ
ʮ/ʯΛʮ1ʯͱʮ2ʯʹղ ʮૉҼղʯ
࠷؆୯ͳૉҼղ 6 = 2 ✖ 3 • ָউʂ
ΛૉҼղ 221 = 13 ✖ 17 • ͜Ε͘Β͍ͳΒͰ͖Δʂ
70000000013390000000171
͜ͷ22ܻͷେ͖ͳ 100000000019 ✖ 700000000009 ͱ͍͏2ͭͷૉͷੵʹղͰ͖Δ
ࢴͱԖච͕͋ΕೋΛֻ͚ࢉͯ͠ɺͱͷ ʹ͢͜ͱ༰қʹߦ͑Δ ͚ΕͲɺେ͖ͳΛૉҼղ͢Δͷ ͍͠
ཱ͔ͪͩΔૉҼղͷน
ͷܭࢉͱ҉߸ • ૉҼղͷ͠͞ܭࢉػΛ༻͍ͯҰ ʹղܾ͠ͳ͍ • ҰඵؒʹԿઍԯճͷܭࢉ͕Ͱ͖ΔܭࢉػΛ ࣋ͬͯͯ͠·ͬͨ͘ࣃ͕ͨͨͳ͍
ޮతͳૉҼղͷํ๏ • ۃΊͯߴͳֶͷཧΛ༻͍ͯૉҼղ ΛٻΊΔํ๏͕ੈքதͷֶऀͷؒͰݚ ڀ͞Ε͍ͯΔ͕… • ͦ͏ͨ͠ཧΛ༻͍ͯܭࢉػͷϓϩάϥϜΛ ࡞ͬͯɺ͍͠Ͱ͋Δ͜ͱʹมΘΓ ͳ͍
34"҉߸ͷ҆શੑ • ૉҼղ͕ࠔͳ͜ͱʹΑΓ୲อ͞Ε͍ͯΔ • ͨ͘͞Μͷܭࢉػͱ్ํͳ͍݄Λ͔͚ͯ ͬͱD͕ٻ·ͬͨͱͯͦ͠ͷࠒʹ౪ௌ͠ Α͏ͱ͍ͯͨ͠ใͷՁ͕ͳ͘ͳ͍ͬͯΔ • ౪ௌ͠Α͏ͱ͍ͯ͠Δใʹରͯ࣌ؒ͠ͱίε τ͕ݟ߹Θͳ͍
҉߸ֶతͳʹ͍ͭͯ
େ͖ͳ • ެ։伴҉߸Ͱͱͯେ͖ͳΛ͏ • RSA҉߸Ͱ1000Ϗοτఔ • 10ਐʹ͢Δͱ300ܻҎ্ͷࣈ
ఱจֶతͳ • ཧֶऀͷEddingtonʢΤσΟϯτϯʣɺશ Ӊͷཅࢠͷਖ਼֬ͳ136✖2 = 1.575 ✖ 10 (Eddingtonఆ)ͩͱ͍ͯ͠Δ •
ຊޠͰɺҰ൪େ͖͍ͷҐ͕ແྔେ (10 ) ͳͷͰ͜ͷΛಡΈ্͛Δ୯Ґଘࡏ ͠ͳ͍ 256 79 68
ਖ߷هʢ͡Μ͜͏͖ʣʹΑΔͷ ͑ํ
҉߸ֶతͳ • RSA҉߸Ͱ1000Ϗοτఔ • 1000Ϗοτ1.80 ✖ 10 • ্͑͛Δ͜ͱͰ͖ͳ͍͠ɺ૾͢ΒͰ͖ ͳ͍
308
·ͱΊ
·ͱΊ • ҉߸ٕज़େ͖͘3ͭʹΘ͚ΒΕΔ • ใΛಡΉ͜ͱ͕Ͱ͖ͳ͍Α͏ʹ͢Δ • ใͷվ͟ΜΛνΣοΫ͢Δ • ใΛૹͬͨ૬खΛ֬ೝ͢ΔͨΊͷ҉߸ٕज़
·ͱΊ • ެ։伴҉߸ • ެ։伴ͱൿີ伴ͷ࡞ํ๏ • ҉߸Խͱ෮߸Խʹ͍ͭͯ
·ͱΊ • RSA҉߸ͷ҆શੑʹ͍ͭͯ • ૉҼղ͕ࠔͳ͜ͱʹΑͬͯ୲อ͞Εͯ ͍Δ • ҉߸ֶతͳ్ํͳ͘େ͖͍
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠