Totient Function and Euler's Theorem
17 Dec 2021
Motivation
The Totient function is used in cryptosystems like RSA and is useful in computing number theoretic problems.
Euler's Totient Function
Euler's Totient Function
Euler's totient function is typically denoted using φ(x), defined as
φ(n)=∣{0≤k<n:(k,n)=1}∣.
Or, φ(n) is the number of non-negative numbers strictly less than n that are co-prime with n.
Properties:
- If p∈P, then φ(p)=p−1
- If p∈P, then φ(pk)=pk−1(p−1)
- In the case that p=2, it simply becomes pk−1. This fact is useful in implementing the Totient function as it allows us to use bit operations.
- If p,q∈N and (p,q)=1, then φ(pq)=φ(p)⋅φ(q) (multiplicative)
Multiplicative Property
To reiterate: If p,q∈N and (p,q)=1, then
φ(p⋅q)=φ(p)⋅φ(q).
Any number a∈N can be written as a factorization of m primes,
a=i=0∏mqiei.
Then, φ(a) can be computed as:
φ(a)=i=0∏mφ(qiei)=i=0∏m[(qi)ei−1(qi−1)]
Euler's Theorem
The following lemma is used in the proof of Euler's theorem.
If (a,b)=1 and (b,c)=1, then (ac,b)=1.
Write all three numbers in terms of their prime factorization and observe that ac shares no common prime factors with b.
Euler's Theorem
Let (a,n)=1, then
aφ(n)≡n1.
Consider the numbers ka(modn) where (k,n)=1 and 1≤k<n. If ja≡nka, then another way to say this is n∣(j−k)a. Since (a,n)=1, we get that n∣(j−k), which means j−k=0, so j must equal k. Hence, the elements in the sequence given by:
ka(modn), where (k,n)=1 and 1≤k<n,
are all distinct, meaning
(j,n)=1∏ka≡n(l,n)=1∏l
for l,j∈[0…n), since each element ja is congruent to a remainder l with (l,n)=1.
Notice that the left hand side is just (∏(j,n)=1l)aφ(n). Since each term in the product is coprime with n, we can cancel ∏(j,n)=1l from both sides and obtain
aφ(n)≡n1.
Fermat's Little Theorem
In the specific case of Euler's theorem where p is prime, we get that
ap−1≡1(modp).
One example of Euler's theorem being applied is in exponentation:
gx(modn)
in cases where x>φ(n), we can reduce this problem to be
gx≡g(xmodφ(n))(modn).
Furthermore, observe
gab≡g(amodφ(n))(bmodφ2(n))(modn),
where φ2(n)≜φ(φ(n)).
Carmichael's Totient Function
We didn't talk about the Carmichael function in our MATH-470, however, this becomes useful in discussing the RSA algorithm.
Carmichael's Totient Function
Carmichael's totient uses the notation λ(n), and is defined to be the smallest positive integer m satisfying
am≡1(modn),
for all a∈[1…n) such that (a,n)=1.
Computing the Carmichael Function
Using results from Carmichael's theorem, we can find that λ(n) can be computed in terms of Euler's totient function.
λ(pr)={φ(pr)21φ(pr)if p∈P,or p=4if p=2 and r≥3