2
$\begingroup$

Let's assume that I choose the bits for my 256-bit private key exponent by flipping a coin 256 times.

Are there any other issues, besides the randomness of the 256-bit private key to consider? For example, should the most significant bit always start with 1 in order to ensure a private key of a certain minimum size or is the probability of flipping enough leading zeros to make the exponent small enough to be dangerous statistically impossible or do you simply check the size of the exponent and if it doesn't reach a minimum threshold you choose a different random exponent?

$\endgroup$
4
$\begingroup$

Are there any other issues, besides the randomness of the 256-bit private key to consider?

Not really. The DLog problem really doesn't have any 'weak keys', that is, keys that can be broken with less effort than other keys.

Now, you might say "hey, isn't the key '1' easier to break than others?" Not really; you might consider '1' easy to break because $g^1$ is easy to recognize - however, for any fixed value $1000000$, the attacker could compute $g^{1000000}$, and check for that exact value - if the attacker sees that value, he knows the private key, and the probability of that happening is exactly the same as him recognizing $g^1$

For example, should the most significant bit always start with 1 in order to ensure a private key of a certain minimum size

No - if you set the msbit, then the attacker can limit the space he is searching by that bit, and that may reduce his effort by a factor of $\sqrt{2}$

Now, if you look at X25519, they really do set an msbit; however not for cryptographical reasons. Instead, the X25519 designer was afraid that an overly clever implementer might skip the leading '0's on the exponent, which would introduce a timing variation (and, in any case, the space reduction point I made above doesn't apply to X25519, because the bits that are variable already cover (almost) the entire subgroup, so setting that one bit doesn't really reduce the attacker's search space).

is the probability of flipping enough leading zeros to make the exponent small enough to be dangerous statistically

The probability that the leading bits are 000...000 is exactly the same as the probability that they are 011...101 (that is, an arbitrary fixed bit pattern). By selecting the exponents randomly, you maximize the number of private keys that are possible.

$\endgroup$
  • 1
    $\begingroup$ A minor correction: as far as I am aware of, even though rho-pollard gives us a sqrt(group size) algorithm for dlog and DH, we do not know of an equivalent algorithm when the exponent comes from a shorter set. Our best algorithms there are linear in the size of the shorter set. So, with respect to known algorithms, as long as the exponent is at least 128 bits long, the best known algorithms do not run faster than in the case where the exponent is uniformly random. $\endgroup$ – Geoffroy Couteau Jun 24 at 22:17
  • 1
    $\begingroup$ @GeoffroyCouteau: Big-Step-Little-Step can take advantage of smaller-than-the-entire-subgroup sizes. To go deeper, to search for a space of size $n$ (which need not be the subgroup size) with $m$ memory, it takes $O(\text{max}(n/m, m))$ time; hence an exponent of 128 bits could be recovered in $O(2^{80})$ time with $O(2^{48})$ memory - a bit too close to realistic for my taste... $\endgroup$ – poncho Jun 25 at 12:20
  • 1
    $\begingroup$ @GeoffroyCouteau: now, fixing one bit (say, the msbit) might not make an algorithm like BSLS realistic; however I don't see the point in making things easier for the attacker (unless we gain something else in the deal) $\endgroup$ – poncho Jun 25 at 12:24
  • 1
    $\begingroup$ Right, somehow I was only thinking rho-pollard and not baby step giant step. Forget my comment :) $\endgroup$ – Geoffroy Couteau Jun 25 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.