Download presentation

Presentation is loading. Please wait.

Published byBrian Shepherd Modified over 2 years ago

1
AKS Implementation of a Deterministic Primality Algorithm R. Salembier & P. Southerington

2
AKS Primality Test Deterministic primality-proving algorithm Deterministic primality-proving algorithm Manindra Agrawal, Neeraj Kaval, Nitin Saxena Manindra Agrawal, Neeraj Kaval, Nitin Saxena PRIMES is in P, 6 August 2002 PRIMES is in P, 6 August 2002 Determines whether a number is prime or composite. Determines whether a number is prime or composite. There is no probability associated as with Miller-Rabin Test There is no probability associated as with Miller-Rabin Test

3
1.If (n = a b for a N and b > 1), output COMPOSITE. 1.If (n = a b for a N and b > 1), output COMPOSITE. 2.Find the smallest r such that O r (n) > 4 log 2 n 2.Find the smallest r such that O r (n) > 4 log 2 n 3.If 1 < GCD(a, n) < n for all a r, output COMPOSITE. 3.If 1 < GCD(a, n) < n for all a r, output COMPOSITE. 4.If n r, output PRIME. 4.If n r, output PRIME. 5.For a = 1 to 5.For a = 1 to if (( x + a) n x n + a (mod x r – 1, n)) if (( x + a) n x n + a (mod x r – 1, n)) output COMPOSITE. output COMPOSITE. 6.Output PRIME. 6.Output PRIME. Original AKS Algorithm August 6, 2002 version:

4
1.If (n = a b for a N and b > 1), output COMPOSITE. 1.If (n = a b for a N and b > 1), output COMPOSITE. 2.Find the smallest r such that O r (n) > log 2 n 2.Find the smallest r such that O r (n) > log 2 n 3.If gcd(a, n) 1 for all a r, output COMPOSITE. 3.If gcd(a, n) 1 for all a r, output COMPOSITE. 4.For a = 1 to 4.For a = 1 to if (( x + a) n x n + a (mod x r -1, n)), output PRIME. if (( x + a) n x n + a (mod x r -1, n)), output PRIME. Lenstra/Pomerance Variant Revised version we are using:

5
Complexity Big-O Notation Big-O Notation Read as order of Read as order of Indicates the dominant term Indicates the dominant term AKS runs in polynomial time AKS runs in polynomial time Original: Õ (log 12 (n)) Original: Õ (log 12 (n)) Lenstra/Pomerance: Õ (log 7.5 (n)) Lenstra/Pomerance: Õ (log 7.5 (n))

6
LiDIA Implementation Perfect Power Test Perfect Power Test used native is_power() function used native is_power() function GCD Test GCD Test Initially used gcd() Initially used gcd() Traditional method of GCD calculation Traditional method of GCD calculation Changed to bgcd() Changed to bgcd() Eliminates division Eliminates division Uses shifts and adds Uses shifts and adds Exponentiation Exponentiation Left-to-Right Expansion Left-to-Right Expansion Modular reduction at each step Modular reduction at each step

7
Division Optimization Split polynomial into three coefficient vectors Split polynomial into three coefficient vectors Terms with exponents > r-1 Terms with exponents > r-1 Term with exponent r-1 Term with exponent r-1 Terms with exponents < r-1 Terms with exponents < r-1 Subtracted r from each exponent in first set Subtracted r from each exponent in first set Added first and third vectors together Added first and third vectors together

8
Division Optimization

9
Squaring Optimization Constructed squaring routine Constructed squaring routine Dealt with first and last terms individually Dealt with first and last terms individually Looped through all terms pairing together Looped through all terms pairing together 91% of test in squaring function 91% of test in squaring function Operation times actually increased Operation times actually increased Confirmed problem using GMP Confirmed problem using GMP

10
NTL Implementation Efficient polynomial multiplication Efficient polynomial multiplication LiDIA used only classical multiplication LiDIA used only classical multiplication NTL Automatically chooses from: NTL Automatically chooses from: Classical algorithm Classical algorithm Karatsuba method Karatsuba method Two Fast Fourier Transform (FFT) methods Two Fast Fourier Transform (FFT) methods Dramatic performance increase Dramatic performance increase 50% of time spent in FFT 50% of time spent in FFT May be able to adjust selection boundaries May be able to adjust selection boundaries

11
LiDIA vs. NTL

12
NTL Potential Implement native Perfect Power test Implement native Perfect Power test Currently falling back to GMP Currently falling back to GMP Possible Alternate Implementations Possible Alternate Implementations Manually reduce coefficients Manually reduce coefficients Represent polynomial directly as a ring Represent polynomial directly as a ring Let NTL handle polynomial reduction Let NTL handle polynomial reduction

13
Performance Comparison Crandall & Papadopoulis Apple / UMD

14
Conjecture Improvement Improves time to Õ (log 3 (n)) Improves time to Õ (log 3 (n)) Conjecture: Conjecture: If n mod r 0 mod r and If n mod r 0 mod r and If (X – 1) n Ξ (X n – 1) mod (X r -1, n) If (X – 1) n Ξ (X n – 1) mod (X r -1, n) And n 2 mod r -1 mod r And n 2 mod r -1 mod r n is PRIME n is PRIME From tests this appears to be true From tests this appears to be true If tests holds for a =1 then it holds for all a If tests holds for a =1 then it holds for all a Conjecture is still not proven Conjecture is still not proven

15
Extrapolation with Conjecture

16
Future Work Native GMP Implementation Native GMP Implementation Allow total control over polynomial operations Allow total control over polynomial operations Very difficult to do more efficiently than NTL Very difficult to do more efficiently than NTL Bernstein Exponentiation Optimization Bernstein Exponentiation Optimization Map polynomial ring onto integer ring Map polynomial ring onto integer ring Qi Cheng Method Qi Cheng Method One round of Elliptic Curve Primality Test One round of Elliptic Curve Primality Test One iteration of AKS One iteration of AKS

17
Conclusions Our implementation comparable to others Our implementation comparable to others NTL better suited to AKS than LiDIA NTL better suited to AKS than LiDIA AKS still too slow for practical use AKS still too slow for practical use Conjecture Conjecture Bernstein / Qi Cheng Bernstein / Qi Cheng Focus should be on algorithmic improvements Focus should be on algorithmic improvements

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google