- Source: Elliptic Curve Digital Signature Algorithm
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. For example, at a security level of 80 bits—meaning an attacker requires a maximum of about
2
80
{\displaystyle 2^{80}}
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
4
t
{\displaystyle 4t}
bits, where
t
{\displaystyle t}
is the exponent in the formula
2
t
{\displaystyle 2^{t}}
, that is, about 320 bits for a security level of 80 bits, which is equivalent to
2
80
{\displaystyle 2^{80}}
operations.
Signature generation algorithm
Suppose Alice wants to send a signed message to Bob. Initially, they must agree on the curve parameters
(
CURVE
,
G
,
n
)
{\displaystyle ({\textrm {CURVE}},G,n)}
. In addition to the field and equation of the curve, we need
G
{\displaystyle G}
, a base point of prime order on the curve;
n
{\displaystyle n}
is the multiplicative order of the point
G
{\displaystyle G}
.
The order
n
{\displaystyle n}
of the base point
G
{\displaystyle G}
must be prime. Indeed, we assume that every nonzero element of the ring
Z
/
n
Z
{\displaystyle \mathbb {Z} /n\mathbb {Z} }
is invertible, so that
Z
/
n
Z
{\displaystyle \mathbb {Z} /n\mathbb {Z} }
must be a field. It implies that
n
{\displaystyle n}
must be prime (cf. Bézout's identity).
Alice creates a key pair, consisting of a private key integer
d
A
{\displaystyle d_{A}}
, randomly selected in the interval
[
1
,
n
−
1
]
{\displaystyle [1,n-1]}
; and a public key curve point
Q
A
=
d
A
×
G
{\displaystyle Q_{A}=d_{A}\times G}
. We use
×
{\displaystyle \times }
to denote elliptic curve point multiplication by a scalar.
For Alice to sign a message
m
{\displaystyle m}
, she follows these steps:
Calculate
e
=
HASH
(
m
)
{\displaystyle e={\textrm {HASH}}(m)}
. (Here HASH is a cryptographic hash function, such as SHA-2, with the output converted to an integer.)
Let
z
{\displaystyle z}
be the
L
n
{\displaystyle L_{n}}
leftmost bits of
e
{\displaystyle e}
, where
L
n
{\displaystyle L_{n}}
is the bit length of the group order
n
{\displaystyle n}
. (Note that
z
{\displaystyle z}
can be greater than
n
{\displaystyle n}
but not longer.)
Select a cryptographically secure random integer
k
{\displaystyle k}
from
[
1
,
n
−
1
]
{\displaystyle [1,n-1]}
.
Calculate the curve point
(
x
1
,
y
1
)
=
k
×
G
{\displaystyle (x_{1},y_{1})=k\times G}
.
Calculate
r
=
x
1
mod
n
{\displaystyle r=x_{1}\,{\bmod {\,}}n}
. If
r
=
0
{\displaystyle r=0}
, go back to step 3.
Calculate
s
=
k
−
1
(
z
+
r
d
A
)
mod
n
{\displaystyle s=k^{-1}(z+rd_{A})\,{\bmod {\,}}n}
. If
s
=
0
{\displaystyle s=0}
, go back to step 3.
The signature is the pair
(
r
,
s
)
{\displaystyle (r,s)}
. (And
(
r
,
−
s
mod
n
)
{\displaystyle (r,-s\,{\bmod {\,}}n)}
is also a valid signature.)
As the standard notes, it is not only required for
k
{\displaystyle k}
to be secret, but it is also crucial to select different
k
{\displaystyle k}
for different signatures. Otherwise, the equation in step 6 can be solved for
d
A
{\displaystyle d_{A}}
, the private key: given two signatures
(
r
,
s
)
{\displaystyle (r,s)}
and
(
r
,
s
′
)
{\displaystyle (r,s')}
, employing the same unknown
k
{\displaystyle k}
for different known messages
m
{\displaystyle m}
and
m
′
{\displaystyle m'}
, an attacker can calculate
z
{\displaystyle z}
and
z
′
{\displaystyle z'}
, and since
s
−
s
′
=
k
−
1
(
z
−
z
′
)
{\displaystyle s-s'=k^{-1}(z-z')}
(all operations in this paragraph are done modulo
n
{\displaystyle n}
) the attacker can find
k
=
z
−
z
′
s
−
s
′
{\displaystyle k={\frac {z-z'}{s-s'}}}
. Since
s
=
k
−
1
(
z
+
r
d
A
)
{\displaystyle s=k^{-1}(z+rd_{A})}
, the attacker can now calculate the private key
d
A
=
s
k
−
z
r
{\displaystyle d_{A}={\frac {sk-z}{r}}}
.
This implementation failure was used, for example, to extract the signing key used for the PlayStation 3 gaming-console.
Another way ECDSA signature may leak private keys is when
k
{\displaystyle 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
{\displaystyle k}
is unique for each message, one may bypass random number generation completely and generate deterministic signatures by deriving
k
{\displaystyle k}
from both the message and the private key.
Signature verification algorithm
For Bob to authenticate Alice's signature
r
,
s
{\displaystyle r,s}
on a message
m
{\displaystyle m}
, he must have a copy of her public-key curve point
Q
A
{\displaystyle Q_{A}}
. Bob can verify
Q
A
{\displaystyle Q_{A}}
is a valid curve point as follows:
Check that
Q
A
{\displaystyle Q_{A}}
is not equal to the identity element O, and its coordinates are otherwise valid.
Check that
Q
A
{\displaystyle Q_{A}}
lies on the curve.
Check that
n
×
Q
A
=
O
{\displaystyle n\times Q_{A}=O}
.
After that, Bob follows these steps:
Verify that r and s are integers in
[
1
,
n
−
1
]
{\displaystyle [1,n-1]}
. If not, the signature is invalid.
Calculate
e
=
HASH
(
m
)
{\displaystyle e={\textrm {HASH}}(m)}
, where HASH is the same function used in the signature generation.
Let
z
{\displaystyle z}
be the
L
n
{\displaystyle L_{n}}
leftmost bits of e.
Calculate
u
1
=
z
s
−
1
mod
n
{\displaystyle u_{1}=zs^{-1}\,{\bmod {\,}}n}
and
u
2
=
r
s
−
1
mod
n
{\displaystyle u_{2}=rs^{-1}\,{\bmod {\,}}n}
.
Calculate the curve point
(
x
1
,
y
1
)
=
u
1
×
G
+
u
2
×
Q
A
{\displaystyle (x_{1},y_{1})=u_{1}\times G+u_{2}\times Q_{A}}
. If
(
x
1
,
y
1
)
=
O
{\displaystyle (x_{1},y_{1})=O}
then the signature is invalid.
The signature is valid if
r
≡
x
1
(
mod
n
)
{\displaystyle r\equiv x_{1}{\pmod {n}}}
, invalid otherwise.
Note that an efficient implementation would compute inverse
s
−
1
mod
n
{\displaystyle s^{-1}\,{\bmod {\,}}n}
only once. Also, using Shamir's trick, a sum of two scalar multiplications
u
1
×
G
+
u
2
×
Q
A
{\displaystyle u_{1}\times G+u_{2}\times 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 5 of verification,
C
=
u
1
×
G
+
u
2
×
Q
A
{\displaystyle C=u_{1}\times G+u_{2}\times Q_{A}}
From the definition of the public key as
Q
A
=
d
A
×
G
{\displaystyle Q_{A}=d_{A}\times G}
,
C
=
u
1
×
G
+
u
2
d
A
×
G
{\displaystyle C=u_{1}\times G+u_{2}d_{A}\times G}
Because elliptic curve scalar multiplication distributes over addition,
C
=
(
u
1
+
u
2
d
A
)
×
G
{\displaystyle C=(u_{1}+u_{2}d_{A})\times G}
Expanding the definition of
u
1
{\displaystyle u_{1}}
and
u
2
{\displaystyle u_{2}}
from verification step 4,
C
=
(
z
s
−
1
+
r
d
A
s
−
1
)
×
G
{\displaystyle C=(zs^{-1}+rd_{A}s^{-1})\times G}
Collecting the common term
s
−
1
{\displaystyle s^{-1}}
,
C
=
(
z
+
r
d
A
)
s
−
1
×
G
{\displaystyle C=(z+rd_{A})s^{-1}\times G}
Expanding the definition of s from signature step 6,
C
=
(
z
+
r
d
A
)
(
z
+
r
d
A
)
−
1
(
k
−
1
)
−
1
×
G
{\displaystyle C=(z+rd_{A})(z+rd_{A})^{-1}(k^{-1})^{-1}\times 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
{\displaystyle C=k\times G}
From the definition of r, 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 m and Alice's signature
r
,
s
{\displaystyle r,s}
on that message, Bob can (potentially) recover Alice's public key:
Verify that r and s are integers in
[
1
,
n
−
1
]
{\displaystyle [1,n-1]}
. If not, the signature is invalid.
Calculate a curve point
R
=
(
x
1
,
y
1
)
{\displaystyle R=(x_{1},y_{1})}
where
x
1
{\displaystyle x_{1}}
is one of
r
{\displaystyle r}
,
r
+
n
{\displaystyle r+n}
,
r
+
2
n
{\displaystyle r+2n}
, etc. (provided
x
1
{\displaystyle x_{1}}
is not too large for the field of the curve) and
y
1
{\displaystyle y_{1}}
is a value such that the curve equation is satisfied. Note that there may be several curve points satisfying these conditions, and each different R value results in a distinct recovered key.
Calculate
e
=
HASH
(
m
)
{\displaystyle e={\textrm {HASH}}(m)}
, where HASH is the same function used in the signature generation.
Let z be the
L
n
{\displaystyle L_{n}}
leftmost bits of e.
Calculate
u
1
=
−
z
r
−
1
mod
n
{\displaystyle u_{1}=-zr^{-1}\,{\bmod {\,}}n}
and
u
2
=
s
r
−
1
mod
n
{\displaystyle u_{2}=sr^{-1}\,{\bmod {\,}}n}
.
Calculate the curve point
Q
A
=
(
x
A
,
y
A
)
=
u
1
×
G
+
u
2
×
R
{\displaystyle Q_{A}=(x_{A},y_{A})=u_{1}\times G+u_{2}\times R}
.
The signature is valid if
Q
A
{\displaystyle Q_{A}}
, matches Alice's public key.
The signature is invalid if all the possible R 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
Q
A
{\displaystyle Q_{A}}
from recovery step 6,
Q
A
=
(
x
A
,
y
A
)
=
u
1
×
G
+
u
2
×
R
{\displaystyle Q_{A}=(x_{A},y_{A})=u_{1}\times G+u_{2}\times R}
From the definition
R
=
(
x
1
,
y
1
)
=
k
×
G
{\displaystyle R=(x_{1},y_{1})=k\times G}
from signing step 4,
Q
A
=
u
1
×
G
+
u
2
k
×
G
{\displaystyle Q_{A}=u_{1}\times G+u_{2}k\times G}
Because elliptic curve scalar multiplication distributes over addition,
Q
A
=
(
u
1
+
u
2
k
)
×
G
{\displaystyle Q_{A}=(u_{1}+u_{2}k)\times G}
Expanding the definition of
u
1
{\displaystyle u_{1}}
and
u
2
{\displaystyle u_{2}}
from recovery step 5,
Q
A
=
(
−
z
r
−
1
+
s
k
r
−
1
)
×
G
{\displaystyle Q_{A}=(-zr^{-1}+skr^{-1})\times G}
Expanding the definition of s from signature step 6,
Q
A
=
(
−
z
r
−
1
+
k
−
1
(
z
+
r
d
A
)
k
r
−
1
)
×
G
{\displaystyle Q_{A}=(-zr^{-1}+k^{-1}(z+rd_{A})kr^{-1})\times G}
Since the product of an element's inverse and the element is the identity, we are left with
Q
A
=
(
−
z
r
−
1
+
(
z
r
−
1
+
d
A
)
)
×
G
{\displaystyle Q_{A}=(-zr^{-1}+(zr^{-1}+d_{A}))\times G}
The first and second terms cancel each other out,
Q
A
=
d
A
×
G
{\displaystyle Q_{A}=d_{A}\times G}
From the definition of
Q
A
=
d
A
×
G
{\displaystyle Q_{A}=d_{A}\times 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
=
(
x
1
,
y
1
)
{\displaystyle R=(x_{1},y_{1})}
from signature value r.
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
{\displaystyle k}
was static instead of random. As pointed out in the Signature generation algorithm section above, this makes
d
A
{\displaystyle d_{A}}
solvable, rendering 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
{\displaystyle 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.
This issue can be prevented by deterministic generation of k, as described by RFC 6979.
= Concerns
=Some concerns expressed about ECDSA:
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 have expressed doubts about how the NIST curves were designed, and voluntary tainting has already been proved in the past. (See also the libssh curve25519 introduction.) Nevertheless, a proof that the named NIST curves exploit a rare weakness is missing yet.
Technical concerns: the difficulty of properly implementing the standard, its slowness, and design flaws which reduce security in insufficiently defensive implementations.
Implementations
Below is a list of cryptographic libraries that provide support for ECDSA:
Botan
Bouncy Castle
cryptlib
Crypto++
Crypto API (Linux)
GnuTLS
libgcrypt
LibreSSL
mbed TLS
Microsoft CryptoAPI
OpenSSL
wolfCrypt
See also
EdDSA
RSA (cryptosystem)
References
Further reading
Accredited Standards Committee X9, ASC X9 Issues New Standard for Public Key Cryptography/ECDSA, Oct. 6, 2020. Source
Accredited Standards Committee X9, American National Standard X9.62-2005, Public Key Cryptography for the Financial Services Industry, The Elliptic Curve Digital Signature Algorithm (ECDSA), November 16, 2005.
Certicom Research, Standards for efficient cryptography, SEC 1: Elliptic Curve Cryptography, Version 2.0, May 21, 2009.
López, J. and Dahab, R. An Overview of Elliptic Curve Cryptography, Technical Report IC-00-10, State University of Campinas, 2000.
Daniel J. Bernstein, Pippenger's exponentiation algorithm, 2002.
Daniel R. L. Brown, Generic Groups, Collision Resistance, and ECDSA, Designs, Codes and Cryptography, 35, 119–152, 2005. ePrint version
Ian F. Blake, Gadiel Seroussi, and Nigel Smart, editors, Advances in Elliptic Curve Cryptography, London Mathematical Society Lecture Note Series 317, Cambridge University Press, 2005.
Hankerson, D.; Vanstone, S.; Menezes, A. (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer. doi:10.1007/b97644. ISBN 0-387-95273-X. S2CID 720546.
External links
Digital Signature Standard; includes info on ECDSA
The Elliptic Curve Digital Signature Algorithm (ECDSA); provides an in-depth guide on ECDSA. Wayback link
Kata Kunci Pencarian:
- Elliptic Curve Digital Signature Algorithm
- Elliptic-curve cryptography
- Digital Signature Algorithm
- BLS digital signature
- Elliptic curve
- Commercial National Security Algorithm Suite
- Digital Signature Standard
- EdDSA
- NSA Suite B Cryptography
- ElGamal signature scheme