Fermat's and Euler's Theorem



Two theorems that play important roles in public-key cryptography are Fermat’s theorem and Euler’s theorem.

Fermat’s Theorem ( Fermat's Little Theorem)

Fermat’s theorem states the following: If p is prime and a is a positive integer not divisible by p, then 
ap11(modp)

Proof: Consider the set of positive integers less than p:{1,2,,p1} and multiply each element by a, modulo p, to get the set X={a(modp),2a(modp),,(p1)a(modp)}

None of the elements of X is equal to zero because p does not divide a. Furthermore, no two of the integers in X are equal.To see this,assume that jaka(modp), where ij<k(p1). Because a is relatively prime to p , we can eliminate a from both sides of the equation resulting in jk(modp) .This last equality is impossible, because j and k are both positive integers less than p.Therefore, we know that the (p1) elements of  X are all positive integers with no two elements equal.

So We can conclude the set X consists of the set of integers [1,2,,p1] in some order. Multiplying the numbers in both sets ( p and  X ) and taking the result mod yields

a×2a×(p1)a1×2××p1(modp)
ap1(p1)!(p1)!(modp)

We can cancel the (p1)! term because it is relatively prime to p.This yields Equation ap11(modp) which completes the proof.

Example:

An alternative form of Fermat’s theorem is also useful: If  p is prime and a is a positive integer, then
apa(modp)

Example:
Application: This helps in solving large congruence modulo p
lets find 268(mod19)
using Fermat's Theorem 2181(mod19)
Now 68=18×3+14
So
268(218)3+214(mod19)214(mod19)
24163(mod19)
21424.24.24.2227.48.4≡=136(mod19)
Therefore
268(mod19)6(mod19)
 
Euler’s Totient Function
Before presenting Euler’s theorem, we need to introduce an important quantity in number theory, referred to as Euler’s totient function, written ϕ(n) , and defined as the number of positive integers less than and relatively prime to n. By convention,
ϕ(1)=1

It should be clear that, for a prime number p
ϕ(p)=p1
Now suppose that we have two prime numbers p and q with pq. Then we can show that, for n=pq
ϕ(n)=ϕ(pq)=ϕ(p)×ϕ(q)=(p1)×(q1)

To see that ϕ(n)=ϕ(p)×ϕ(q), consider that the set of positive integers less than n is the set [1,2,,(pq1)]. The integers in this set that are not relatively prime to n are the set {p,2p,,(q1)p} and the set {q,2q,,(p1)q}. Accordingly
ϕ(n)=(pq1)[(q1)+(p1)]
ϕ(n)=pqpq+1
ϕ(n)=(p1)×(q1)
ϕ(n)=ϕ(p)×ϕ(q)

Example:

Euler's Theorem

Euler’s theorem states that for every a and n that are relatively prime:
aϕ(n)1(modn)
Proof: The above Equation  is true if n is prime, because in that case,ϕ(n)=n1 and Fermat’s theorem holds. However, it also holds for any integer n. Recall that ϕ(n) is the number of positive integers less than n that are relatively prime to n .Consider the set of such integers, labeled as

R={x1,x2,,xϕ(n)}

That is, each element  xi of R is a unique positive integer less than n with gcd(xi,n)=1.Now multiply each element by a, modulo n:
S={ax1(modn),ax2(modn),,axϕ(n)(modn)}

The set S is a permutation of  R, by the following line of reasoning:
1. Because a is relatively prime to n and xi is relatively prime to n , axi must also be relatively prime to n. Thus, all the members of S are integers that are less than n and that are relatively prime to n.
2.There are no duplicates in S.If axi(modn)=axj(modn), then xi=xj

Fermat's little theorem and Euler's theorem can be used for Primality testing.
Fermat's Little Theorem is a fundamental theorem in number theory that states that if p is a prime number and a is an integer not divisible by p, then ap1(mod1). This theorem provides a useful tool in primality testing through what's known as the Fermat primality test.

The Fermat primality test is a probabilistic algorithm used to determine whether a given number is likely prime or composite. It works based on Fermat's Little Theorem as follows:

    1.Select a random integer a
    Choose a random integer a such that 1<a<n, where n is the number being tested for primality.
    2.Check if an11(modn):
    Compute an1(modn). If the result is not congruent to 1, then n is definitely composite.
3.Repeat the test with different a: 
Repeat steps 1 and 2 with different random values of a. If n passes the test for a certain number of randomly chosen a values, it is considered likely prime.

The Fermat primality test is fast and easy to implement. However, it is important to note that it is probabilistic, meaning there's a chance it might incorrectly identify composite numbers as prime (known as a false positive). This occurs when n is a composite number that satisfies an11(modn) for all chosen a values. Such composite numbers are called Carmichael numbers.

Despite its probabilistic nature and the existence of Carmichael numbers, the Fermat primality test is still valuable, particularly for large numbers, as it provides a quick way to filter out many composites efficiently. It is often used as a preliminary test before applying more rigorous primality tests, such as the Miller-Rabin primality test or the AKS primality test.

Example:
Check whether the number 9 is prime or not.
choose a number relatively prime to 9 say 2
No as per theorem if p is prime then ap11(modp)
ie; 281(mod9)
28(mod9)=4
So the number 9 is composite

Check whether the number 7 is prime or not.
choose a number relatively prime to 7 say 2
No as per theorem if p is prime then ap11(modp)
ie; 261(mod7)
26(mod7)=1
choose another a=3
36(mod7)=1
choose another a=5
56(mod7)=1

We can conclude that 7 is a prime

Note:
561: This is the smallest Carmichael number. It is composite and can be factored as 3×11×17 It satisfies a5601(mod561) for all a that are coprime to 561.

Carmichael numbers are relatively rare compared to composite numbers in general, but they are important to consider when designing primality testing algorithms because they can lead to false positives if only relying on Fermat's Little Theorem for primality testing.

Comments

Popular posts from this blog

Number Theory CST 292 KTU IV Semester Honors Course Notes Dr Binu V P 9847390760

Sum of Squares

Well Ordering Principle