If p is a a prime number and a∈{1,2,⋯,p−1} then ap−1≡1modp.
Variation: if p is prime then ap≡amodp for any integer a
Generalization
Let ϕ(n) be the number of integers between 1 and n that are relatively prime with n(this is Euler’s totient function). Then aϕ(n)≡1modn.
RSA
Premise: Alice wants to securely send a message x to Bob
Procedure
Bob chooses two primes p and q, and lets N=pq
Bob finds e and d which are multiplicative inverses mod(p−1)(q−1)
this means e and d are relatively prime with (p−1)(q−1)
Bob posts his public key (N,e) to the world and keeps d private
Alice sends Bob the value of E(x)=xemodN
Bob receives E(x) and decrypts it using the function D(y)=ydmodN
D(E(x))=E(x)d=(xe)d=xedmodN
It turns out that xed=xmodN, which is the original message
Fermat’s Little Theorem
Generalization
RSA
Procedure