Euler's Totient Function
Euler's totient function ϕ(n) counts how many integers in the range [1, n] are coprime to n (share no common factor other than 1).
ϕ(n)=n×p∣n∏(1−p1) The product runs over all distinct prime factors of n. For a prime p, ϕ(p)=p−1 (every number from 1 to p−1 is coprime to a prime).
RSA Cryptography Connection
Euler's totient is the mathematical backbone of RSA encryption, the most widely used public-key cryptosystem:
- Choose two large primes p and q
- Compute n=p×q (the public modulus)
- Compute ϕ(n)=(p−1)(q−1) (the secret)
- Choose public exponent e coprime to ϕ(n)
- Compute private exponent d≡e−1(modϕ(n))
Security relies on the difficulty of factoring n to recover p and q, and hence ϕ(n).
Scale of the problem: For n=91=7×13, ϕ(91)=6×12=72 — trivial with small primes. But for 1024-bit primes (each ~300 digits), the factorization is computationally infeasible with current technology.
Euler's Theorem
Euler's theorem generalizes Fermat's little theorem: if gcd(a,n)=1, then:
aϕ(n)≡1(modn) This is the mathematical foundation that makes RSA decryption work: raising to the private exponent d reverses the public encryption because ed≡1(modϕ(n)).
Frequently Asked Questions
What does Euler's totient function calculate?
Euler's totient function ϕ(n) counts how many integers from 1 to n are coprime to n, meaning they share no common factor other than 1. For example, ϕ(12)=4 because the integers 1, 5, 7, and 11 are coprime to 12.
How do I compute phi(n) from the prime factorization?
Use the formula ϕ(n)=n×∏(1−1/p) where the product runs over all distinct prime factors p of n. For example, ϕ(60)=60×(1−1/2)(1−1/3)(1−1/5)=60×1/2×2/3×4/5=16.
Why is the totient function important in RSA encryption?
RSA encryption relies on ϕ(n) where n=p×q for two large primes. The public and private keys satisfy e×d≡1(modϕ(n)). Security depends on the fact that computing ϕ(n) requires knowing p and q, and factoring large n is computationally infeasible.
What is Euler's theorem?
Euler's theorem states that if gcd(a,n)=1, then aϕ(n)≡1(modn). This generalizes Fermat's little theorem (where n is prime). It is the mathematical foundation that makes RSA decryption work, because raising to the private exponent d reverses the public encryption.
What is the totient of a prime number?
For any prime p, ϕ(p)=p−1, because every integer from 1 to p−1 is coprime to a prime. More generally, for a prime power pk, ϕ(pk)=pk−pk−1=pk−1(p−1).