Public key

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Public key

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Who is allowed to have a copy of your public key?
A Only you, because it must be kept secret
B Anyone, because it is shared openly
2. What is a public key used for?
A Encrypting data sent to its owner
B Decrypting data sent to its owner
3. Can a public key decrypt data that it encrypted?
A No, only the matching private key can decrypt it
B Yes, the same public key can decrypt it
4. Which is a safe way to share a public key?
A Publish it on a website
B Keep it hidden in a locked file
5. An interceptor copies your public key as it is sent over the network. What is the result?
A Big problem, they can now read your messages
B No problem, it cannot decrypt messages sent to you

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1public key Apublish(publicKey, website)
2encrypt(message, publicKey) Bsend(publicKey, network)
3A public key can be published openly, for example on a website, because it cannot decrypt data CThe half of a key pair that the owner shares openly so anyone can use it to encrypt data sent to them
4A public key can be sent over the network to anyone who wants to send the owner a secure message DA public key is meant to be shared openly. Only the private key must be kept secret.
5decrypt(ciphertext, publicKey) ELocks a message using the recipient's shared key so that only the recipient's private key can unlock it
6keep(publicKey, secret) FA public key cannot decrypt data. Decryption needs the matching private key.

Definitions

public key

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
ciphertext ← ENCRYPT(message, _________)
2.
_______(publicKey, website)
3.
message ← DECRYPT(ciphertext, __________)
4.
publicKey ← keyPair.______
5.
IF key = publicKey THEN canDecrypt ← _____ ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A msg ← "Meet at 5"
B pub ← getPrivateKey("Bob")
C cipher ← encrypt(msg, pub)
D send(cipher, "Bob")
Question 2
A pub ← getPublicKey("Amy")
B msg ← "Hello Amy"
C cipher ← encrypt(msg, pub)
D send(msg, "Amy")
Question 3
A keys ← makeKeyPair()
B publish(keys.private, website)
C keep(keys.private)
Question 4
A cipher ← encrypt(msg, pub)
B send(cipher, "Sam")
C plain ← decrypt(cipher, pub)
D output plain
Question 5
A IF key = "private" THEN
B share(key)
C ELSE
D keepSecret(key)
E ENDIF

Answer Key

Public key
Section A: Quick Questions
Q1
B — Anyone, because it is shared openly
Q2
A — Encrypting data sent to its owner
Q3
A — No, only the matching private key can decrypt it
Q4
A — Publish it on a website
Q5
B — No problem, it cannot decrypt messages sent to you
Section B: Match the Pairs
Q1
public key → The half of a key pair that the owner shares openly so anyone can use it to encrypt data sent to them
Q2
encrypt(message, publicKey) → Locks a message using the recipient's shared key so that only the recipient's private key can unlock it
Q3
A public key can be published openly, for example on a website, because it cannot decrypt data → publish(publicKey, website)
Q4
A public key can be sent over the network to anyone who wants to send the owner a secure message → send(publicKey, network)
Q5
decrypt(ciphertext, publicKey) → A public key cannot decrypt data. Decryption needs the matching private key.
Q6
keep(publicKey, secret) → A public key is meant to be shared openly. Only the private key must be kept secret.
Section C: Definitions
Q1
public key — The half of a key pair that the owner shares openly. Anyone can use it to encrypt data sent to the owner, but it cannot decrypt that data. Only the matching private key can.
Section D: Fill in the Blanks
Q1
ciphertext ← ENCRYPT(message, publicKey)
Q2
PUBLISH(publicKey, website)
Q3
message ← DECRYPT(ciphertext, privateKey)
Q4
publicKey ← keyPair.public
Q5
IF key = publicKey THEN canDecrypt ← FALSE ENDIF
Section E: Spot the Error
Q1
B — The sender must use Bob's public key, which he shares openly. A private key is never shared. It should be getPublicKey("Bob").
Q2
D — The message was encrypted with Amy's public key, but this line sends the plaintext, so an interceptor could read it. It should send the ciphertext: send(cipher, "Amy").
Q3
B — Only the public key is published on a website. Publishing the private key would let anyone decrypt the owner's messages. It should be publish(keys.public, website).
Q4
C — A public key can encrypt but cannot decrypt. Sam must use his matching private key. It should be decrypt(cipher, priv).
Q5
A — The key that is shared openly is the public key, not the private key. The condition should be IF key = "public" THEN.