Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Math 152 - Intro to Mathematical Software
2017-03-15
Kiran Kedlaya; University of California, San Diego
adapted from lectures by William Stein, University of Washington
Guest lecturer: Alina Bucur
** Lecture 27: Public key cryptography and number theory, part 2 **
Announcements:
Office hours this week:
Zonglin: Thursday, March 16, 3:30-5:30 in APM 5748.
Kiran: Friday, March 17, 11-12 in APM 7202.
Peter: Friday, March 17, 12-1 and 3-4 in APM 6132.
Homework due Friday, 8pm. Peer grading due Sunday, 8pm.
No final exam!
Please do your course evaluation (CAPE)! Evaluations close Monday, March 20 at 8am.
Last time, we saw how to use the difficulty of the discrete logarithm problem to execute a Diffie-Hellman key exchange.
This time, we will use the difficulty of integer factorization to perform RSA encryption and decryption.
To begin with, one needs two large primes and , preferably of comparable size; one then computes . The values and must be kept private, but the value of will be made public. (Having and be of comparable size is important because otherwise, one can try to use a factorization technique that looks specifically for the smaller prime factor, e.g., trial division.)
Since we know the factorization of as , we can compute the Euler phi function . This must be kept secret!
Let's say we want to have a public key for encryption and a secret key for decryption. We pick a value coprime to and make that public. We then compute the reciprocal of mod , called , and keep that private.
Now suppose someone wants to send us a secure message. The message must first be transformed into an integer (having no common factor with , but this is essentially automatic because has only huge prime factors).
Our correspondent encrypts by computing . In addition to , this uses only the public information of and .
We receive the ciphertext and then decrypt it by computing . This uses the private information of .
Finally, we translate this integer back into a string.
Exercise: decrypt the following ciphertext.
One can also do this in reverse: we can use the secret key to encode a message which anyone can decrypt using the public key. This is an example of authentication: the fact that the message decrypts correctly proves that we must have sent it, because (presumably) no one other than us has access to the secret information needed to compute the secret key!
This demonstration is an oversimplification for several reasons: see https://en.wikipedia.org/wiki/RSA_(cryptosystem).
The security of RSA depends on the practical difficulty of factoring . (In principle, there might exist a method for breaking RSA without directly factoring , but no such techniques are currently known.) See https://members.loria.fr/PZimmermann/records/factor.html for some "factoring records".
As with Diffie-Hellman, the performance of RSA is inferior to that of symmetric encryption systems of comparable security. One thus typically uses RSA to encrypt/decrypt a key to then be used for symmetric encryption/decryption.
In addition to being the most widely used public key cryptographic system on the internet, RSA can also be used in SMART CARDS.
Smart cards have a tiny chip embedded in them that allows the card to communicate with the bank through, say, the ATM.
The bank chooses two large primes and and computes the modulus It programs each card with the RSA encryption with an encryption exponent specific to that card.
The bank needs to compute which it can do since it knows and
Upon receiving the card, the customer chooses a PIN. The bank stores in each customer account the PIN and the decrypting exponent Note that the customer does not know
When the customer inserts the card at an ATM and enters the PIN, the bank retrieves from the customer file, picks a random integer and sends to the card.
The card computes and sends to the bank.
The bank computes and checks that If this holds, it accepts that the card is genuine.
Key point: The ATM only sees and go through and cannot recover which is the crucial piece of information that the card contains.