Processing math: 100%
Skip to main content

Section 10.5 A Practical Use of Primitive Roots

We will soon begin talking about cryptography and related matters. Before we do so, we will preview our computational needs by using primitive roots to solve some congruences in a cool way.

Suppose you want to solve a more involved congruence than the basic ones we have tackled thus far. A general form that we might want to solve would look like

ab≑c (mod n)

where either a or b might be a variable, and n would be prime or a prime power. Here are two examples:

  • x3≑5 (mod 17)

  • 5x≑17 (mod 19)

You can think of the first one as finding a higher root modulo n, and the second one as finding a logarithm modulo n.

As we will see below, our general strategy will be to find a primitive root g of n (when this is possible) and write both as powers of g, e.g. a=gi and c=gj for some i,j∈Z. Then our congruence will become

gib≑gj (mod n)

and thinking of it as solving in the exponents ib and j will be productive.

Subsection 10.5.1 Finding a higher root

With that as introduction, let's examine one way to solve the first congruence using this idea.

First, find a primitive root modulo 17. Obviously we could just ask Sage and its builtin command primitive_root, or use Lemma 10.2.3 with trial and error. In the not too distant past, the back of every number theory text had a table of primitive roots!

Now what we will do is try to represent both sides of

x3≑5 (mod 17)

as powers of that primitive root.

The easy part is representing x3; we just say that x≑3i for some (as yet unknown) i, so

x3≑(3i)3≑33i.

The harder part is figuring out what power of 3 gives 5. Again, there is no shortcut, though number theory texts in the past had huge tables of them, and their powers (for easy reference). In practice, one would have all powers of a given primitive root available for use ahead of time.

By substituting the primitive roots in for x3 and 5, we transform

x3≑5 (mod 17)

into the congruence

33i≑35 (mod 17).

This is a much more familiar type of problem. How would we have solved this in high school? You would solve it this way, with equations (not congruences):

33i=35β‡’3i=5β‡’i=5/3.

We will try to do something very similar here.

What is very important is that this congruence is, in some sense, really no longer a congruence in Z17. To be precise, everything in sight is really in U17, a cyclic group of order Ο•(17)=16. But a cyclic group of order 16 would just be the same as thinking modulo sixteen! So we can take out the exponents, just like in precalculus, but do things (mod 16):

3i≑5 (mod 16).

(See Exercise 10.6.14 to justify doing this manipulation.)

A little guess and check (or more powerful methods earlier in the book) show that i=7 suffices, so that x=37≑11 (mod 17) is the solution. And we figured it out without taking every cube out there!

Indeed, doing just that confirms our result. We take all cubes starting at 2, and the one corresponding to 11 is what we want:

Note the use of range from Sage note 2.1.3. Why do you think we used it here?

Example 10.5.1.

If we change the congruence to a fourth power x4≑5 (mod 17), the only change is that now we have to solve 4i≑5 (mod 16). However, there are no such solutions since gcd(4,16)=4∀5, and we confirm this by seeing that 5 does not show up in this list:

Example 10.5.2.

Finally, let's try solving the closely related x3≑7 (mod 19). Here, a primitive root is 2, and it turns out that 26≑7, so we may attempt a solution. We obtain

23i≑26 (mod 19)β‡’3i≑6 (mod 18),

which definitely does have solutions.

In fact, there are three solutions (2,8,14) to the reduced congruence

i≑2 (mod 6)

so there are three solutions (22,28,214) to the original congruence. Let's check this:

A similar strategy can work for higher degree congruences. (See [C.2.4, Theorem 8.17] for a general statement on when such solutions exist, which we will omit for the sake of space.)

Example 10.5.3.

If we try solving x6≑8 (mod 49), we'll need a primitive root of 49; 3 works. I can find out what power 3i of 3 yields 8:

Looks like it's 336. So we write x=3i for some as yet unknown i, and get

36i≑336 (mod 49),

which gives us

6i≑36 (mod Ο•(49)=42)

which itself reduces to

i≑6 (mod 7).

So i=6,13,20,27,34,41 all work, which means that x=3i≑43,10,16,6,39,33 all should work.

Subsection 10.5.2 Discrete logarithms

Similarly, we can try to solve logarithmic examples like

5x≑17 (mod 19).

Indeed, solving this problem is an example of what is called a discrete logarithm problem. Such problems are apparently very, very hard to solve quickly, but (!) no one has every actually proved this.

Example 10.5.4.

Let's solve 5x≑17 (mod 19). As we noted in Example 10.5.2, a primitive root modulo 19 is 2, and we can check that 5≑216 (mod 19) and 17≑210 (mod 19). Then, replacing these, we see that

216x≑210 (mod 19)

yields

16x≑10 (mod 18).

Since each of the numbers in this latter congruence is even, we can reduce this to 8x≑5 (mod 9), which further reduces to the easy-to-solve βˆ’x≑5 (mod 9).

Taking xβ‰‘βˆ’5≑4, and keeping in mind the original modulus of 18, that suggests that we could let x≑4,13 in solving the original congruence. And indeed

54≑513≑17 (mod 19)

as desired:

Sage note 10.5.5. Reminder on equality.

To check whether two things are equal, remember that you can just use == with the two expressions and see if you get True or False.

Example 10.5.6.

Let's try to solve 16x≑13 (mod 19).

Again, 2 is a primitive root of 19, and obviously 16=24. It might look harder to represent 13; of course we could do it with the computer, but note that 13+19=32=25. Sometimes we really can do them by hand!

Thus our congruence becomes

24x≑25 (mod 19)

which yields

4x≑5 (mod 18).

However, since gcd(4,18)=2∀5, by Proposition 5.1.1 this latter congruence has no solutions, so neither does the original congruence. (It turns out that 16 has only order 9 as an element of U19, and evidently 13 is not one of the elements in the subgroup generated by 16.)