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 in their implementation of the Elliptic Curve Digital Signature Algorithm. By reusing the value for , the private key can be directly calculated (the details of which can be seen here)
But the answer to “how do you detect being reused” isn’t as prevalent. In order to detect that is being reused, we can take advantage of the nature of elliptic curves in for some prime .
We know that the signature can be expressed as:
where:
- is the x value of the scalar multiplication of and the generator point . The curve is defined over , while has prime order .
- is the integer derived from the message hash , truncated to the bit length of when necessary and used modulo .
- is such that is the public key and is the private key.
- , and and must be nonzero.
Here’s our first clue: does not change if stays the same. This isn’t enough to conclude that the same is being used, but it is the first indicator.
There are at most two points which have the same x-value on the usual short-Weierstrass curves over for an odd prime . However, taking can make different x-values produce the same . So seeing the same three times does not guarantee that was reused.
For two signatures from the same key with the same , we can test the assumption that was reused. Subtracting their signature equations gives , so:
This requires and different and modulo ; collecting the same signature repeatedly does not help. The inverses are modular inverses modulo . Since and also produce the same , we should also try replacing with when the resulting denominator is nonzero.
Then, you can check each candidate against the known public key: compute and see whether it matches. A candidate nonce must also be nonzero and produce the observed .
With three signatures sharing , we have three pairs to try. Testing and gives us at most six candidate private keys before filtering. At most one will match the public key.