To send a secret to someone you've never met, you can't share a key first: anyone could copy it on the way. Public key encryption works like an open padlock: anyone can lock a message with someone's public key, but only their private key opens it. HTTPS uses it to start every secure connection.
Your browser has never met the online shop's server, yet it sends your card number safely across café Wi-Fi. How do two strangers share a secret in public?
Challenge: the class server· Set up the Pi as a class server with a share, accounts, a firewall and a nightly backup.
Share files with Samba· Samba shares a folder so Windows, Mac and Linux computers can use it.
Hashes protect passwords where they're stored. This lesson is about protecting a secret while it travels, between two people who have never met.
How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Strangers
TryTry it on the board and compare the result with your prediction.
Try: lock it with Alice's padlock
Was your prediction right?
Try it yourselfYour edits are saved in this browser.
Bob locks the box with Alice's padlock and sends it. Who can read it?
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: two keys, two jobs
Worked exampleBefore each step, say what you think comes next.
public key=open padlockAlice gives it to anyone. It can only lock.
Bob locks with Alice’s public keyThe box crosses the café Wi-Fi. Eve copies it.
Eve: box, padlock, no keyShe can't open it. Copying isn't reading.
private key=the only keyIt never leaves Alice. Only she opens the box.
HTTPSYour browser locks a fresh shared key with the site's public key; then both use that shared key for the rest.
Now: who can open it?
Sam sends Alice a secret. Click the line where it first goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: one change at a time
Try it yourselfYour edits are saved in this browser.
Now Bob uses his own padlock. Send it. Who can read it?
Use the board. This ticks when you get there.
Send it with no padlock.
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Which key?
Which tool fits? Sort each one.
A site keeps your password so it can check it next timeIt only ever needs checking, never reading back.
Your card number on its way to an online shopThe shop has to read it, and it crosses networks other people share.
Checking a downloaded app is exactly the file its maker publishedSame file, same hash; one changed byte changes it.
A private message to a friend across the internetYour friend has to read it, so it must be reversible for them.
A news headline anyone can readIt's public: there's nothing to hide or check.
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Explain HTTPS
Then: why does it matter that the padlock is the shop's, and not one Eve handed you? (Ask your teacher about certificates.)
Your browser has never met the shop's server, and you're on café Wi-Fi with Eve. Explain how your card number reaches the shop without Eve reading it. Say which key does what.
Your working
A model solution
The shop's server gives the browser its public key: an open padlock. a public key can be handed out in the open
The browser makes a fresh secret key and locks it with the shop's public key. anyone can lock with a public key
Eve copies the locked secret but can't open it. only the shop's private key opens it, and it never leaves the server
The shop opens it with its private key; now both share the secret key. the private key matches the public one
The card number is encrypted with that shared key on the way. both ends have it, and Eve doesn't
Check your own working
Lesson done. You've finished every step you need.
Now you can
Explain how a public key and a private key work together.
Say which key to lock a secret with.
Explain how a browser and a site that have never met share a secret.
Students send a message past an eavesdropper locked with Alice's public padlock, see why Bob's own padlock and no padlock both fail, then sort hashes from public key encryption and explain how HTTPS starts (AC9TDI10K01 node 4, second half; Hashes and salt is the first). About 40 minutes.
I can explain how a public key and a private key work together.
I can say which key to lock a secret with.
I can explain how a browser and a site that have never met share a secret.
Before class
Try the board yourself. Every name is made up.
The kit's typical width: public key cryptography (as in TLS/HTTPS) secures data in transit; hashing (last lesson) secures stored passwords; they address different threats. Split from Hashes and keys on 25 Oct. Simplifications: the padlock is an analogy; HTTPS uses public keys to agree a shared key, then faster encryption for the rest; certificates (who vouches that a public key really is the shop's) are a stretch question, not taught.
Links: Secret messages' key sharing (agreeing a key in public) is the other half of how HTTPS starts.
Running the lesson
Predict: students who chose "send Bob the key first" haven't met the problem: ask what Eve does with the key.
Try: ask what Eve has. (The box and a padlock.) What is she missing?
Worked example: ask why the key that opens must never travel.
Vary: ask why Bob's own padlock is safe from Eve but useless to Alice.
Make: compare two students' explanations against the criteria before showing the model.
The hard part (on purpose)
The public key only locks, which runs against intuition (a key that doesn't open?). Use the padlock as the anchor all lesson: anyone can snap one shut.
When students get stuck
A student locks with their own padlock (Sam's mistake). Ask: Who has the key to Bob's padlock? Fix: Lock with the receiver's public key.
A student thinks the public key opens the box. Ask: Eve has a padlock too. Can she open the box? Fix: Public keys only lock; the private key opens.
Stretch and support
Stretch: Eve hands you a padlock and says it's the shop's. How would you know? Look up what a certificate is.
Support: A card: public key = open padlock (anyone locks); private key = the only key (only the owner opens). Lock with theirs.
Where it leads
Next: Capture the flag (use everything from this course to find and fix the weaknesses in a school portal).
Links: Secret messages (key sharing, challenge and response).
What each step is for
strangers: Committing to how a stranger can send Alice a secret tests the new move: a key that only locks can be handed out in public.
Try: lock it with Alice's padlock: Locking with Alice's padlock and sending past Eve settles the prediction: Eve copies the box but can't open it; Alice can.
Worked example: two keys, two jobs: Following one message through the public and private key models the new move. Sam locks with his own padlock, the misconception planted after the method.
Vary: one change at a time: Each task changes the lock Bob uses (his own, none), then asks what happens if the private key leaks.
which key?: Choosing the right key, reading the browser's padlock, the hash-or-encryption sort from the last lesson with public keys in it (the hinge), and a review of hashing.
explain HTTPS: Explaining a real connection end to end reverses the process: students start from the browser and the shop and build the chain of keys themselves.