Section 19.1.3

Discrete logarithm and the Diffie–Hellman problem

Definition

The discrete logarithm of an element hh to the base gg, in a group (a set with a multiplication-like operation), is the smallest whole number x≥0x \ge 0 with gx=hg^x = h, where gxg^x means xx copies of gg multiplied together. The discrete logarithm problem asks for xx, given gg and hh. The Diffie–Hellman problem, named after Whitfield Diffie and Martin Hellman, asks for gabg^{ab}, given gg, gag^a and gbg^b but neither aa nor bb. The first asks for a secret exponent; the second asks only for the value that two exponents jointly produce.

The idea

Raising a group element to a power is fast, even when the exponent has hundreds of digits. Repeated squaring computes gxg^x for a 256-bit exponent xx with fewer than 512 multiplications. Going the other way, from gxg^x back to xx, has no known fast method in the groups that cryptography uses. A value gxg^x can therefore be published while xx stays private. Diffie–Hellman key agreement §19.1.4, in which two parties each publish such a value and then compute a shared secret, depends on this one-way behavior.

The word discrete marks the difference from the logarithm of school mathematics. With real numbers, 2x2^x grows steadily, so the size of the result shows roughly how large xx is, and xx can be found by narrowing down. Modulo 23, where every product is replaced by its remainder after division by 23, the powers of 2 are 2, 4, 8, 16, 9, 18, 13, 3, 6, 12, 1. The values jump about, and the size of a result says nothing about its exponent.

Two problems have names because an eavesdropper on a key agreement does not need an exponent. The eavesdropper sees gag^a and gbg^b and wants the shared value gabg^{ab}. Finding aa would be enough, but some other route might exist. The security of the exchange is therefore stated in terms of its own problem. That problem comes in two strengths: computing gabg^{ab}, and merely recognizing it.

How it works

All three problems are stated for a public group and a public element gg of order nn, which means that the powers of gg take exactly nn different values. The exponents aa, bb and xx are chosen at random from 0 to n−1n - 1.

The problems are ordered.

  1. Whoever can find discrete logarithms can solve CDH: find aa from gag^a, then compute (gb)a=gab(g^b)^a = g^{ab}.

  2. Whoever can solve CDH can solve DDH: compute gabg^{ab} and compare it with ww.

Neither step is known to reverse in general. No proof shows that a method for CDH yields a method for discrete logarithms in every group, and there are groups in which DDH is easy although CDH is believed to be hard.

How hard the problems are today is measured by the best known attacks.

Worked example

Use the numbers 1 to 22 with multiplication modulo 23 and the element g=2g = 2, which has order 11. Its powers 212^1 to 2112^{11} are 2, 4, 8, 16, 9, 18, 13, 3, 6, 12, 1.

Discrete logarithm. Given 13, find xx with 2x=132^x = 13. The simplest method is to search the list: 13 is the seventh entry, so x=7x = 7. Check: 27=128=5×23+132^7 = 128 = 5 \times 23 + 13. The search took 7 steps and can never take more than 11. In a group whose order is near 22562^{256}, the same search could take about 22562^{256} steps, and the best general method about 21282^{128}.

Computational Diffie–Hellman problem. Given ga=8g^a = 8 and gb=13g^b = 13, find gabg^{ab}. In this tiny group a logarithm is easy: 8 is the third entry of the list, so a=3a = 3. Then gabg^{ab} is 133=2197=95×23+1213^3 = 2197 = 95 \times 23 + 12 reduced modulo 23, so the answer is 12.

Decisional Diffie–Hellman problem. Given 8, 13 and the candidate 12, the correct answer is that the candidate is gabg^{ab}, which was just computed to be 12. Given 8, 13 and the candidate 6, the correct answer is that the candidate is not gabg^{ab}.

