8.5. Discrete LogarithmsDiscrete logarithms are fundamental to a number of public-key algorithms, including Diffie-Hellman key exchange and the digital signature algorithm (DSA). This section provides a brief overview of discrete logarithms. For the interested reader, more detailed developments of this topic can be found in [ORE67] and [LEVE90]. The Powers of an Integer, Modulo nRecall from Euler's theorem [Equation (8.4)] that, for every a and n that are relatively prime: af(n) 1(mod where f(n), Euler's totient function, is the number of positive integers less than n and relatively prime to n. Now consider the more general expression: Equation 8-10
If a and n are relatively prime, then there is at least one integer m that satisfies Equation (8.10), namely, m = f(n). The least positive exponent m for which Equation (8.10) holds is referred to in several ways:
Table 8.3 shows all the powers of a, modulo 19 for all positive a < 19. The length of the sequence for each base value is indicated by shading. Note the following:
Table 8.3. Powers of Integers, Modulo 19More generally, we can say that the highest possible exponent to which a number can belong (mod n) is f(n). If a number is of this order, it is referred to as a primitive root of n. The importance of this notion is that if a is a primitive root of n, then its powers a, a2,..., af(n) are distinct (mod n) and are all relatively prime to n. In particular, for a prime number p, if a is a primitive root of p, then a, a2,..., ap1 are distinct (mod p). For the prime number 19, its primitive roots are 2, 3, 10, 13, 14, and 15. Not all integers have primitive roots. In fact, the only integers with primitive roots are those of the form 2, 4, pa, and 2pa, where p is any odd prime and a is a positive integer. The proof is not simple but can be found in many number theory books, including [ORE76]. Logarithms for Modular ArithmeticWith ordinary positive real numbers, the logarithm function is the inverse of exponentiation. An analogous function exists for modular arithmetic. Let us briefly review the properties of ordinary logarithms. The logarithm of a number is defined to be the power to which some positive base (except 1) must be raised in order to equal the number. That is, for base x and for a value y: y = xlogx(y) The properties of logarithms include the following: logx(1) = 0 logx(x) = 1 Equation 8-11
Equation 8-12
Consider a primitive root a for some prime number p (the argument can be developed for nonprimes as well). Then we know that the powers of a from 1 through (p 1) produce each integer from 1 through (p 1) exactly once. We also know that any integer b satisfies b p) for some r, where 0 (by the definition of modular arithmetic. It follows that for any integer b and a primitive root a of prime number p, we can find a unique exponent i such that b p) where 0 ( This exponent i is referred to as the discrete logarithm of the number b for the base a (mod p). We denote this value as dloga.p(b).[9] [9] Many texts refer to the discrete logarithm as the index. There is no generally agreed notation for this concept, much less an agreed name. Note the following: Equation 8-13 Equation 8-14 Here is an example using a nonprime modulus, n = 9. Here f(n) = 6 and a = 2 is a primitive root. We compute the various powers of a and find 20 = 1 24 7(mod 9) 21 = 2 25 5(mod 9) 22 = 4 26 1(mod 9) 23 = 8 This gives us the following table of the numbers with given discrete logarithms (mod 9) for the root a = 2: Logarithm 0 1 2 3 4 5 Number 1 2 4 8 7 5 To make it easy to obtain the discrete logarithms of a given number, we rearrange the table: Number 1 2 4 5 7 8 Logarithm 0 1 2 5 4 3 Now consider
Using the rules of modular multiplication,
But now consider Euler's theorem, which states that, for every a and n that are relatively prime: af(n) 1(mod Any positive integer z can be expressed in the form z = q + kf(n), with 0 f(n). Therefore, by Euler's theorem, az n) if z f(n) Applying this to the foregoing equality, we have dloga,p(xy) [dlogx) + dloga,p(y)] (mod f(p)) and generalizing, dloga,p(yr) [a.p(y)] (mod f(n)) This demonstrates the analogy between true logarithms and discrete logarithms. Keep in mind that unique discrete logarithms mod m to some base a exist only if a is a primitive root of m. Table 8.4, which is directly derived from Table 8.3, shows the sets of discrete logarithms that can be defined for modulus 19. Table 8.4. Tables of Discrete Logarithms, Modulo 19 |