Ed25519 Signatures
When OpenSSH, Tor, OpenBSD's signify, minisign, Git commit signing with SSH keys and many newer protocols needed a signature scheme they could trust without a manual of caveats, they chose Ed25519. It answers the ECDSA problems of the last lesson by design: no per-signature randomness to get wrong, no special cases, fast constant-time implementations, and 64-byte signatures with 32-byte keys.
What Ed25519 is
Ed25519 (Bernstein, Duif, Lange, Schwabe, Yang, 2011) is the EdDSA signature scheme on the twisted Edwards curve edwards25519, birationally equivalent to Curve25519. It is specified in RFC 8032 and was added to NIST's FIPS 186-5 in 2023, so it is now also approved for US federal use.
Key generation, signing and verification, in outline (with the base point, the group order, = SHA-512):
private key: 32 random bytes seed
h = SHA-512(seed); a = clamp(h[0:32]); prefix = h[32:64]; A = a*B (public key, 32 bytes)
sign(m):
r = SHA-512(prefix || m) mod L <- the nonce: deterministic, secret, unique per message
R = r*B
S = (r + SHA-512(R || A || m) * a) mod L
signature = R || S (64 bytes)
verify(A, m, R || S): check S*B == R + SHA-512(R || A || m) * AThe decisive difference from ECDSA is the nonce : it is derived from a secret prefix (part of the private key's hash) and the message. The same message gives the same signature; different messages give unrelated nonces; and no random number generator is involved at signing time, so a broken RNG on a device cannot leak the key the way it did for PS3 and the Android Bitcoin wallets.
On the RFC test vector
The example loads the private key of RFC 8032 section 7.1, test 1 (a published key: never use it for anything real), and checks the public key and the signature of the empty message against the RFC.
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.exceptions import InvalidSignature
# RFC 8032 section 7.1, test 1: a published test key. Never use a published key for anything real.
seed = bytes.fromhex("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60")
sk = Ed25519PrivateKey.from_private_bytes(seed)
pk = sk.public_key()
print("public key:", pk.public_bytes_raw().hex())
sig = sk.sign(b"")
print("signature of the empty message:", sig.hex()[:32] + "...", len(sig), "bytes")
print("matches RFC 8032:", sig.hex().startswith("e5564300c360ac729086e2cc806e828a"))
print("deterministic:", sk.sign(b"") == sig)
m = b"deploy build 7f3a to prod"
s = sk.sign(m)
pk.verify(s, m); print("verify: OK")
for bad in (m.replace(b"prod", b"dev "), ):
try: pk.verify(s, bad)
except InvalidSignature: print("verify changed message: InvalidSignature")public key: d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a
signature of the empty message: e5564300c360ac729086e2cc806e828a... 64 bytes
matches RFC 8032: True
deterministic: True
verify: OK
verify changed message: InvalidSignature
Because Ed25519 is deterministic, its output can be checked byte for byte against the RFC, which is not possible for randomised ECDSA. Real keys come from Ed25519PrivateKey.generate() (or ssh-keygen -t ed25519).
Ed25519 compared
| RSA-3072 PSS | ECDSA P-256 | Ed25519 | |
|---|---|---|---|
| security level | 128 bits | 128 bits | about 128 bits |
| public key / signature | 384 / 384 bytes | 64 (33 compressed) / 64–72 bytes | 32 / 64 bytes |
| nonce at signing | random salt (not critical) | random or RFC 6979, critical | deterministic by design |
| constant time | depends on implementation | depends on implementation | designed for it |
| typical use | legacy and broad compatibility | WebAuthn defaults, many HSMs, government PKI | SSH keys, Tor, signify, minisign, Git SSH signing |
Ed25519's limits: certificate authorities and many HSMs still issue mostly RSA and ECDSA, so public TLS certificates with Ed25519 keys are rare. Ed448 (also RFC 8032) gives about 224-bit security when a higher level is required.
What can still go wrong
- Fault attacks on deterministic signatures: if a glitch corrupts a computation while signing the same message twice, the two outputs can leak the key. Hardware tokens add countermeasures or "hedged" randomness.
- Mismatched public keys: some early libraries had a signing API that took the public key as a separate argument without checking that it belonged to the private key. Signing the same message with two different "public keys" leaks the private key (a 2022 survey found dozens of affected libraries). Use APIs that derive the public key themselves, as
cryptographydoes. - Verification differences: libraries disagreed for years on edge cases (non-canonical encodings, small-order points), which matters in consensus systems; "ZIP 215" and RFC 8032's strict checks are the references.
- Key handling: an Ed25519 key is still a private key that must be protected, rotated and revoked like any other.
How weak signature setups are detected
- Inventory:
ssh-keygen -lf ~/.ssh/authorized_keysshows key types and sizes (ED25519,RSA 1024…); code-signing and artefact-signing configurations; JWTalgvalues (EdDSA,ES256,RS256, and the dangerousnone). - Library review: signing functions that take the public key as an input; home-made EdDSA.
- Weak legacy keys: DSA (
ssh-dss, disabled by default since OpenSSH 7.0), RSA under 2,048 bits,ssh-rsasignatures with SHA-1 (disabled by default in OpenSSH 8.8).
How it is fixed
- Use Ed25519 for new SSH keys, artefact signing and internal protocols where both ends are under your control.
- Use a library API where signing takes only the private key.
- Keep ECDSA or RSA where standards require them (public TLS certificates, some regulated environments), with RFC 6979 or hedged nonces for ECDSA.
Pitfalls
- Using an Ed25519 signing key for X25519 key exchange: they are related curves, but key reuse across protocols is not supported; generate separate keys.
- Expecting Ed25519 signatures to hide the message: signatures provide authenticity, not confidentiality.
- Confusing Ed25519 (signatures) with X25519 (key exchange, next lessons).
Practice
1. Why is it safe for Ed25519 to produce the same signature when the same message is signed twice, while ECDSA must never reuse a nonce?
Reusing a nonce is only dangerous for two different messages. Ed25519's nonce depends on the message, so equal messages give equal nonces (and equal signatures, which reveal nothing new), and different messages give different nonces.
2. An audit finds ssh-dss and ssh-rsa 1024 keys in authorized_keys on a jump host. What do you recommend?
Remove them; issue Ed25519 keys (ssh-keygen -t ed25519), ideally on hardware tokens (-t ed25519-sk), and configure the server to accept only modern algorithms (PubkeyAcceptedAlgorithms).
3. In the example, add one byte to m and verify the old signature. What happens?
InvalidSignature: the signature binds the exact message bytes through the hash .
Test yourself
How does Ed25519 avoid ECDSA's nonce-reuse failure?
- It uses no nonce
- Its nonce is derived deterministically from a secret part of the key and the message
- It uses RSA internally
- It signs only once
How long is an Ed25519 signature?
- 32 bytes
- 64 bytes
- 256 bytes
- 384 bytes
Which RFC specifies Ed25519?
- RFC 7748
- RFC 8032
- RFC 8446
- RFC 5280
Why can the example compare its signature byte for byte with the RFC?
- The library caches it
- Ed25519 is deterministic: the same key and message always give the same signature
- The RFC uses a weak key
- The message is empty