In cryptography, the Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital Signature Algorithm (DSA) which uses elliptic curve cryptography.
Contents
Key and signature-size comparison to DSA
As with elliptic-curve cryptography in general, the bit size of the public key believed to be needed for ECDSA is about twice the size of the security level, in bits. For example, at a security level of 80 bits (meaning an attacker requires a maximum of about
Signature generation algorithm
Suppose Alice wants to send a signed message to Bob. Initially, they must agree on the curve parameters
Alice creates a key pair, consisting of a private key integer
For Alice to sign a message
- Calculate
e = HASH ( m ) , where HASH is a cryptographic hash function, such as SHA-2. - Let
z be theL n e , whereL n n . - Select a cryptographically secure random integer
k from[ 1 , n − 1 ] . - Calculate the curve point
( x 1 , y 1 ) = k × G . - Calculate
r = x 1 mod n . Ifr = 0 , go back to step 3. - Calculate
s = k − 1 ( z + r d A ) mod n . Ifs = 0 , go back to step 3. - The signature is the pair
( r , s ) .
When computing
As the standard notes, it is crucial to select different
Signature verification algorithm
For Bob to authenticate Alice's signature, he must have a copy of her public-key curve point
- Check that
Q A O , and its coordinates are otherwise valid - Check that
Q A - Check that
n × Q A = O
After that, Bob follows these steps:
- Verify that
r ands are integers in[ 1 , n − 1 ] . If not, the signature is invalid. - Calculate
e = HASH ( m ) , where HASH is the same function used in the signature generation. - Let
z be theL n e . - Calculate
w = s − 1 mod n . - Calculate
u 1 = z w mod n andu 2 = r w mod n . - Calculate the curve point
( x 1 , y 1 ) = u 1 × G + u 2 × Q A - The signature is valid if
r ≡ x 1 ( mod n ) , invalid otherwise.
Note that using Shamir's trick, a sum of two scalar multiplications
Correctness of the algorithm
It is not immediately obvious why verification even functions correctly. To see why, denote as
From the definition of the public key as
Because elliptic curve scalar multiplication distributes over addition,
Expanding the definition of
Collecting the common term
Expanding the definition of
Since the inverse of an inverse is the original element, and the product of an element's inverse and the element is the identity, we are left with
From the definition of
This shows only that a correctly signed message will verify correctly; many other properties are required for a secure signature algorithm.
Security
In December 2010, a group calling itself fail0verflow announced recovery of the ECDSA private key used by Sony to sign software for the PlayStation 3 game console. However, this attack only worked because Sony did not properly implement the algorithm, because
On March 29, 2011, two researchers published an IACR paper demonstrating that it is possible to retrieve a TLS private key of a server using OpenSSL that authenticates with Elliptic Curves DSA over a binary field via a timing attack. The vulnerability was fixed in OpenSSL 1.0.0e.
In August 2013, it was revealed that bugs in some implementations of the Java class SecureRandom sometimes generated collisions in the k value. As discussed above, this allowed solution of the private key, in turn allowing stealing bitcoins from the containing wallet on Android app implementations, which use Java and rely on ECDSA to authenticate transactions.
This issue can be prevented by deterministic generation of k, as described by RFC 6979.