ALICESIGNPRIVATEINTERNETVERIFYBOBPUBLIC1priv = Ed25519PrivateKey.generate()2pub = priv.public_key()3msg = b"Pay Bob 10"4sig = priv.sign(msg)5pub.verify(sig, msg)6pub.verify(sig, b"Pay Bob 99")msg—sig—verify()—Pay Bob 10Pay Bob 99
Back row: Alice, Sign, the internet, Verify, Bob; middle: the private and public keysFront: the Python program and its three values (msg, sig, verify())Tokens: the message, a changed copy, the signature, the private key, a public-key copyAt the back, the way a signed message travels: Alice, the Sign machine, the internet, the Verify machine and Bob. Alice's private key stays in front of her; Bob holds a copy of her public key. Alice signs "Pay Bob 10" with Ed25519 and Bob's check passes; a copy changed to "Pay Bob 99" fails, because a new signature would need her private key. Ed25519 does not sign one hash of the message. RFC 8032 hashes the message twice with SHA-512, mixed with key material, inside the signing maths; the figure draws this as one "hash, then sign" box.

The problem and the keys

  1. Alice sends Bob "Pay Bob 10" over the internet. Bob cannot see who sent it, or whether someone changed it on the way. A digital signature lets him check both: who signed it (authenticity) and that it is unchanged (integrity).

Sign and verify

What it proves

What happens

;; step 1/10 · problem
message      "Pay Bob 10", sent in the open
question 1   did Alice really send it?   (authenticity)
question 2   is it exactly what she sent? (integrity)
tool         a digital signature answers both

Ed25519 does not sign one hash of the message. RFC 8032 hashes the message twice with SHA-512, mixed with key material, inside the signing maths; the figure draws this as one "hash, then sign" box. The figure uses RFC 8032's published test key so its numbers are reproducible. It is public: never use a test key for anything real; generate your own as in line 1.