Introduction to Cryptography: The Proposal Story
Learn about cryptography and how it works with an analogy of a proposal story.
Sarim-Katrina ring exchange
This is a story of two friends, Sarim and Katrina. Sarim lives near the river, and Katrina lives across the river. They send messages to each other by placing them inside a box and sending it across the river. Sarim loves Katrina and wants to propose to her by sending her the ring across the river. However, there is a problem. The pirates have attacked and are capturing all the boxes are unlocked. If a box is locked, they let it go.
Sarim and Katrina have boxes and locks. Now, we need to come up with a plan through which Sarim can give the ring to Katrina.
Note: Sarim and Katrina both have their own locks along with their keys.
If Sarim places the ring inside the box, locks it, and sends it to Katrina, he has eventually saved the ring from the pirates and Katrina collects the box. But, is the problem solved here?
No. Katrina got the locked box containing the ring, not the key. Therefore our problem remains unsolved.
What if she locks the same box again (double lock) and sends that back to him? Sarim can unlock his own lock and again send the box back to her. Now, the box has only one lock and Katrina has its key and can easily unlock it.
The problem is now solved.
This story illustrates the concepts of cryptography, which is a crucial field of computer science.
Cryptograph
In a web-based online world, all messages or information we share over the internet are encrypted in some form, so that if anyone tries to hack them, they cannot be understood. Only we, the receiver of the messages, should be able to understand what they mean. Once these messages pass through the internet network (which is like a river), they reach their destination servers (just like the two ends of the river). Pirates are access points where anyone can connect (the internet providers with privileges) and can hook the network packets passing through their connections. All encryption versions of messages work in a similar fashion as in the above example about mailing a box.
For example, a very powerful encryption method called Encryption Protocol is used the giants of social world enterprise businesses, such as Facebook, Google, and so on. Encryption protocol (in the bigger picture) works in the following similar fashion.
- To establish secure communication with the end-user U, the server S creates and distributes a lock, , which is similar to the padlocks used in the story between Sarim and Katrina. However, in this case, the end-user U already has the lock of the recipient, (the lock of Katrina), and can use it to lock the message before sending it to the server S. The lock, , created by the server S is available to everyone, including the end-user U, and is used to secure the message during transmission between the two parties.
- The key, , of the lock, , is only there with the server S, which is hidden.
- In cryptography, is known as the public key and is called the private key of server S.
- The end-user U (in the above case, Sarim) uses to encrypt (Sarim’s ring) and make (ring in the box locked with , as is available to him) using some mathematical operations (multiplications and divisions like arithmetic operations) which is quite easy to compute if you know and and send it over the internet. When the encrypted message reaches the server S (when the locked box containing the ring reaches Katrina), to decrypt from , there is only one practical way to figure out what is M and that is by using (Katrina’s own key).
- It is possible to decrypt without using the private key, , but the only way to do so is by trying all possible combinations of the key. This would be extremely impractical, as the number of possible combinations is exponential and would take, even for a supercomputer, millions of years to crack.
Exercise 1
A farmer wants to take a goat, a lion, and a bundle of grass across a river. The boat is small, so he can only carry one of them at a time. If he leaves the goat and grass alone together, the goat will eat the grass. If he leaves the lion and goat alone together, the lion will eat the goat. How can he bring all three safely across the river?
Exercise 2
We must carry four numbers , , , and in a boat across a river. We can’t take more than two numbers, and the cost of traveling is equal to the larger of these two numbers. Once we’ve crossed the river, one number must be in our boat during the return trip, which defines the cost of this trip. What is the minimum price to carry all four digits from one river bank to the other?
Directions to look at the exercise
If we take and to cross the river first, then this one side trip will cost us , and we can come back with . Hence, this complete trip will cost us . Further, we can take along with to cross the river and bring back with the current total cost of . Then, we can take and . This way, our total cost will be .
But can we come up with an even better solution?
Exercise 3
Consider a scenario where we have two cubes (cube A and cube B). We can arrange them so that the front faces show the current day of the month. How can we use numbers on the front faces of the cubes so that they show the current date?
Note: We can’t represent day with a single cube with a side that says on it and the other cube hidden. We have to use both cubes all the time. So the day should be represented as .