Elliptic Curve Digital Signature Algorithm Explained

In cryptography, the Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital Signature Algorithm (DSA) which uses elliptic-curve cryptography.

Key and signature sizes

As with elliptic-curve cryptography in general, the bit size of the private key believed to be needed for ECDSA is about twice the size of the security level, in bits.[1] For example, at a security level of 80 bits - meaning an attacker requires a maximum of about

280

operations to find the private key - the size of an ECDSA private key would be 160 bits. On the other hand, the signature size is the same for both DSA and ECDSA: approximately

4t

bits, where

t

is the exponent in the formula

2t

, that is, about 320 bits for a security level of 80 bits, which is equivalent to

280

operations.

Signature generation algorithm

Suppose Alice wants to send a signed message to Bob. Initially, they must agree on the curve parameters

(rm{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

.
Parameter
CURVE the elliptic curve field and equation used
G elliptic curve base point, a point on the curve that generates a subgroup of large prime order n
n integer order of G, means that

n x G=O

, where

O

is the identity element.

dA

the private key (randomly selected)

QA

the public key

dA x G

(calculated by elliptic curve)
mthe message to send

The order

n

of the base point

G

must be prime. Indeed, we assume that every nonzero element of the ring

Z/nZ

is invertible, so that

Z/nZ

must be a field. It implies that

n

must be prime (cf. Bézout's identity).

Alice creates a key pair, consisting of a private key integer

dA

, randomly selected in the interval

[1,n-1]

; and a public key curve point

QA=dA x G

. We use

x

to denote elliptic curve point multiplication by a scalar.

For Alice to sign a message

m

, she follows these steps:
  1. Calculate

e=rm{HASH}(m)

. (Here HASH is a cryptographic hash function, such as SHA-2, with the output converted to an integer.)
  1. Let

z

be the

Ln

leftmost bits of

e

, where

Ln

is the bit length of the group order

n

. (Note that

z

can be greater than

n

but not longer.[2])
  1. Select a cryptographically secure random integer

k

from

[1,n-1]

.
  1. Calculate the curve point

(x1,y1)=k x G

.
  1. Calculate

r=x1\bmodn

. If

r=0

, go back to step 3.
  1. Calculate

s=k-1(z+rdA)\bmodn

. If

s=0

, go back to step 3.
  1. The signature is the pair

(r,s)

. (And

(r,-s\bmodn)

is also a valid signature.)

As the standard notes, it is not only required for

k

to be secret, but it is also crucial to select different

k

for different signatures. Otherwise, the equation in step 6 can be solved for

dA

, 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+rdA)

, the attacker can now calculate the private key

dA=

sk-z
r
.

This implementation failure was used, for example, to extract the signing key used for the PlayStation 3 gaming-console.[3]

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.[4]

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.[5]

Signature verification algorithm

For Bob to authenticate Alice's signature

r,s

on a message

m

, he must have a copy of her public-key curve point

QA

. Bob can verify

QA

is a valid curve point as follows:
  1. Check that

QA

is not equal to the identity element, and its coordinates are otherwise valid.
  1. Check that

QA

lies on the curve.
  1. Check that

n x QA=O

.

After that, Bob follows these steps:

  1. Verify that and are integers in

[1,n-1]

. If not, the signature is invalid.
  1. Calculate

e=rm{HASH}(m)

, where HASH is the same function used in the signature generation.
  1. Let

z

be the

Ln

leftmost bits of .
  1. Calculate

u1=zs-1\bmodn

and

u2=rs-1\bmodn

.
  1. Calculate the curve point

(x1,y1)=u1 x G+u2 x QA

. If

(x1,y1)=O

then the signature is invalid.
  1. The signature is valid if

r\equivx1\pmod{n}

, invalid otherwise.

Note that an efficient implementation would compute inverse

s-1\bmodn

only once. Also, using Shamir's trick, a sum of two scalar multiplications

u1 x G+u2 x QA

can be calculated faster than two scalar multiplications done independently.[6]

Correctness of the algorithm

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

C=u1 x G+u2 x QA

From the definition of the public key as

QA=dA x G

,

C=u1 x G+u2dA x G

Because elliptic curve scalar multiplication distributes over addition,

C=(u1+u2dA) x G

Expanding the definition of

u1

and

u2

from verification step 4,

C=(zs-1+rdAs-1) x G

Collecting the common term

s-1

,

C=(z+rdA)s-1 x G

Expanding the definition of from signature step 6,

C=(z+rdA)(z+r

-1
d
A)

(k-1)-1 x 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 x G

From the definition of, this is verification step 6.

This shows only that a correctly signed message will verify correctly; other properties such as incorrectly signed messages failing to verify correctly and resistance to cryptanalytic attacks are required for a secure signature algorithm.

Public key recovery

Given a message and Alice's signature

r,s

on that message, Bob can (potentially) recover Alice's public key:[7]
  1. Verify that and are integers in

[1,n-1]

. If not, the signature is invalid.
  1. Calculate a curve point

R=(x1,y1)

where

x1

is one of

r

,

r+n

,

r+2n

, etc. (provided

x1

is not too large for the field of the curve) and

y1

is a value such that the curve equation is satisfied. Note that there may be several curve points satisfying these conditions, and each different value results in a distinct recovered key.
  1. Calculate

e=rm{HASH}(m)

, where HASH is the same function used in the signature generation.
  1. Let be the

Ln

leftmost bits of .
  1. Calculate

u1=-zr-1\bmodn

and

u2=sr-1\bmodn

.
  1. Calculate the curve point

QA=(xA,yA)=u1 x G+u2 x R

.
  1. The signature is valid if

QA

, matches Alice's public key.
  1. The signature is invalid if all the possible points have been tried and none match Alice's public key.

Note that an invalid signature, or a signature from a different message, will result in the recovery of an incorrect public key. The recovery algorithm can only be used to check validity of a signature if the signer's public key (or its hash) is known beforehand.

Correctness of the recovery algorithm

Start with the definition of

QA

from recovery step 6,

QA=(xA,yA)=u1 x G+u2 x R

From the definition

R=(x1,y1)=k x G

from signing step 4,

QA=u1 x G+u2k x G

Because elliptic curve scalar multiplication distributes over addition,

QA=(u1+u2k) x G

Expanding the definition of

u1

and

u2

from recovery step 5,

QA=(-zr-1+skr-1) x G

Expanding the definition of from signature step 6,

QA=(-zr-1+k-1(z+rdA)kr-1) x G

Since the product of an element's inverse and the element is the identity, we are left with

QA=(-zr-1+(zr-1+dA)) x G

The first and second terms cancel each other out,

QA=dA x G

From the definition of

QA=dA x G

, this is Alice's public key.

This shows that a correctly signed message will recover the correct public key, provided additional information was shared to uniquely calculate curve point

R=(x1,y1)

from signature value .

Security

In December 2010, a group calling itself fail0verflow announced the 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

dA

solvable, rendering the entire algorithm useless.[8]

On March 29, 2011, two researchers published an IACR paper[9] 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.[10] The vulnerability was fixed in OpenSSL 1.0.0e.[11]

In August 2013, it was revealed that bugs in some implementations of the Java class SecureRandom sometimes generated collisions in the

k

value. This allowed hackers to recover private keys giving them the same control over bitcoin transactions as legitimate keys' owners had, using the same exploit that was used to reveal the PS3 signing key on some Android app implementations, which use Java and rely on ECDSA to authenticate transactions.[12]

This issue can be prevented by deterministic generation of k, as described by RFC 6979.

Concerns

Some concerns expressed about ECDSA:

  1. Political concerns: the trustworthiness of NIST-produced curves being questioned after revelations were made that the NSA willingly inserts backdoors into software, hardware components and published standards; well-known cryptographers[13] have expressed[14] [15] doubts about how the NIST curves were designed, and voluntary tainting has already been proved in the past.[16] [17] (See also the libssh curve25519 introduction.[18]) Nevertheless, a proof that the named NIST curves exploit a rare weakness is missing yet.
  2. Technical concerns: the difficulty of properly implementing the standard, its slowness, and design flaws which reduce security in insufficiently defensive implementations.[19]

Implementations

Below is a list of cryptographic libraries that provide support for ECDSA:

See also

Further reading

External links

Notes and References

  1. The Elliptic Curve Digital Signature Algorithm (ECDSA). 1999. Don. Johnson. Alfred. Menezes. 10.1.1.38.8014. Certicom research. Canada.
  2. http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf NIST FIPS 186-4, July 2013, pp. 19 and 26
  3. https://events.ccc.de/congress/2010/Fahrplan/attachments/1780_27c3_console_hacking_2010.pdf Console Hacking 2010 - PS3 Epic Fail
  4. Web site: Android Security Vulnerability. February 24, 2015.
  5. RFC 6979 - Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA). 2013 . 10.17487/RFC6979 . February 24, 2015. Pornin . T. . free .
  6. Web site: The Double-Base Number System in Elliptic Curve Cryptography . 22 April 2014.
  7. Daniel R. L. Brown SECG SEC 1: Elliptic Curve Cryptography (Version 2.0) https://www.secg.org/sec1-v2.pdf
  8. News: Bendel. Mike. Hackers Describe PS3 Security As Epic Fail, Gain Unrestricted Access. Exophase.com. 2010-12-29. 2011-01-05.
  9. Web site: Cryptology ePrint Archive: Report 2011/232. February 24, 2015.
  10. Web site: Vulnerability Note VU#536044 - OpenSSL leaks ECDSA private key through a remote timing attack. www.kb.cert.org.
  11. Web site: ChangeLog . OpenSSL Project . 22 April 2014.
  12. Web site: Android bug batters Bitcoin wallets . The Register . 12 August 2013.
  13. Web site: The NSA Is Breaking Most Encryption on the Internet. Schneier on Security. Bruce. Schneier. September 5, 2013.
  14. Web site: SafeCurves: choosing safe curves for elliptic-curve cryptography. Oct 25, 2013.
  15. Web site: Security dangers of the NIST curves. Daniel J.. Bernstein. Tanja. Lange. Tanja Lange. May 31, 2013.
  16. Web site: The Strange Story of Dual_EC_DRBG. Schneier on Security. Bruce. Schneier. November 15, 2007.
  17. Web site: NSA Efforts to Evade Encryption Technology Damaged U.S. Cryptography Standard. Larry. Greenemeier. Scientific American. September 18, 2013.
  18. Web site: curve25519-sha256@libssh.org.txt\doc - projects/libssh.git. libssh shared repository.
  19. Web site: How to design an elliptic-curve signature system. Daniel J.. Bernstein. March 23, 2014. The cr.yp.to blog.