← Teacher guide

Public and private keys

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).

Security and privacy · How systems are kept safe · about 40 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 6 min · Worked example 10 min · Vary 8 min · Practise 8 min · Make 8 min

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

  1. Predict: students who chose "send Bob the key first" haven't met the problem: ask what Eve does with the key.
  2. Try: ask what Eve has. (The box and a padlock.) What is she missing?
  3. Worked example: ask why the key that opens must never travel.
  4. Vary: ask why Bob's own padlock is safe from Eve but useless to Alice.
  5. Make: compare two students' explanations against the criteria before showing the model.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

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

What you will seeA question to askThe fix
A student locks with their own padlock (Sam's mistake).Who has the key to Bob's padlock?Lock with the receiver's public key.
A student thinks the public key opens the box.Eve has a padlock too. Can she open the box?Public keys only lock; the private key opens.

Answers to the checks

  1. strangers: Bob wants to send Alice a secret. They've never met, and everything they send can be copied by Eve. A shared key, like a shift cipher's, would have to be sent first. What can Alice do?
    Hand out open padlocks. Anyone, Eve included, can have one, because a padlock only locks. The only key that opens it never leaves Alice.
  2. Try: lock it with Alice's padlock: Bob locks the box with Alice's padlock and sends it. Who can read it?

    Eve has the box and even one of Alice's padlocks, but no key: only Alice's private key opens it.
  3. Lock, send, open: Alice has given out hundreds of open padlocks. Who can open a box Bob locks with one?
    Only Alice, with her private key
    The public key only locks. The private key, which never leaves Alice, is the only thing that opens.
  4. Find the mistake: Sam sends Alice a secret. Click the line where it first goes wrong.
    line 3
    Line 3: locked with Sam's own padlock, only Sam's key opens it, and that key is with Sam. Lock with the receiver's public key.
  5. Eve's padlock: Why doesn't it matter that Eve has one of Alice's padlocks?
    A padlock can only lock; she still can't open anything
    That's why the public key can be public. Only the private key has to stay secret.
  6. Bob's own padlock: Now Bob uses his own padlock. Send it. Who can read it?

    Nobody but Bob: Alice can't open it, because only Bob has that key. You lock with the receiver's public key.
  7. No padlock: Send it with no padlock.

    No lock: Eve reads it. That's a website without HTTPS.
  8. A leaked private key: Eve copies Alice's private key from her laptop. What can Eve do now?
    Open every box locked with Alice's padlock
    That includes old boxes Eve copied earlier. Everything rests on the private key staying private. That's why it never leaves the device, and why a leaked one is replaced at once.
  9. Which key?: Which key do you use to send someone a secret?
    Their public key
    Lock with the receiver's public key; only their private key opens it.
  10. The browser's padlock: A browser shows a padlock beside a shop's address. What does it promise?
    What you send is encrypted on the way to that site
    The padlock is about data in transit: nobody on the way can read it. It doesn't vouch for the site.
  11. Hash or encryption?: Which tool fits? Sort each one.
    A site keeps your password so it can check it next time → A hash; Your card number on its way to an online shop → Public key encryption; Checking a downloaded app is exactly the file its maker published → A hash; A private message to a friend across the internet → Public key encryption; A news headline anyone can read → Neither
    Stored and only checked: a hash. Travelling and read again: public key encryption. A hash is not encryption: it can't be undone, even with a key.
  12. explain HTTPS: 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.
    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)
    The public key starts the conversation in the open; the private key is what Eve never gets.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: one change at a time › Bob's own padlock

Open task: any program that does what the step asks.

Vary: one change at a time › No padlock

Open task: any program that does what the step asks.

Vary: one change at a time › A leaked private key

Open task: any program that does what the step asks.

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.

Exit ticket

Which key locks a message for Alice, and why can it be public?

Alice's public key. It can only lock; only her private key, which never leaves her, opens it.

What each step is for

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).