Post · 1 min read· p. 127
Multiplicative inverses modulo m
The multiplicative group of integers modulo m is defined as:
Zm∗={a ∣ gcd(a,m)=1}
But why?
This is because Euler’s theorem says that:
gcd(a,m)=1⇒aϕ(m)=1
This in turn, implies that every element in
Zm∗ has an inverse, since:
a⋅aϕ(m)−1=1
Thus, for a prime
p, all elements in
Zp∗={1,2,…,p−1} have inverses.
Specifically, the inverse of
a∈Zp∗ is
ap−2.
Finding primitive roots mod p
Suppose you have \Zp∗={1,2,3,…,p−2,p−1}: i.e., the group of integers mod p, where p is a prime.
How do you find a generator g for it? (a.k.a., primitive roots)
⟨g⟩\bydef{g0,g1,g2,…,gp−2}=\Zp∗
First, you factor its order p−1 as
p−1=i∏qiei, where qi are primes
Second, you simply brute-force: you pick a potential candidate generator g and ensure:
∀i,gqip−1=1(modp)
If all these checks pass, then
g is a generator.