Public-key cryptography: try it yourself
Exercises on modular exponentiation, one-wayness and verifying a signature, with solutions.
Exercise 1: the easy direction
Compute 3^4 mod 7 and 5^3 mod 13.
Exercise 2: the hard direction
Find x such that 3^x mod 7 = 6, with x between 1 and 6. How many attempts did you need?
Exercise 3: verify a signature
With the example public key (n = 3233, e = 17), check whether 588 is a valid signature for the message 65 by computing 588^17 mod 3233 with a computer or a suitable calculator.
Exercise 4: the trust problem
Anna finds Bruno’s public key on a website. List three ways she could make sure it really is Bruno’s.
Public-key cryptography: frequently asked questions
Short answers to the most common doubts about public-key cryptography.
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: worked example
A digital signature with small numbers, using the example RSA keys, to see how private and public keys work together.
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.
Public-key cryptography today
Where public-key cryptography is used every day: HTTPS, digital signatures, messaging, passkeys, cryptocurrencies, software updates.