## 10 Jul RSA: The Elegant Code

The quest to share information securely and the curiosity to decipher the hidden meaning, has astounded the human mind since eternity. Whether it was the ancient art of steganography, or the development of ciphers from the Caesar Cipher to the Enigma Cipher Machine, the basic idea has been to protect information from falling into the wrong hands.

This science of cryptography took a very interesting turn during the 1970’s with the development of the concept of asymmetric ciphers by exploiting the one-way functions. This was achieved by a trio of three brilliant cryptographers at Stanford University, namely Whitfield Diffie, Martin Hellman and Ralph Merkle. Together they solved one of the greatest mysteries of sharing messages secretly without having to share the key. For instance, if Alice wants to communicate privately to Bob she must encrypt the message using a key. Now for Bob to be able to decrypt the message he must know the key. This is an example of a symmetric cipher which uses the same key to encode and decode the message. This implied that the key distribution is an inevitable part of decipherment. It could be achieved by personally meeting and sharing the key or delivering it through a reliable source which is not only less secure but also inconvenient.

Another trio of computer scientists at MIT namely Ron Rivest, Adi Shamir and Leonard Aldeman developed a mathematical function in 1977 (called the RSA Code, named after their initials) which was based on the revolutionary concept of asymmetric ciphers (which uses separate keys for encryption and decryption).

The RSA Code, a system of asymmetric cryptography is a form of Public Key cryptography. To understand the mystery of RSA Code, we again take the example of Alice and Bob, who want to share some private information with each other. Alice creates a public key (which is a one way function- that is it is impossible for anyone to reverse it to decode the message). This is available to everyone who wants to send her a message. So Bob encrypts the message using the public keys and sends it to Alice. Now Alice needs to decipher the message sent to her and for this she possess a private key (some extra piece of information) that allows only her to decode any message sent to her since no one else possess the private key for decryption.

Mathematically it goes like this:

- Alice takes two giant prime numbers, and . Let’s take and for simplicity. She multiplies and to get . In practice the numbers and are quite large, so that cannot be easily found out even if computers are employed.
- She now picks up another number (say ) such that is relatively prime to which in this case is . This is an outcome of Euler’s Theorem which states that if we raise to the power Euler’s Totient function of then we end up with modulo . That Is , where is the Euler’s totient function.

- Alice now publishes and which are available to everyone as public keys for encryption.

- Bob wants to send her a message (say ). He uses the encryption formula (one way function) along with the public keys issued by Alice to get the encryption key such that in our example , where is called the Cipher Text, which is what he sends Alice.

- Since modular functions are one way functions hence it is extremely difficult to work out from when larger primes are involved. So even if Eve (any third person or spy) catches hold of when Bob sends it to Alice, she can’t decipher it back to trace .

- But Alice can decipher the message because she knows and . She calculates a special number, her private key according to the formula . In our example which can be easily calculated using the technique of Euclid’s algorithm.

- Once Alice has calculated her private key, she simply uses the decryption formula, . Here in our example after simplification we shall get .

** **

Eureka! Alice is able to recover the original message sent by Bob. Thus this one-way function allows everyone to encrypt messages to a particular person by using the public keys ( and ) but only the intended person can decrypt the message because the recipient is the only person who knows and , and hence the only person who knows the private key .

The fundamental logic involved is the difficulty in factorizing (to get and ). Nowadays, for important transactions is taken to be of the order of atleast which would take all the computers in the world, put together, longer than the age of the universe to factorize .

As long as we do not come up with extremely efficient and faster ways of factorization, the RSA Code is here to stay in all its elegance, simplicity and beauty.

**[This article has been written by Harman Kour, who is at present an intern with Gonit Sora.]**

Download this post as PDF (will not include images and mathematical symbols).

## No Comments