Modulo Primality Test.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Modulo primality test. 1. Abstract. Verifying large prime numbers is a time-consuming proces, even with modern day computers. This article describes the "modulo primality test" that combines the segmented prime spiral, modular arithmetic and the primorial sieve. The "modulo primality test" can be used to factorize RSA-numbers. In the segmented prime spiral with one segment each integer is identified as an unique member of the Eastward family of quadratic polynomials with only two terms. By way of modular arithmetic the number of digits is reduced when checking a large integer for a possible divisor. In addition the primorial sieve can be used to deselect sets of divisors. The modulo primality test can also be used as another methode to check the correctness of computercalculations. 2. The prime spiral with one segment. The modulo primality test is based on the prime spiral with one segment. This prime spiral is derived from the Ulam spiral with startvalue 0 when placed in a Cartesian coordinate system (appendix A). There is an infinite set of families of segmented prime spirals. The Ulam spiral has four segments. The segmented prime spirals are unusual since integers on the seam appear twice. These doubled integers disappear behind the overlap when putting a prime spiral together, like when folding the prime spiral with one segment into a cone (Fig. 1), or the SE main diagnonal in the Ulam spiral (appendix A). Each integer in the prime spiral with one segment is member of the Eastward family of functions 2 2 f1, c(nE) = 1 n + 0 n + c = n + c with −n < c ≤ n which has just two terms (Fig. 1). For instance the integer g = 90 with n = ⌊⌊⌊ √g ⌉⌉⌉ has the parameters n = 9 and c = 9 and is thus found on the NE main diagonal at the location (x, y) = ( n, c) = (9, 9). The location (10, −10) of g = 90 on the SE main diagonal does not comply with the definition of the families of functions (appendix A). 2 2 Note that the integer g = 90 also belongs to f1,0 (nNE ) = 1 n + 1 n + 0 and f1,18 (nSE ) = 1 n − 1 n + 18 with n = ⌊⌊⌊ √g ⌉⌉⌉ Fig. 1: Partial prime spiral with one segment based on the Ulam spiral. Hans Dicker \ _Modulo primality test.doc 1/13 3. The modulo primality test. The simplest primality test to verify if an integer g is a prime number is trial division. Find a prime integer d from 2 to √g that evenly divides g (the division leaves no remainder). As sone as g is evenly divisible by d then g is composite, otherwise g is a prime number. In the prime spiral with one segment each integer g is a unique member of the family of quadratic functions 2 2 fa,b,c(n) = f1, b,c(n) = f1, c(nE) = 1 n + 0 n + c = n + c with −n < c ≤ n. This specific function has only two terms. So, each integer g is defined as g = n2 + c with −n < c ≤ n and n = ⌊⌊⌊ √g ⌉⌉⌉. The modulo primality test reduces the integer g = n2 + c into g' = n' · n' + c with n' = n (mod d). When there is a divisor d in 2 ≤ d ≤ √g with g' (mod d) = 0 then g is composite, otherwise g is a prime number. The modulo primality test takes more operations than the straightforward division of the integer g by the divisors (appendix C: "Modular arithmetic"). The strength of the modulo primality test lies in the reduction of the size of the integer g (Fig. 2). Fig. 2: The reduction of a integer as function of the divisor d via modular arithmetic. 2 g (mod d) 1 d 1 Fig. 2 shows that the reduction of bounces back to at every = with m ∈ { ..., 5, 4, 3, 2}. g m n m 1 From 1 towards the value of n' = n (mod d) slowly approaches zero via a quadratic function. m + 1 m Further reduction of g' (mod d) / g can be obtained by selective changing n2 = n · n ≡ n' · n' (mod d) into n2 = n · n ≡ n' · (n' − d) (mod d). Hans Dicker \ _Modulo primality test.doc 2/13 4. The modulo primality test to find verify large primes. In the prime number theorem the prime-counting function π(g) for the positive integers up to g is defined as: g π g)( ≈ with log ( g) the natural logarithm of g. log g)( For large enough g, the probability that a random integer not greater than g is prime is close to 1 / log ( g). Among the positive integers g ≈ 10 9 about one in 21 is prime, since log(10 9) ≈ 20.7. For prime numbers ≈ 10^10^8, about one in 2.3 · 10 8 is prime, since log(10^10^8) = 10 8 · log (10) ≈ 2.3 · 10 8. The modulo primality test can be deployed to search for ever larger prime numbers, like the first prime number with at least one hundred million digits when written in base 10. Below is a describtion of how to find the first prime number after integer gs with the modulo primality test. Imagine trying to find the first prime number after the integer gs = 10^10^8 − 1 2 1. The prime spiral with one segment defines the integer gs as member of f1, c(nE) = n + c with −n < c ≤ n. Calculate both n = ⌊⌊⌊ √g ⌉⌉⌉ and c = g − n2. 2. Take a list of prime numbers up to for instance pend = p238 . Define pi ∈ {p2, ..., pend } thus pi ∈ {3, ..., 1499}. Other options are: The P6#−sieve gives a list of all π(p6#) = 3,248 prime numbers < p6# with p6# = 30,030. 9 The extended P9#−sieve supplies a list of all prime numbers up to 10 . ' ' ' 3. Calculate gs (mod pi) for every given pi via gs'(pi) = ( n · n + c ) (mod pi) with n = n (mod pi). Store the calculations of gs'(pi) in an array. 4. Select the next odd integer gv, with ∆g = gv − gs the distance between gs and gv. Calculate gv'(pi) = ( gs'(pi) + ∆g ) (mod pi) for every given pi up to pend . Overwrite gs'( pi) with gv'( pi). As sone as gv' = 0 then gv is not a prime number. Repeat step 4. 5. When gv' ≠ 0 for every given pi up to pend then gv could be a prime number. Use modular arithmetic (appendix C) to check gv for primality. For instance with the P4#−sieve the division by the prime divisors pend < d < √gv can be approximated by d ∈ { S(p4#) j + k • p4# │ 1 ≤ j ≤ φ(p4#) ∧ k ∈ N0 } (see Appendix B). Hans Dicker \ _Modulo primality test.doc 3/13 5. The modulo primality test and RSA cryptography. RSA cryptography is based on two large prime numbers gA and gB to generate a composite number g = gA · gB. Multiplying the two large numbers gA and gB is easy. Factoring the large number g is very difficult. For example, the RSA-100 number is defined as the semi-prime g = 0.15226... · 10 100 , the product of the prime 50 50 numbers gA = 0.37975... · 10 and gB = 0.40094... · 10 . For demonstration purposes the RSA-100 number is replaced by the semi-prime g = 1,523,012,791 = 0.15230... · 10 10 5 5 and the prime numbers gA = 0.37987 · 10 and gB = 0.40093 · 10 . Out of the infinite set of primorial sieves, the P4#−sieve is implemented with p4# = 210 and φ(p4#) = 48. The integer g = 1,523,012,791 ≡ 181 (mod p4#) could be prime since 181 = S(p4#) 41 (see Appendix B). The segmented prime spiral with one segment splits g into the two terms of the Eastward quadratic polynomial. 2 The function f1, c(nE) = n + c with −n < c ≤ n gives n = ⌊⌊⌊ √g ⌉⌉⌉ = 39,026 and c = −15,885. Find d │ g via g = n · n − 15,885 ≡ n' · n' − 15,885 (mod d) with n' ≡ n (mod d). Possible divisors p4 < d < √g are d ∈ { S(p4#) j + k · p4# │ 1 ≤ j ≤ φ(p4#) ∧ k ∈ N0 }, based on the fourth double primorial sieve. Start at the end and work backwards, since the principles of RSA crytograhpy define g = gA · gB with gA ≈ gB ≈ √g ≈ n. 2 d ≤ n S(p4#) j n = 39,026 f1,−15885 (nE) = n − 15,885 = 1,523,012,791 Comment n' = n (mod d) f1,0,−15885 (39,026) ≡ n' · n' − 15,885 (mod d) about g 39,023 173 3 32 − 15,885 ≡ −15,876 − −1 · d ≡ 23,147 possible prime 39,019 169 7 72 − 15,885 ≡ −15,836 − − 1 · d ≡ 23,183 possible prime 39,017 167 9 92 − 15,885 ≡ −15,804 − − 1 · d ≡ 23,213 possible prime . 38,027 17 999 999 2 − 15,885 ≡ 982,116 − 25 · d ≡ 31,441 possible prime 38,023 13 1,003 1,003 2 − 15,885 ≡ 990,124 − 26 · d ≡ 1,526 possible prime . 37,997 197 1,029 1,029 2 − 15,885 ≡ 1,042,956 − 27 · d ≡ 17,037 possible prime 37,993 193 1,033 1,033 2 − 15,885 ≡ 1,051,204 − 27 · d ≡ 25,393 possible prime 37,991 191 1,035 1,031 2 − 15,885 ≡ 1,055,340 − 27 · d ≡ 29,583 possible prime 37,987 187 1,039 1,039 2 − 15,885 ≡ 1,063,636 − 28 · d ≡ 0 ◄ NOT prime The "modulo primality test" claims: Divisions? Who needs divisions! Based on the modulo primality test the RSA-100 number is reduced to maximum 0.001 of its original size.