Crypto Basics
(Primitive Roots)
Sk Md Mizanur Rahman, Ph.D.
Professor, Cybersecurity
Centennial College, Toronto, Canada
To test that a is a primitive root of p you need to do the following.
First, let s=ϕ(p) where ϕ() is the Euler's totient function.
If p is prime, then s=p−1. Then you need to determine all the
prime factors of s: p1,…,pk.
Finally, calculate as/pi mod p for all i=1…k, and if you find 1
among residuals then it is NOT a primitive root, otherwise it is.
So, basically you need to calculate and check k numbers
where k is the number of different prime factors in ϕ(p).
How you test
Let us find the lowest primitive root of 761:
s=ϕ(761)=760=23×5×19
the powers to test are: 760/2=380, 760/5=152 and 760/19=40
(just 3 instead of testing all of them)
Test 2:
2380 ≡ 1 mod 761 oops
test 3:
3380 ≡ −1 mod 761 OK
3152≡1 mod 761 oops
test 5 (skip 4 because it is 22):
5380≡1 mod 761 oops
test 6:
6380 ≡ −1 mod 761 OK
6152 ≡ 67 mod 761 OK
640 ≡ −263 mod 761 hooray!
So, the least primitive root of 761 is 6.
Example
Once you have found one primitive root, you can
easily find all the others. Indeed, if a is a primitive
root mod p, and p is prime (for simplicity),
then a can generate all other remainders 1…(p−1)
as powers: a1 ≡ a,a2,…, ap−1 ≡ 1.
And am mod p is another primitive root if and only if
m and p−1 are coprime (if gcd (m,p−1)=1).
By the way, this is exactly why you have
ϕ(p−1) primitive roots when p is prime.
How you find all the other primitive roots
16
1
17
)
17
( 



Prime number = 17
}
16
,
15
,
14
,
13
,
12
,
11
,
10
,
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
{
]
16
,
1
[
*
17 


31
mod
17
32
mod
17
33
mod
17
34
mod
17
35
mod
17
36
mod
17
37
mod
17
38
mod
17
39
mod
17
310
mod
17
311
mod
17
312
mod
17
313
mod
17
314
mod
17
315
mod
17
316
mod
17
3 9 10 13 5 15 11 16 14 8 7 4 12 2 6 1
How you find all the other primitive roots(cont…)
Considering “3” as a candidate:
Example:
8
8
16
2
2
)
2
(
)
16
(
)
1
17
(
))
17
(
( 3
4
4








 




GCD(16,2) = 2; GCD(16,3) = 1; so 33 mod 17 = 10 is a primitive root of mod 17
GCD(16,4) = 4; GCD(16,5) = 1; so 35 mod 17 = 5 is a primitive root of mod 17
GCD(16,6) = 2; GCD(16,7) = 1; so 37 mod 17 = 11 is a primitive root of mod 17
GCD(16,8) = 8; GCD(16,9) = 1; so 39 mod 17 = 14 is a primitive root of mod 17
GCD(16,10) = 2; GCD(16,11) = 1; so 311 mod 17 = 7 is a primitive root of mod 17
GCD(16,12) = 4; GCD(16,13) = 1; so 313 mod 17 = 12 is a primitive root of mod 17
GCD(16,14) = 2; GCD(16,15) = 1; so 315 mod 17 = 6 is a primitive root of mod 17
How you find all the other primitive roots (cont…)
101
mod
17
102
mod
17
103
mod
17
104
mod
17
105
mod
17
106
mod
17
107
mod
17
108
mod
17
109
mod
17
1010
mod
17
1011
mod
17
1012
mod
17
1013
mod
17
1014
mod
17
1015
mod
17
1016
mod
17
10 1
How you find all the other primitive roots (cont…)
Considering “10” as a candidate:

Primitive-Roots.pptx

  • 1.
    Crypto Basics (Primitive Roots) SkMd Mizanur Rahman, Ph.D. Professor, Cybersecurity Centennial College, Toronto, Canada
  • 2.
    To test thata is a primitive root of p you need to do the following. First, let s=ϕ(p) where ϕ() is the Euler's totient function. If p is prime, then s=p−1. Then you need to determine all the prime factors of s: p1,…,pk. Finally, calculate as/pi mod p for all i=1…k, and if you find 1 among residuals then it is NOT a primitive root, otherwise it is. So, basically you need to calculate and check k numbers where k is the number of different prime factors in ϕ(p). How you test
  • 3.
    Let us findthe lowest primitive root of 761: s=ϕ(761)=760=23×5×19 the powers to test are: 760/2=380, 760/5=152 and 760/19=40 (just 3 instead of testing all of them) Test 2: 2380 ≡ 1 mod 761 oops test 3: 3380 ≡ −1 mod 761 OK 3152≡1 mod 761 oops test 5 (skip 4 because it is 22): 5380≡1 mod 761 oops test 6: 6380 ≡ −1 mod 761 OK 6152 ≡ 67 mod 761 OK 640 ≡ −263 mod 761 hooray! So, the least primitive root of 761 is 6. Example
  • 4.
    Once you havefound one primitive root, you can easily find all the others. Indeed, if a is a primitive root mod p, and p is prime (for simplicity), then a can generate all other remainders 1…(p−1) as powers: a1 ≡ a,a2,…, ap−1 ≡ 1. And am mod p is another primitive root if and only if m and p−1 are coprime (if gcd (m,p−1)=1). By the way, this is exactly why you have ϕ(p−1) primitive roots when p is prime. How you find all the other primitive roots
  • 5.
    16 1 17 ) 17 (     Prime number= 17 } 16 , 15 , 14 , 13 , 12 , 11 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 { ] 16 , 1 [ * 17    31 mod 17 32 mod 17 33 mod 17 34 mod 17 35 mod 17 36 mod 17 37 mod 17 38 mod 17 39 mod 17 310 mod 17 311 mod 17 312 mod 17 313 mod 17 314 mod 17 315 mod 17 316 mod 17 3 9 10 13 5 15 11 16 14 8 7 4 12 2 6 1 How you find all the other primitive roots(cont…) Considering “3” as a candidate: Example:
  • 6.
    8 8 16 2 2 ) 2 ( ) 16 ( ) 1 17 ( )) 17 ( ( 3 4 4               GCD(16,2)= 2; GCD(16,3) = 1; so 33 mod 17 = 10 is a primitive root of mod 17 GCD(16,4) = 4; GCD(16,5) = 1; so 35 mod 17 = 5 is a primitive root of mod 17 GCD(16,6) = 2; GCD(16,7) = 1; so 37 mod 17 = 11 is a primitive root of mod 17 GCD(16,8) = 8; GCD(16,9) = 1; so 39 mod 17 = 14 is a primitive root of mod 17 GCD(16,10) = 2; GCD(16,11) = 1; so 311 mod 17 = 7 is a primitive root of mod 17 GCD(16,12) = 4; GCD(16,13) = 1; so 313 mod 17 = 12 is a primitive root of mod 17 GCD(16,14) = 2; GCD(16,15) = 1; so 315 mod 17 = 6 is a primitive root of mod 17 How you find all the other primitive roots (cont…)
  • 7.