A group in which DDH is easy. Now use the whole group of 22 numbers and the element 5, which has order 22. For any element uu of this group, u11u^{11} is 1 when the exponent of uu to the base 5 is even, and 22 when it is odd. The reason is that 5115^{11} is 22 and 22×22=484=21×23+122 \times 22 = 484 = 21 \times 23 + 1: if uu is 5e5^e, then u11u^{11} is 22e22^e, which is 22 for odd ee and 1 for even ee. Take u=53=125=5×23+10u = 5^3 = 125 = 5 \times 23 + 10, which is 10. Square repeatedly and reduce modulo 23 each time: 102=100=4×23+810^2 = 100 = 4 \times 23 + 8, so 10210^2 is 8; 82=64=2×23+188^2 = 64 = 2 \times 23 + 18, so 10410^4 is 18; 182=324=14×23+218^2 = 324 = 14 \times 23 + 2, so 10810^8 is 2. Since 11=8+2+111 = 8 + 2 + 1, 101110^{11} is 2×8×10=160=6×23+222 \times 8 \times 10 = 160 = 6 \times 23 + 22, reduced: the result is 22, and the exponent is odd. The element v=57v = 5^7, which is 17, gives 22 in the same way. Both exponents are odd, so their product is odd, and the true shared value must also give 22. The candidate 2 gives 1, because 211=2048=89×23+12^{11} = 2048 = 89 \times 23 + 1, so it is rejected without finding any logarithm. A random candidate fails this test half of the time, and the true shared value never fails it. DDH is therefore easy in this group. This is why practice works in a subgroup of prime order, such as the one generated by 2.

Stated precisely

The standard statements fix a cyclic group §19.1.1 GG of prime order qq with generator gg, so that every element of GG is a power of gg, and choose aa, bb, cc and xx independently and uniformly at random from 0 to q−1q - 1. The discrete logarithm problem is to output xx given gxg^x. CDH is to output gabg^{ab} given gag^a and gbg^b. DDH is to say, given gag^a, gbg^b and an element ww that is gabg^{ab} or gcg^c with equal probability, which of the two it is. A problem is called hard in GG when no algorithm that runs in a feasible time succeeds with more than a negligible probability, one too small to matter in practice. For DDH, succeeding means answering correctly with a probability noticeably above one half.

Two implications are proven: if DDH is hard in GG then CDH is hard in GG, and if CDH is hard in GG then the discrete logarithm problem is hard in GG. Assuming that DDH is hard is therefore the strongest of the three assumptions, and assuming that the discrete logarithm problem is hard is the weakest. The hardness itself is not proven for any group. It is an assumption, supported by the failure of every known attack. The best attack known on a standardized elliptic-curve group of prime order qq costs about q\sqrt{q} group operations. On that basis NIST rates an elliptic-curve group whose order has 256 bits at a security strength of 128 bits, meaning that the best known attack needs about 21282^{128} operations.

Limits and common mistakes

Hard is an assumption, not a theorem. A new algorithm would end it. So would a large quantum computer: NIST warns that key agreement based on these problems may have to be replaced when such machines become available.

Hardness belongs to one group with one set of parameters. In the group of the whole numbers 0 to n−1n - 1 under addition modulo nn, repeating the operation xx times multiplies by xx, and the discrete logarithm is found by one division modulo nn, a fast calculation.

The assumptions speak about exponents chosen at random by honest parties. They promise nothing when an attacker chooses an input, or when a private exponent is predictable.

CDH being hard does not make the shared value a good key. Where DDH fails, part of the shared value is predictable, as the test with the eleventh power shows. Protocols therefore pass the shared value through a key derivation function §5.20 (KDF), an algorithm that turns a secret value into keys, and do not use it directly.

Questions answered

Does hardness of one named problem automatically prove every exchange using it secure?

No, the hardness of one named problem does not prove that every exchange using it is secure. A hardness assumption says that one exactly stated computation is infeasible when its inputs are chosen at random by honest parties. A key exchange is secure only if every attack on it would require that computation, and showing this takes a separate proof for the exact protocol. Without solving the hard problem, an exchange can fail in at least these ways.

A security proof for a protocol, called a reduction, shows that any successful attacker of a stated kind could be turned into a solver of a named problem. The proof covers that protocol, that kind of attacker and that problem, and nothing else.

Related entries: Group, cyclic subgroup, generator, and order (§19.1.1), Diffie–Hellman key agreement (§19.1.4), Authenticated key exchange and transcript binding (§19.1.6), Elliptic-curve Diffie–Hellman (ECDH) (§19.1.5), Key derivation function (KDF) (§5.20). Further reading: [147, 152, 432].