Prerequisites:
- Elliptic Curves
- Point Addition, Scalar Multiplication
- Cyclic Groups on Elliptic Curves
In this section, we will discuss the following topics:
- Signature Generation using Elliptic Curves
- Signature Verification using Elliptic Curves
- Correctness of the signature algorithm
Consider Alice
as the person who is generating a signature of a message M
and Bob
as a signature verifier.
Let us define the notations that will be used throughout this writeup:
- G - a point on the Elliptic Curve, chosen as the base point
- xQ, yQ - x, y coordinates of a point Q on the Elliptic Curve
- n - order of the subgroup generated by G
- N - order of the Elliptic Curve
- p - size of the finite field over which the Elliptic Curve is defined
- e - HASH(m), where HASH() is a cryptographically secure hash function. A hashing algorithm is selected by signature generator and verifier when the communication between the two is just established.
- z - Ln left most bits of
e
, where Ln is the bit length ofn
- M - message that is to be signed
- dA - Alice's private key
Let PA be Alice's public key which is calculated as , where dA is Alice's private key.
In this section, we will discuss how signatures are generated using Elliptic Curves.
Like most of the Digital Signature Authentication algorithms, ECDSA (Elliptic Curve Digital Signature Authentication) too signs the hash of the message rather than the message itself. This makes it convenient to sign even large sized files/documents.
To sign a message:
- Calculate hash of the message that you want to sign ie. e = HASH(M). Note that HASH() should be a cryptographically secure hash function.
- Calculate
z
= Ln left most bits ofe
, where Ln is the bit length ofn
- Choose a random integer
k
such that- k-1 is the modular multiplicative inverse of k modulo n and can be calculated using Extended Euclid's Algorithm
- Calculate
- Calculate
- Check if r=0, if yes then go back to Step-3
- Calculate
- Check if s=0, if yes then go to back to Step-3
- The pair (r, s) is the signature
Along with the signature pair, there are other values involved in the verification that are public: e, z, Q, G, PA.
In this section, we will discuss how signatures are verified using Elliptic Curves.
Prior to the verification algorithm, the following conditions must be checked and must hold true:
- PA must lie on the curve.
- nPA must be equal to 0, note that 0 is the arbitrary point defined on the Elliptic Curve and is considered to be at infinity and along y-axis
- We are checking this because PA = dAG and nG=0 (Order of the subgroup generated by G multiplied by G is equal to 0). Hence, nPA=k(nG) = k0 = 0
To verify a signature:
- Calculate
- Calculate
- Calculate
- The signature is valid only if , here xT is the x-coordinate of point T
Let us expand Step-3 in the signature verification and then see how the algorithm correctly verifies Alice:
Since, , we can write:
=
Expanding u1 and u2 we can write the above equation as:
Substituting s
we get:
So,
And hence,
To study more about Elliptic Curves and ECDSA, you can refer to this amazing blog post on ECDSA by Andrea Corbellini- http://andrea.corbellini.name/2015/05/30/elliptic-curve-cryptography-ecdh-and-ecdsa/