Lesson 2-18 AP Computer Science Principles Asymmetric Keys Lesson 2-18 AP Computer Science Principles
Objectives Students will be able to: Explain the difference between symmetric and asymmetric encryption. Model public key cryptography using cups and beans. Connect real terminology of public key cryptography to the cups and beans activity. Explain the benefits of public key cryptography over encryption that uses a symmetric key.
Ciphers and Keys Think back to the Caesar cipher, random substitution cipher, and Vigenère cipher we saw in previous lessons. Each of these ciphers had something called a “key” that was used to encrypt and decrypt secret messages. An eavesdropper who intercepted the message and didn’t have the key had to do a lot of work to crack the message or just guess what the key was.
Question Is there a way to send an encrypted message over an insecure channel without establishing a key ahead of time in private?
Let’s do a thought experiment… Imagine that Bob wants to send Alice a message using the Vigenère cipher. Alice and Bob haven’t met ahead of time or established any kind of shared secret. Now imagine that Alice and Bob are far apart and have to rely on Eve, the eavesdropper, to deliver their messages to each other. Assume that Eve won’t alter the messages when she delivers them, but she will try to spy. Can you figure out a way for Bob to send Alice an encrypted message that only Alice can read?
Activity The problem of how to send encrypted messages without establishing keys in private ahead of time baffled cryptographers and computer scientists for years, but there is a way to do it! In today’s activity, we will act out a way to send secret messages that does NOT rely on a shared secret key.
Public Key Cryptography This method is called public key cryptography because the “key” needed to encrypt something is actually public, and can be used by anyone! But that key cannot be used to decrypt. It also relies on the existence of one- way functions that work similarly to the one we studied in the last lesson.
Activity For today’s activity, we’re not going to encrypt and decrypt data. Instead we’ll be using physical objects to represent data, one-way functions, encryption, and decryption.
Activity Have you ever been to a carnival or fair where there’s a big glass jar of jelly beans and you’re supposed to guess how much candy is in the jar? Today this will be our metaphor for a one-way function
Activity Imagine that a person can count out some number of candies, dump them in a glass jar, close the lid and put a lock on it. Only that person knows how many candies there are in the jar, and only that person can open the jar. For anyone else, even though they can see the all the candy right there in the jar, it’s almost impossible to accurately count how many candies there are. If you do manage to figure it out, it’s probably just dumb luck! So for today, we’ll say that guessing the number of candies in the jar is a computationally hard problem to solve.
Activity Guide Follow the instruction in the Activity Guide - Public Key Bean Countings Try it a few times, switching roles each time.
So What??? This is a big deal: Public key cryptography is what makes secure transactions on the Internet possible. Without it we couldn’t buy things, communicate without being spied on, use banks, or keep our own conduct on the Internet secret or private.
Major Points Major points: Bob was able to encrypt a secret message for Alice without needing to know her key The only “information” exchanged in public, where Eve could see it, was the result of one-way functions that produced data that would be “computationally hard” to crack. Anyone, not just Alice, could make a sealed cup of beans and put it out in public with their name on it, allowing anyone else to encrypt a message just for them! This is asymmetric encryption in a nutshell: one key can only be used to encrypt data, and a different (but related) key can only be used to decrypt.
Video
Public Key Cryptography It’s important to understand how the process of public key cryptography works. The “real” thing uses math instead of cups and beans, but the process is the same. Next time we’ll take a look at how the math works. (Don’t worry; it’s not that hard.)
Official Terms (You should know these) Definition Asymmetric Encryption A method of encrypting that uses two different keys, one for encrypting a message and one for decrypting. Public Key Cryptography The term for the most common form of asymmetric encryption. The encrypting key is made public so anyone can use it. The decrypting key is kept private and never shared. Thus, anyone can encrypt a message for anyone else, but only the holder of the private key can actually read it.
Official Terms (You should know these) Definition Cups and Beans Example Private Key A key used for decrypting a message that is only known to one person, the intended recipient. Alice’s private key is the number of beans she chooses to put in the cup initially. Public Key A key that can be used by anyone to encrypt a message for the intended recipient. It is generated using a one-way function on the private key, so there is a relationship between the public and private keys, but figuring it out is a computationally hard problem. Alice makes her public key by using the “one way function” of sealing the lid on the cup of beans, which makes cracking her private key a “hard problem.”
Official Terms (You should know these) Definition Cups and Beans Example Encrypting (a message) In public key cryptography, you encrypt a message using a one-way function with the intended recipient’s public key. Bob encrypts a message by using Alice’s public cup of beans. Adding beans to the cup is also a one-way function. Bob can put the cup back out in public, knowing that cracking his message is a “hard” problem.
Official Terms (You should know these) Definition Cups and Beans Example Decrypting (a message) In public key cryptography, the recipient gets a message that has been encrypted with her public key. She can use the private key to decrypt the message. It works because of the relationship between the public and private keys. Alice decrypts the message by taking the lid off the cup, dumping out the beans, and taking away the number of beans she “privately” added to the cup. The lid on the cup represents a one-way function that Alice knows the answer to.
Stage 18 Complete Stage 18