← Archive

November 22, 2023

ECDSA: Detecting the Reuse of k

Many people are familiar with the PS3 exploit discovered in 2010 by the fail0Overflow group. This exploit was the result of Sony reusing the value kk in their implementation of the Elliptic Curve Digital Signature Algorithm. By reusing the value for kk, the private key can be directly calculated (the details of which can be seen here)

But the answer to “how do you detect kk being reused” isn’t as prevalent. In order to detect that kk is being used, we can take advantage of the nature of elliptic curves in Zp\mathbb{Z}_p for some prime pp.

We know that the value signature (r,s)(r, s) can be expressed as:

  1. r=xkPmodqr = x_{kP} \mod q
  2. s=H(m)+αrkmodqs = \frac{H(m) + \alpha r}{k} \mod q

where:

Notice that rr does not change if kk is kept the same 👀. This isn’t enough to conclude that the same kk is being used, but it is the first indicator. If we see the same rr value three separate times, we can guarantee that at least two of those signatures used the same value for kk.

We can do this because there are at most two points which have the same x-value in an elliptic curve in Zp\mathbb{Z}_p for some prime pp. Note that taking modq\mod q doesn’t increase the possible number of values.

Then, the steps used in actual break can be done with three pairs to determine three possible private keys.

Then, using knowledge about the components of each ss, you can try each guess for α\alpha until you are reduced to only one that works for all ss. In the worst case, you would be left with three guesses for a while 🤷.