Encrypting with the recipient's public key

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

Encrypting with the recipient's public key

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Amir wants to send Bella a secure message using asymmetric encryption. Which key does Amir use to encrypt the plaintext?
A Amir's own public key
B Bella's public key
2. True or false: the sender encrypts the plaintext with their own private key so that only the receiver can read it.
A True: the sender uses their own private key
B False: the sender uses the receiver's public key
3. After Amir encrypts a message with Bella's public key, who can decrypt it?
A Only Bella, using her private key
B Amir, using Bella's public key
4. Is it safe for Amir to send the ciphertext across the internet where anyone could intercept it?
A Yes: an interceptor cannot read it without the private key
B No: it must be sent secretly or it can be decrypted
5. Which step happens first when Amir sends Bella a secure message?
A Amir gets Bella's public key
B Amir gets Bella's private key

Match the Pairs

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

Left columnRight column
1encrypt(message, bobPublicKey) Adecrypt(ciphertext, receiverPrivateKey)
2ciphertext = encrypt(plaintext, receiverPublicKey) BThe sender locks the plaintext using the receiver's public key, so only the receiver can unlock it.
3The sender must use the receiver's public key, not their own key, to encrypt the message. CA private key must never be used by the sender. The sender should use the receiver's public key, which is safe to share.
4After encrypting with the receiver's public key, the sender cannot decrypt the ciphertext. Only the receiver's private key can. Dencrypt(message, receiverPublicKey)
5encrypt(message, mySenderPublicKey) EThe sender used their own public key. The message must be encrypted with the receiver's public key so only the receiver can decrypt it.
6encrypt(message, receiverPrivateKey) FThe result is ciphertext that is safe to send openly over a network.

Definitions

encrypt with recipient's public key

Fill in the Blanks

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

1.
// Alice sends a secure message to Bob cipher ← encrypt(message, _________)
2.
// Alice sends a secure message to Bob cipher ← _______(message, bobPublic)
3.
// Alice encrypts for Bob cipher ← encrypt(message, bob._________)
4.
// Alice cannot decrypt cipher afterwards plain ← decrypt(cipher, __________)
5.
cipher ← encrypt(message, bobPublic) send(______, bob)

Spot the Error

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

Question 1
A msg ← 'Meet at 5pm'
B key ← receiver.publicKey
C cipher ← decrypt(msg, key)
D send(cipher)
Question 2
A key ← sender.publicKey
B cipher ← encrypt(text, key)
C send(cipher)
Question 3
A key ← bob.privateKey
B text ← 'Pay 50 now'
C cipher ← encrypt(text, key)
D send(cipher)
Question 4
A key ← receiver.publicKey
B cipher ← encrypt(msg, key)
C send(msg)
Question 5
A msg ← 'Meet at 5pm'
B key ← receiver.publicKey
C cipher ← encrypt(msg, key)
D send(cipher, me.privateKey)

Answer Key

Encrypting with the recipient's public key
Section A: Quick Questions
Q1
B — Bella's public key
Q2
B — False: the sender uses the receiver's public key
Q3
A — Only Bella, using her private key
Q4
A — Yes: an interceptor cannot read it without the private key
Q5
A — Amir gets Bella's public key
Section B: Match the Pairs
Q1
encrypt(message, bobPublicKey) → The sender locks the plaintext using the receiver's public key, so only the receiver can unlock it.
Q2
ciphertext = encrypt(plaintext, receiverPublicKey) → The result is ciphertext that is safe to send openly over a network.
Q3
The sender must use the receiver's public key, not their own key, to encrypt the message. → encrypt(message, receiverPublicKey)
Q4
After encrypting with the receiver's public key, the sender cannot decrypt the ciphertext. Only the receiver's private key can. → decrypt(ciphertext, receiverPrivateKey)
Q5
encrypt(message, mySenderPublicKey) → The sender used their own public key. The message must be encrypted with the receiver's public key so only the receiver can decrypt it.
Q6
encrypt(message, receiverPrivateKey) → A private key must never be used by the sender. The sender should use the receiver's public key, which is safe to share.
Section C: Definitions
Q1
encrypt with recipient's public key — To send a secure message, the sender encrypts the plaintext using the receiver's public key, not their own. Only the receiver's private key can decrypt the ciphertext.
Section D: Fill in the Blanks
Q1
// Alice sends a secure message to Bob cipher ← encrypt(message, bobPublic)
Q2
// Alice sends a secure message to Bob cipher ← encrypt(message, bobPublic)
Q3
// Alice encrypts for Bob cipher ← encrypt(message, bob.publicKey)
Q4
// Alice cannot decrypt cipher afterwards plain ← decrypt(cipher, bobPrivate)
Q5
cipher ← encrypt(message, bobPublic) send(cipher, bob)
Section E: Spot the Error
Q1
C — The sender must encrypt the plaintext, not decrypt it. Line 3 should be cipher ← encrypt(msg, key).
Q2
A — The sender must use the receiver's public key, not their own. If they used their own key, the receiver could not decrypt it. It should be key ← receiver.publicKey.
Q3
A — Messages are encrypted with the receiver's PUBLIC key. A private key is kept secret and is used for decrypting. It should be key ← bob.publicKey.
Q4
C — This sends the plaintext, so an interceptor could read it. Only the ciphertext should be sent. It should be send(cipher).
Q5
D — The sender's private key must never be sent. The ciphertext alone is safe to send openly, so line 4 should be send(cipher).