Definition
The discrete logarithm of an element to the base , in a group (a set with a multiplication-like operation), is the smallest whole number with , where means copies of multiplied together. The discrete logarithm problem asks for , given and . The Diffie–Hellman problem, named after Whitfield Diffie and Martin Hellman, asks for , given , and but neither nor . 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 for a 256-bit exponent with fewer than 512 multiplications. Going the other way, from back to , has no known fast method in the groups that cryptography uses. A value can therefore be published while 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, grows steadily, so the size of the result shows roughly how large is, and 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 and and wants the shared value . Finding 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 , and merely recognizing it.
How it works
All three problems are stated for a public group and a public element of order , which means that the powers of take exactly different values. The exponents , and are chosen at random from 0 to .
Discrete logarithm problem: given , find .
Computational Diffie–Hellman problem (CDH): given and , find .
Decisional Diffie–Hellman problem (DDH): given , and a third element , decide whether is or an unrelated random power of .
The problems are ordered.
Whoever can find discrete logarithms can solve CDH: find from , then compute .
Whoever can solve CDH can solve DDH: compute and compare it with .
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.
In any group, methods such as Pollard’s rho find a discrete logarithm in about group operations. For near that is about operations.
If is a product of smaller primes, the Pohlig–Hellman method solves the problem separately for each prime factor, so the cost is set by the largest prime factor of and not by itself. For that reason the order is chosen to be a large prime.
For the whole numbers modulo a prime , index-calculus methods, which exploit the fact that many whole numbers are products of small primes, are much faster than the general methods, so has to be very long: NIST approves no such group with shorter than 2048 bits. No comparable method is known for the groups of points on the standardized elliptic curves §19.1.5, the other kind of group used for key agreement.
On a large quantum computer, Shor’s algorithm §14.1 [432] finds discrete logarithms in a number of steps that grows only as a fixed power of the length of the numbers, which would make groups of every practical size breakable.
Worked example
Use the numbers 1 to 22 with multiplication modulo 23 and the element , which has order 11. Its powers to are 2, 4, 8, 16, 9, 18, 13, 3, 6, 12, 1.
Discrete logarithm. Given 13, find with . The simplest method is to search the list: 13 is the seventh entry, so . Check: . The search took 7 steps and can never take more than 11. In a group whose order is near , the same search could take about steps, and the best general method about .
Computational Diffie–Hellman problem. Given and , find . In this tiny group a logarithm is easy: 8 is the third entry of the list, so . Then is 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 , which was just computed to be 12. Given 8, 13 and the candidate 6, the correct answer is that the candidate is not .
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 of this group, is 1 when the exponent of to the base 5 is even, and 22 when it is odd. The reason is that is 22 and : if is , then is , which is 22 for odd and 1 for even . Take , which is 10. Square repeatedly and reduce modulo 23 each time: , so is 8; , so is 18; , so is 2. Since , is , reduced: the result is 22, and the exponent is odd. The element , 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 , 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 of prime order with generator , so that every element of is a power of , and choose , , and independently and uniformly at random from 0 to . The discrete logarithm problem is to output given . CDH is to output given and . DDH is to say, given , and an element that is or with equal probability, which of the two it is. A problem is called hard in 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 then CDH is hard in , and if CDH is hard in then the discrete logarithm problem is hard in . 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 costs about 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 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 under addition modulo , repeating the operation times multiplies by , and the discrete logarithm is found by one division modulo , 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.
The wrong problem was named. Hardness of the discrete logarithm problem is not known to imply hardness of the computational Diffie–Hellman problem (CDH), which asks for the shared value. Hardness of CDH is not known to imply hardness of the decisional problem (DDH), which asks only to recognize the shared value, and in some groups DDH is easy although CDH is believed to be hard. An exchange that uses the shared value directly as a key needs the strongest of the three.
The attacker is active. An exchange that does not authenticate its messages lets an intermediary run a separate exchange with each party. The intermediary computes nothing hard.
An input is not honest. A received public value that is not one of the values the protocol intends, for example an element whose powers take only a few different values, can confine the shared value to a few possibilities or leak part of a private key.
The randomness is poor. A private exponent that can be guessed is found by guessing, not by computing a logarithm.
The result is misused. The shared value must go through a key derivation function (KDF), an algorithm that turns a secret value into keys, and the keys must be tied to the identities of both parties.
The implementation leaks. Running time or power use that depends on the private exponent can reveal it through a side channel §1.29.
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].