Processing math: 100%

학교수업/정보보호이론

[InformationSecurityTheory] 10. Primality Testing

hwijin97 2022. 6. 14. 22:38

Deterministic Algorithms

 

Probabilistic algorithms 

- Fermat Test

  > If n is a prime then an1modn=1 for all 1<a<n.

  > If an1modn1 for some a, 1<a<n then n is a composite

  > If an1modn=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,1nn1

- If n is a prime, then 1modn=1,n1

- If 1modn1,n1, then n is composite.

 

Miller-Rabin Test

- Fermat test + Square Root test

 

- Choose an integer a such that 2an2 and calculatest an1modn.

- n1=m×2k 형태로 쓴다.

- an1modn 계산을 한꺼번에 하지않고 여러 스텝으로 하면서, 과정에서 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