Table of contents
Open Table of contents
What it is
The Elliptic Curve Digital Signature Algorithm (ECDSA) is a standard that’s used to generate digital signatures over arbitrary messages. Such digital signatures can then be verified by a third party in a non-interactive way.
How it works
Our example assumes that Alice wants to create a digital signature for a message which is then verified by Bob.
We’ll be working with the Elliptic Curve that is of order and has a generator . All calculations are done if not stated otherwise.
As a first step, Alice generates her private key by sampling a random value from . Once done, she derives the public key by multiplying her private key with the generator :
Alice then samples another, random value from that’s called the “nonce” (number used once). It’s of utmost important that this value is truly random and never reused.
Next up, the value is derived by multiplying with the generator :
Given that the value is a point on the Elliptic Curve it has an - and -coordinate. Alice can therefore define the value as the -coordinate of :
If , Alice needs to discard and sample another, random nonce and derive and as she did before. This has to be done until .
Alice now needs to turn the message she wants to sign into a representation that can be “mapped onto” the Elliptic Curve . This can be done by hashing via a cryptographic hash function and interpreting its result as a point on the curve:
Finally she computes the value :
If , Alice needs to discard and sample another, random nonce and derive , and as she did before. This has to be done until .
The signature for the message is the tuple which Alice can send alongside her public key to Bob for verification.
To verify Alice’s signature, Bob recomputes as .
He then calculates , and as follows:
The signature is valid if .
That is, if the value from Alice’s signature equals the -coordinate of the Elliptic Curve point that Bob calculated as .
Why it works
While the ECDSA signature verification algorithm might seem daunting at first, it’s easy to see why it works if we apply some basic algebra.
First, let’s recall that is the hash of the message that’s interpreted as a point on the Elliptic Curve .
We can now use the value from the signature to isolate :
By expanding and substituting for (as we’ve just calculated), we can see that :
Checking the signature generation procedure above, we can verify that this Elliptic Curve point is the same as the one Alice derived from .
This implies that its -coordinate is equal to the value of the signature. The signature over the message is therefore valid.
A note on nonce reuse
As we’ve highlighted above, it’s of utmost importance that the nonce is never reused as otherwise attackers who get access to two signatures that were generated with the same nonce can extract the private key .
To see how this would work, let’s pretend that we got our hands on two such signatures and .
The first thing to note is that . This is because is the -coordinate of and given that is reused, is also the -coordinate of the same .
Looking at and we can subtract both from each other to extract as follows:
We can now use to extract the private key from any :
To see how severe this issue really is you can take a look at the PlayStation 3 Homebrew Wikipedia Article which has a section on the infamous private key compromise in which the key was extracted exactly the way you just learned.
References
The following resources have been invaluable for me to learn the concepts discussed in this article.
You should definitely give them a read if you want to dive deeper into the topic.