206124033 Primality Testing and Factorization
206124033 Primality Testing and Factorization
TESTING AND
FACTORIZATION
Presented By:- Tarun Bhati
(206124033)
AGENDA
Introduction & Definitions
Importance in Mathematics & Cryptography
Primality Testing: Methods & Examples
Factorization: Algorithms and Complexity
Cryptographic Applications (e.g., RSA)
Future Considerations and Conclusion
Q&A
Example: 91 = 71 × 131
Challenges: For large numbers (hundreds of digits), factorization is
computationally very hard
Underpins cryptographic security since multiplication is easy but reversing
(factoring) is hard
Probabilistic Tests:
Fermat’s Test: Based on Fermat’s Little Theorem; simple but can be
fooled
Miller-Rabin Test: Probabilistic, very efficient, small error probability
EXAMPLE??
Tarun Bhati (206124033)
AKS PRIMALITY TEST
In 2002, Agrawal, Kayal, and Saxen announced that they had found an
algorithm for primality testing with polynomial bit-operation time complexity
of .
The algorithm uses the fact that .
First unconditional polynomial-time algorithm (2012 proof)
Elegant but not used in practice due to higher constants.
Assume n has 200 bits. What is the number of bit operations needed to run
the AKS algorithm?
The bit-operation complexity of this algorithm is . This means that the
algorithm needs only (log 2200)12 = 39,547,615,483-bit operations. On a
computer capable of doing 1-billion-bit operations per second, the
algorithm needs only 40 seconds.
Tarun Bhati (206124033)
PROBABILISTIC PRIMALITY
TESTING
Probabilistic algorithms do not guarantee correctness but have an extremely low
error probability.
Used before the AKS algorithm became known.
Key Properties:
If n is prime, the algorithm always returns 'prime'.
If n is composite, the algorithm correctly returns 'composite' with probability (1 -
ε), but may incorrectly return 'prime' with probability ε.
Reducing Error Probability:
Running the test multiple times reduces the error probability.
If the algorithm runs ‘m’ times, the error probability decreases to εm.
Significance:
Efficient for large numbers.
Example: Miller-Rabin Test
Tarun Bhati (206124033)
FERMAT’S PRIMALITY TEST
• Basis: If p is prime, then for any a with 1 < a < p,
≡ 1 (mod p)
• Example: Testing 341 (which is composite: 11×31) may pass for some
bases like 2
• Limitations: Existence of pseudoprimes and especially Carmichael
numbers
Test Conditions:
If x² ≡ 1 (mod n), then x must be ±1 for prime n.
If there exists x ≠ ±1 such that x² ≡ 1 (mod n), then n is composite.
Example (Composite: n = 15):
- 1² ≡ 1 (mod 15), (-1)² ≡ 1 (mod 15)
- 4² ≡ 1 (mod 15) (Extra Root!) → 15 is composite.
Conclusion:
If extra roots exist, n is composite.
Although this test can tell us if a number is composite, it is difficult to do the testing.
All numbers less than n (except 1 and n - 1) must be squared to be sure that none of them
is 1.
Used in primality testing algorithms like Miller-Rabin.
Tarun Bhati (206124033)
THE MILLER-RABIN
PRIMALITY TEST
Type: Probabilistic test with low error
probability.
The Miller-Rabin primality test combines the
Fermat test and the square root test in a very
elegant way to find a strong pseudoprime (a prime
with a very high probability).
Method:
Write n – 1 = m * (with m odd)
Check mod n and subsequent squaring’s
In each step, we assure ourself that the Fermat test is passed, and the
square root test is satisfied between all pairs of adjacent steps, if
applicable (if the result is 1).
There exists a proof that each time a number passes a Miller-Rabin test, the
probability that it is not a prime is 1/4. If the number passes m tests (with
m different bases), the probability that it is not a prime is (1/4)m
Algorithm Steps:
Initialize a = 2 and e = 2.
Perform exponentiation: a ← ae mod n, increment e until e > B.
Compute p = gcd(a - 1, n).
If 1 < p < n, return p; otherwise, return failure.
Complexity:
Needs B-1 exponentiation operations (O() complexity).
Assume that there are two integers, x1 and x2, such that prime factor p divides (x1 - x2), but n
does not.
Algorithm:
Choose x₁, a small random integer (seed).
Compute x₂ using a function f(x₁) = x₁² + a (where a is usually 1), ensuring that n does not
divide (x₁ - x₂).
Compute gcd(x₁ - x₂, n):
If gcd(x₁ - x₂, n) ≠ 1, then the result is a factor of n.
If gcd(x₁ - x₂, n) = 1, repeat steps with x₂ as the new starting point.
The algorithm iterates until a non-trivial factor is found.
RHO
Complexity
The method requires arithmetic
operations. However, because
we
expect p to be smaller or equal
to , we expect to do n1/4
arithmetic operations. This
means that the bit-operation
complexity is O(2n/4 ),
Tarun Bhati (206124033)
exponential.
QUADRATIC THE GENERAL
NUMBER FIELD
SIEVE SIEVE (GNFS)
• Devised By: Pomerance • Devised By: Hendric Lenstra and Argin Lenstra
• Complexity: Approximately • Complexity: Approximately
• Key Generation:
• Requires fast primality tests to find large primes