Public-key cryptography: worked example
A digital signature with small numbers, using the example RSA keys, to see how private and public keys work together.
Let us use the toy RSA keys from the RSA page: public key (n = 3233, e = 17), private key (d = 2753).
Signing
Anna wants to sign the message represented by the number 65. She uses her private key:
signature = 65^2753 mod 3233 = 588Verifying
Bruno receives the message 65 and the signature 588. He uses Anna’s public key:
588^17 mod 3233 = 65 → matches the message: valid signatureIf someone changed the message to 66 while keeping the signature 588, verification would still give 65, different from 66: the forgery would be detected. And without the private key nobody can compute the correct signature for 66.
Public-key cryptography: weaknesses and attacks
The man-in-the-middle attack, weak keys, side channels and the quantum threat: where public-key cryptography can fail.
The pages of this topic
Back to the overviewPublic-key cryptography: how it works
The open padlock as a metaphor, encryption with the public key, signing with the private key and hybrid cryptography.
Public-key cryptography: history
From the secret insights of Britain’s GCHQ to Diffie and Hellman’s paper, from RSA to elliptic curves and certificate infrastructures.
Public-key cryptography: the maths
Trapdoor one-way functions: multiplication and factoring, modular exponentiation and the discrete logarithm.
Public-key cryptography today
Where public-key cryptography is used every day: HTTPS, digital signatures, messaging, passkeys, cryptocurrencies, software updates.
Public-key cryptography: try it yourself
Exercises on modular exponentiation, one-wayness and verifying a signature, with solutions.
Public-key cryptography: frequently asked questions
Short answers to the most common doubts about public-key cryptography.