Ed25519 signing and verification, step by step
In one line: Follow the RFC 8032 signing procedure to see why the signature is deterministic and why verification fails on a single changed bit.
An Ed25519 signature is 64 bytes: R in the first 32 and S in the last 32, produced by two different calculations. Following the order explains why verification is so strict.
1. From seed to scalar and prefix
h = SHA-512(seed) // 64 bytes a = clamp(h[0..32]) // scalar prefix = h[32..64] // used for the nonce A = encode([a]B) // 32-byte public key
Clamping clears the low three bits, clears the top bit and sets the second-highest bit. That pins the scalar to a range and removes small-subgroup tricks.
2. Producing R and S
r = SHA-512(prefix ‖ M) mod L R = encode([r]B) k = SHA-512(R ‖ A ‖ M) mod L S = (r + k·a) mod L signature = R ‖ S // 32 + 32 = 64 bytes
The critical detail: the nonce r is a hash of the prefix and message, not a random number. Unlike ECDSA, the same key and message always produce the same signature, and the classic disaster of a broken random generator leaking a private key is structurally impossible.
3. Verification recomputes a point
k' = SHA-512(R ‖ A ‖ M) mod L R' = [S]B - [k']A R' == R ?
The verifier has no private key. It computes R' from the public key, the signature and the message, then compares the re-encoded point with R. If R is not a valid curve point or S is out of range, verification fails before any comparison.
4. Why verification fails
| Cause | Symptom |
|---|---|
| One message bit differs | Failure |
| R or S altered | Failure |
| S ≥ L (out of range) | Failure (canonical check) |
| Different public key | Failure |
| Message decoded differently | Failure even though the text looks the same — check UTF-8, hex, Base64 |
The last row is the common one in practice. Sign "Hello" as UTF-8 and verify it interpreted as hex, and the bytes are entirely different. Failure is not proof of tampering. Match the input format first.
5. Determinism is useful
Same input, same output makes testing easy. RFC 8032 vectors assume it, and comparing a signature character by character is the fastest way to check an implementation. Sign a vector's seed and message in panel ② and compare against the expected value in panel ⑤.
seed 9d61b19d…7f60 message (empty string) signature e5564300…7a100b
6. The tamper test
The tamper button in panel ③ flips one bit in the final signature byte. Verification must fail immediately. If it does not, something is wrong with the input format or the implementation — which is itself a useful signal.
Making a key yourself shows the format differences immediately.
Open Ed25519LabFrequently asked questions
Why is an Ed25519 signature always the same?
The nonce comes from SHA-512(prefix‖M) instead of a random source, so an identical message gives an identical nonce and signature. That is a designed property, not nonce reuse.
What if the signature is not 64 bytes?
Verification fails. 128 hex characters or 86 Base64url characters is the valid length; anything else is a format error.
References
Read next
- Ed25519 and X25519: one curve, two jobsWhat each of the two Curve25519 algorithms does, and why a key made from the same seed is not interchangeable between them.
- One key, five notations: raw, hex, Base64url, JWK, PEMHow a single 32-byte key becomes hex, Base64url, JWK, PKCS#8 PEM and SPKI PEM, and which form belongs where.
- X25519 shared secrets and why HKDF is not optionalHow X25519 produces a 32-byte shared secret, how to check both sides agree, and how HKDF-SHA256 derives purpose-specific keys.