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 480: Open Source Mathematical Software
2016-05-25
William Stein
Lectures 26: Public key cryptography (part 2 of 3): RSA
Plan:
Homework/grading reminder.
Next week -- discussion
Today: explain RSA
Work on homework
WE will not meet next week. There are 9 assignments. You will be completely done with everything related to this class on Friday May 27 at 6pm.
Recall... the Diffie-Hellman key exchange:
A and B agree on .
A and B choose random and send and .
The shared secret is , which both A and B can easily compute, but an eavesdropper (presumably) can't.
DH is simple, beautifully symmetric, and is useful for setting up an active secure channel for temporary communication:
login to a website, ssh to a remote computer, etc.
DH does not solve a lot of interesting problems though. For example:
B publishes some information -- a "public key" -- on their website.
Anybody at any time, and without B having to do anything, can encrypt a message that only B can decrypt.
There is a solution to this problem, which also uses modular arithmetic. It's completely different than Diffie-Hellman!

RSA = Rivest-Shamir-Adleman
(Errata: In the lecture yesterday I said GCHQ secretly also discovered DH, but actually they also discovered RSA.)
How RSA works. There's one basic idea from number theory that you have to know about to understand RSA.
Let be a prime. Fermat's Little Theorem says that for every integer coprime to , we have
Try it out:
Proof: The cardinality of the finite group is and it's a basic result in group theory that the order of any element of a group divides the cardinality of the group.
Similarly for component , we have that if , then since is a group of order .
So A wants to send a secret message to B.... here's how.
Step 1. Setup:
B secretly chooses two large prime numbers and at random and an integer , and publishes and .
B knows and , so B can compute , and also an integer such that . Thus for some .
Step 2. Encryption:
A encodes the message as an integer modulo .
Then A encrypts the message as .
Step 3. Decryption:
B decrypts the message by using that .
This last step uses that .
Let's try it out!
Attacking RSA
To attack RSA the observer has to compute given .
That is NOT the discrete log problem again! (Why?)
In theory, the attacker has all the information they need. They know , so they can "just" factor to find , then compute , and as above.
However... factoring large numbers seems to be really frickin' hard.
OK, now work on your homework...