← IGCSE Computer Science Paper 1

Encrypting with the 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.

Understanding Encrypting with the recipient's public key in IGCSE Computer Science Paper 1

What it does: The key passed in is the receiver's public key, which matches the rule that the sender encrypts with the recipient's key. A public key cannot undo its own encryption. Only the matching private key, which Bella keeps secret, can decrypt the ciphertext.

Common mistakes: The sender must encrypt the plaintext, not decrypt it. Line 3 should be cipher ← encrypt(msg, key). 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.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 204–217) and word search (Modules 189–217).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Amir wants to send Bella a secure message using asymmetric encryption. Which key does Amir use to encrypt the plaintext?
Amir's own public keyBella's public key
Matches
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.
Applying
Meanings
Term
encrypt with recipient's public key
Meaning
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.
Practice
plaintext ← "Meet at 5pm"
Testing
Gaps
cipher ← encrypt(message, )
Check Answer
Spots
2key ← receiver.publicKey
3cipher ← decrypt(msg, key)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Dumbo Octopus' badge — Module Maker, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

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 ✓
The sender encrypts with the receiver's public key. Only Bella's private key can then decrypt the message.
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 ✓
A private key is never used by the sender to protect a message for someone else. The receiver's public key is used.
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
A public key cannot undo its own encryption. Only the matching private key, which Bella keeps secret, can decrypt the ciphertext.
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
The ciphertext is safe to send openly because it is unreadable without Bella's private key.
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
Public keys can be shared with anyone. Amir uses Bella's public key to encrypt, and her private key stays with her only.

Match the Pairs

encrypt(message, bobPublicKey) → The sender locks the plaintext using the receiver's public key, so only the receiver can unlock it.
ciphertext = encrypt(plaintext, receiverPublicKey) → The result is ciphertext that is safe to send openly over a network.
The sender must use the receiver's public key, not their own key, to encrypt the message. → encrypt(message, receiverPublicKey)
After encrypting with the receiver's public key, the sender cannot decrypt the ciphertext. Only the receiver's private key can. → decrypt(ciphertext, receiverPrivateKey)
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.
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.

Key Term

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.

Fill in the Blanks

1. // Alice sends a secure message to Bob cipher ← encrypt(message, bobPublic)
Hint: Type the key variable that belongs to the receiver, Bob, not the sender.
2. // Alice sends a secure message to Bob cipher ← encrypt(message, bobPublic)
Hint: Type the function name that turns plaintext into ciphertext.
3. // Alice encrypts for Bob cipher ← encrypt(message, bob.publicKey)
Hint: Type the property name for the receiver's key that can be shared openly and is used by the sender to encrypt.
4. // Alice cannot decrypt cipher afterwards plain ← decrypt(cipher, bobPrivate)
Hint: Type the key variable needed to decrypt, which only the receiver holds.
5. cipher ← encrypt(message, bobPublic) send(cipher, bob)
Hint: Type the variable holding the scrambled data that is safe to send over the network.

Spot the Error

Question 1
A msg ← 'Meet at 5pm'
B key ← receiver.publicKey
C cipher ← decrypt(msg, key)
D send(cipher)
Line C — The sender must encrypt the plaintext, not decrypt it. Line 3 should be cipher ← encrypt(msg, key).
Question 2
A key ← sender.publicKey
B cipher ← encrypt(text, key)
C send(cipher)
Line 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.
Question 3
A key ← bob.privateKey
B text ← 'Pay 50 now'
C cipher ← encrypt(text, key)
D send(cipher)
Line 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.
Question 4
A key ← receiver.publicKey
B cipher ← encrypt(msg, key)
C send(msg)
Line C — This sends the plaintext, so an interceptor could read it. Only the ciphertext should be sent. It should be send(cipher).
Question 5
A msg ← 'Meet at 5pm'
B key ← receiver.publicKey
C cipher ← encrypt(msg, key)
D send(cipher, me.privateKey)
Line 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).

Student with a class code? Join your class →