What is Primality Testing in Information Security?


A primality test is an algorithm to decide whether an input number is prime. Some primality tests are deterministic. They always correctly decide if a number is prime or composite.

The fastest known deterministic primality test was invented in 2004. There are three computer scientists, such as Agrawal, Kayal, and Saxena, invented the AKS primality test that operated in O˜ (log(n)6 ) time, where O˜ (f(n)) is represented as O(f(n).log(f(n))k) for some integer k [1]. Although a significant breakthrough, this speed is rather slow when compared to information security requirement.

The advantage of prime numbers are that they are utilized in cryptography. One of the standard cryptosystem -RSA algorithm need a prime number as key which is generally over 1024 bits to provide higher security.

When handling with such large numbers, definitely doesn't create the following method any good. It is not simply to work with such large numbers particularly when the operations performed are / and % at the time of primality testing.

Therefore, the best primality testing algorithms that are produced can only decide if the provided number is a "probable prime" or composite.

There are the following types of Primality Testing which are as follows −

  • Determininstic Algorithm − A deterministic primality testing algorithm accepts an integer and continually output a prime or a composite. This algorithm always provide a proper answer.

  • Divisibility Algorithm − The simplest primality test is as follows −

    Given an input number n, checks whether any integer from 2 to n -1 divides n. If n is divisible by any m, then n is composite otherwise it is a prime. However, instead of testing all m upto n – 1, it is only important to test m upto √n. If n is composite then it can be factored into two values, at least one of which should be less than or same to √n.

  • Probabilistic Algorithm − A probabilistic algorithm provide an answer that is correct most of time, but not all of the time. These tests decided whether n satisfies one or more conditions that all primes should satisfy. A probabilistic algorithm restore either a prime or a composite depends on the following rules −

    • If the integer to be tested is actually a prime, the algorithm definitely return a prime.

    • If the integer to be tested is actually a composite, it returns a composite with probability 1 − ε, but it can return a prime with the probability ε. The probability of mistakes can be enhanced if it can run the algorithm ‘m’ times and the probability of error reduce to Σm.

Fermat Primality Test − The Fermat Primality Test stems from Fermat’s Little Theorem, which states that if n is prime, an−1 ≡ 1 (mod n). Given an input n and a < n, it can check whether an−1 ≡ 1 (mod n). If this is not true, thus n is composite and n is probably prime. Unfortunately, the Fermat Primality Test has a high cost of error, with too several composites being probably prime.

Updated on: 16-Mar-2022

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements