Deterministic Algorithms

Probabilistic algorithms
- Fermat Test
> If n is a prime then an−1modn=1 for all 1<a<n.
> If an−1modn≠1 for some a, 1<a<n then n is a composite
> If an−1modn=1 for some a, 1<a<n, then n may be a prime.
> "composite" 라 판단하면 확실히 composite
> "Prime" 라 판단하면, n 은 아마도 prime.
Square Root Test
- √1modn=x|x2modn=1,1≤n≤n−1
- If n is a prime, then √1modn=1,n−1
- If √1modn≠1,n−1, then n is composite.
Miller-Rabin Test
- Fermat test + Square Root test
- Choose an integer a such that 2≤a≤n−2 and calculatest an−1modn.
- n−1=m×2k 형태로 쓴다.
- an−1modn 계산을 한꺼번에 하지않고 여러 스텝으로 하면서, 과정에서 prime / composite 를 판단한다.

- 확률적으로 a 가 prime 이고 제대로 판단할 확률은 1/4 이고 a 를 랜덤하게 10 번 선택해서 확률을 더 올린다.
Recommended Primality Test

Factorization
- Any positive integer n can be written uniquely in a prime factorization form. p1,p2,⋯,pk are primes, are e1,e2,⋯,ek are positive integers.
n = p_1^e_1 \times p_2^e_2 \times \cdots \times p_k^e_k
Exponentiation and Logarithm

Fast Exponentiation
- given a,x,n
- calcuate y=axmodn

'학교수업 > 정보보호이론' 카테고리의 다른 글
[InformationSecurityTheory] 9. Mathmatics of Cryptography (0) | 2022.06.14 |
---|