Suvarna Garge (Editor)

Elliptic Curve Digital Signature Algorithm

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

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 2 80 operations to find the private key) the size of an ECDSA public key would be 160 bits, whereas the size of a DSA public key is at least 1024 bits. On the other hand, the signature size is the same for both DSA and ECDSA: 4 t bits, where t is the security level measured in bits, that is, about 320 bits for a security level of 80 bits.

Signature generation algorithm

Suppose Alice wants to send a signed message to Bob. Initially, they must agree on the curve parameters ( CURVE , G , n ) . In addition to the field and equation of the curve, we need G , a base point of prime order on the curve; n is the multiplicative order of the point G .

Alice creates a key pair, consisting of a private key integer d A , randomly selected in the interval [ 1 , n 1 ] ; and a public key curve point Q A = d A × G . We use × to denote elliptic curve point multiplication by a scalar.

For Alice to sign a message m , she follows these steps:

  1. Calculate e = HASH ( m ) , where HASH is a cryptographic hash function, such as SHA-2.
  2. Let z be the L n leftmost bits of e , where L n is the bit length of the group order n .
  3. Select a cryptographically secure random integer k from [ 1 , n 1 ] .
  4. Calculate the curve point ( x 1 , y 1 ) = k × G .
  5. Calculate r = x 1 mod n . If r = 0 , go back to step 3.
  6. Calculate s = k 1 ( z + r d A ) mod n . If s = 0 , go back to step 3.
  7. The signature is the pair ( r , s ) .

When computing s , the string z resulting from HASH ( m ) shall be converted to an integer. Note that z can be greater than n but not longer.

As the standard notes, it is crucial to select different k for different signatures, otherwise the equation in step 6 can be solved for d A , the private key: Given two signatures ( r , s ) and ( r , s ) , employing the same unknown k for different known messages m and m , an attacker can calculate z and z , and since s s = k 1 ( z z ) (all operations in this paragraph are done modulo n ) the attacker can find k = z z s s . Since s = k 1 ( z + r d A ) , the attacker can now calculate the private key d A = s k z r . This implementation failure was used, for example, to extract the signing key used in the PlayStation 3 gaming-console. Another way ECDSA signature may leak private keys is when k is generated by a faulty random number generator. Such a failure in random number generation caused users of Android Bitcoin Wallet to lose their funds in August 2013. To ensure that k is unique for each message one may bypass random number generation completely and generate deterministic signatures by deriving k from both the message and the private key.

Signature verification algorithm

For Bob to authenticate Alice's signature, he must have a copy of her public-key curve point Q A . Bob can verify Q A is a valid curve point as follows:

  1. Check that Q A is not equal to the identity element O , and its coordinates are otherwise valid
  2. Check that Q A lies on the curve
  3. Check that n × Q A = O

After that, Bob follows these steps:

  1. Verify that r and s are integers in [ 1 , n 1 ] . If not, the signature is invalid.
  2. Calculate e = HASH ( m ) , where HASH is the same function used in the signature generation.
  3. Let z be the L n leftmost bits of e .
  4. Calculate w = s 1 mod n .
  5. Calculate u 1 = z w mod n and u 2 = r w mod n .
  6. Calculate the curve point ( x 1 , y 1 ) = u 1 × G + u 2 × Q A .
  7. The signature is valid if r x 1 ( mod n ) , invalid otherwise.

Note that using Shamir's trick, a sum of two scalar multiplications u 1 × G + u 2 × Q A can be calculated faster than two scalar multiplications done independently.

Correctness of the algorithm

It is not immediately obvious why verification even functions correctly. To see why, denote as C the curve point computed in step 6 of verification,

C = u 1 × G + u 2 × Q A

From the definition of the public key as Q A = d A × G ,

C = u 1 × G + u 2 d A × G

Because elliptic curve scalar multiplication distributes over addition,

C = ( u 1 + u 2 d A ) × G

Expanding the definition of u 1 and u 2 from verification step 5,

C = ( z s 1 + r d A s 1 ) × G

Collecting the common term s 1 ,

C = ( z + r d A ) s 1 × G

Expanding the definition of s from signature step 6,

C = ( z + r d A ) ( z + r d A ) 1 ( k 1 ) 1 × G

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

C = k × G

From the definition of r , this is verification step 6.

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 k was static instead of random. As pointed out in the Signature generation algorithm section above, this makes d A solvable and the entire algorithm useless.

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.

References

Elliptic Curve Digital Signature Algorithm Wikipedia


Similar Topics