6. Basic Mathmatics for Cryptography - Euclid's Algorithm & Fermat's Little Theorem & Euler's Theorem
INDEX
prime number
prime number
prime number=素数=only have divisors of 1とself
Prime Factorization
: All numbers can be expressed as a unique products of primes. (すべての数字はprime numの積で表すことができます)
n = a X b X c
GCD
greatest common divisor
それらの素数分解を比較&最小べき乗(最大公約数)->GCDを決定できる
273 = 3*7*13, 399 = 3*7*19.
gcd(273, 399) = 3*7=21
Euclid Algorithm
gcdが入手できます!
def Euclid_GCD(a,b) :
# Assume a and b are nonnegative integers
if (b==0) :
gcd(a,b) = a # stopping condition
else
gcd(a,b) = gcd(b, a%b) # recursive step
a = 54, b = 30.
gcd(54, 30) = gcd(30, 54%30) = gcd(30, 24)
gcd(30, 24) = gcd(24, 30%24) = gcd(24, 6)
gcd(24, 6) = gcd(6, 24%6) = gcd(6,0)
gcd(6,0) = 6
=>>GCDは6!
Extended Euclidean Algorithm
a×x+b×y=gcd(a,b)a\times x +b\times y = gcd(a,b)a×x+b×y=gcd(a,b)
整数a,bが与えられると,中間過程のxとyも知ることができる.
例1
例2
Modular Arithmetic
ざんりゅうえんざん
クリーンアップ用語
模演算後の残存値が等しい場合
ex) 100 mod 11 = 34 mod 11 = 1
a mod n=bまたはa=qn+bの場合b
通常の最小整数は
⚠️Properties⚠️
a=b(modn)およびc=d(modn)の場合、
2つの相対素数a,bがある場合
aai=1(modb)aa^i=1(modb)aai=1(modb)のaia^iaiが存在する.
Euler Totient Fucntion
residues
complete set of residues = {0, 1, 2, 3, 4, 5, 6,7, 8, 9}
reduced set of residues = {1, 3, 7, 9}
Euler Totient Function φ(n)\varphi (n)φ(n)
減少した残留物の元素数
ex) φ(10)=4\varphi(10) = 4φ(10)=4 (1, 3, 7, 9)
->n=pq,p,qがprimeの場合,n未満のnに対して相対primeの正数を求めることができる.
pは素数->φ(p)=p−1\varphi(p) =p -1φ(p)=p−1
p,qはprime->φ(pq)=(p−1)×(q−1)\varphi(pq)=(p-1)\times (q-1)φ(pq)=(p−1)×(q−1)
φ(11)\varphi(11)φ(11) = 11-1 = 10
φ(21)\varphi(21)φ(21) = (3-1)*(7-1)=2*6=12
φ(10)\varphi(10)φ(10) = (2-1)*(5-1)=1*4=4
Fermat's Little Theorem
ap−1=1a^{p-1}=1ap−1=1(mod ppp)
where ppp is prime and gcd(a, p) = 1
(pはPrime,a,pはPrime)
ex
464^646mod 7 = 1
192219^{22}1922mod 23 = 1
Fermat's Little Theoryアプリケーション
非常に大きな数pに対してapは-1=1 a^{p-1}=1 apは1=1(modppp)ですか?
- apa^pap mod p=ap=ap=a
- a(p−1)×k+1a^{(p-1)\times k+1}a(p−1)×k+1mod ppp = a
ex
4374^{37}437mod 7 = 46×6+14^{6\times 6+1}46×6+1mod 7 = 16×1^6\times16× 4 mod 7 = 4
1922×2+119^{22\times 2+1}1922×2+1 mod 23 = (1922)2×(19^{22})^2\times(1922)2× mod 23 = 19
89100×10+189^{100\times10 + 1}89100×10+1 mod 101 = (89100)10×(89^{100})^{10}\times(89100)10×89 mod 101 = 89
Euler's Theorem
φ(n)\varphi (n)φ(n)はEulerのTotiner関数で、
gcd(a,n)=1の場合
aφ(n)=1a^{\varphi(n)}=1aφ(n)=1(modnn).
2512025^{120}25120 mod 143 = 25(11−1)(13−1)25^{(11-1)(13-1)}25(11−1)(13−1) mod 11 X 13 = 1
196019^{60}1960 mod 77 = 19(7−1)(11−1)19^{(7-1)(11-1)}19(7−1)(11−1) mod 7 X 11 = 1
Euler's Theoremアプリケーション
aφ(n)a^{\varphi(n)}aφ(n)mod n=1
25120125^{1201}251201 mod 143 = 25120×10+125^{120\times 10 + 1}25120×10+1 mod 11 X 13 = 25
1948119^{481}19481 mod 77 = 1960×8+119^{60\times 8 + 1}1960×8+1 mod 7 X 11 = 19
Reference
この問題について(6. Basic Mathmatics for Cryptography - Euclid's Algorithm & Fermat's Little Theorem & Euler's Theorem), 我々は、より多くの情報をここで見つけました https://velog.io/@yesterdaykite/6.-Basic-Mathmatics-for-Cryptography-1テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol