Modular Exponentiation
Suppose we are asked to compute modulo . We could calculate and then reduce mod , but a better way is to observe . Since we have , and lastly
The second way is better because the numbers involved are smaller.
This trick, known as repeated squaring, allows us to compute mod using only modular multiplications. (We can use the same trick when exponentiating integers, but then the multiplications are not modular multiplications, and each multiplication takes at least twice as long as the previous one.)
The Discrete Log Problem
Let us examine the behaviour of the successive powers of modulo .
Note we compute each power by mulitplying the previous answer by then reducing modulo . Beyond this, the sequence repeats itself (why?):
and so on.
At a glance, the sequence seems to have no order or structure whatsoever. In fact, although there are things we can say about this sequence (for example, members three elements apart add up to 7), it turns out that so little is known about the behaviour of this sequence that the following problem is difficult to solve efficiently:
(The discrete log problem) Let be a prime, and be two elements of . Suppose it is known that . Then what is ?
Example: One instance of the discrete log problem: find so that . (Answer: . Strictly speaking, any will work.)
Recall when we first encountered modular inversion we argued we could try every element in turn to find an inverse, but this was too slow to be used in practice. The same is true for discrete logs: we could try every possible power until we find it, but this is impractical.
Euclid’s algorithm gave us a fast way to compute inverses. However no fast algorithm for finding discrete logs is known. The best discrete log algorithms known are faster than trying every element, but are not polynomial time.
Nonunits
Why don’t we bother studying the behaviour of nonunits under exponentiation?
First consider when for some prime . Then is nonunit exactly when , which in this case means for some .
We have , thus in at most steps we hit zero, which is uninteresting (at least for our purposes).
In general, write . By the Chinese Remainder Theorem we have
Thus an element corresponds to some element on the right-hand side, and is a nonunit if at least one of the is a multiple of . From above, this means in at most steps, the th member will reach zero, so in general, for some , each is zero or a unit, hence we can restrict our study to units.
Note we have again followed an earlier suggestion: we handle the prime power case first and then generalize using the Chinese Remainder Theorem.