Announcements
- PS#4 and the proposal for the Programming-Component Project are both due on Friday, 3/28.
- PS#5 is due on Friday, 4/4. You don't even need to talk with your classmates for this one!
- Please bring the Shank's Baby Step - Giant Step handout to class on Monday for one more wrap-up problem before we move on to the next topics.
- Head to indigo.cs.oswego.edu/jupyter/ to log into our Jupyter Hub with your CS department credentials. To stay organized, create a folder for Crypto to put all of your files from this semester into and be sure that you make new SageMath files so that you can use Python-y-Math commands. :)
Getting in touch with your instructor...
- Email: I actually read and respond to emails. I check email frequently during the workday but limit my email time after work hours and on weekends. Please be patient, but if I don't reply by the end of the next working day then feel free to email me again – there's always a chance your first email got buried under urgent emails (or spam ...) and I appreciate the nudge!
- Office Hours: Mondays 11:30 - 12:25, Tuesdays 2 - 3:30, and Fridays 1:50 - 2:45
Just stop by! You don't need an appointment to drop by my office. If you want to meet over Zoom, you will need to make and keep an appointment, because I am uncomfortable sitting on Zoom with no one there. I am also available over Discord (username in the syllabus, behind the SUNY Oswego login...). Join the Math Club Discord server (link in syllabus) and send me a message! We can use the voice channels and the text channels to stay in contact. Just be aware that if you message me in Discord, I won't respond until I'm free to check my phone ... in person obligations come first. - Other times: If my office door is open then you are welcome to stop in and ask if I'm available. I may be! If I'm busy, we can make an appointment to meet up later on.
Useful Resources
- University of Toronto - Mississauga Primes Pages
- Handbook of Applied Cryptography by Menezes, van Oorschot, and Vanstone
- RFC 8017 - PKCS#1: RSA Cryptography Specifications Version 2.2
- a table of symbols and their commands in latex
- El Gamal worksheet: p = 433026689
LaTeX Fun
You can exchange the commands in the box below for your own and render it on demand. It's kind of fun! Press the Render! button when you're ready.
\({}\)
SageMath and Tiny SageMath Programs
SageMath is free open source mathematics software that can do some pretty amazing calculations, and the software has a ton of useful libraries and built-in functions. You can download and install Sage for use on your computer through a terminal window or Juypter notebook, or you can use Sage online through CoCalc or SageMathCell. The SageMath language is built on Python, so if you know a bit of Python then you can often logic your way around SageMath. I will often use SageMathCell in class for quick examples and calculations but I prefer to use SageMath in a Juypter notebook on my computer so you might see both during the class meetings.
For really quick things, here's a SageCell box that you can try out! Change the input area to be whatever code you need, press Evaluate, and ta da!
You may prefer a different language or different software and that's great! Go ahead and use whatever you wish that will complete the same operations. SageMath has a lot of built-in programs and functions that make the programming easier, but there's something to be said for figuring out how to get the same results yourself and for learning how to do the same computations in your preferred programming language.
A few good SageMath commands to know:
- mod(x,n) returns the remainder of \(x\) modulo \(n\)
- factor(n) factors \(n\) ... but this can time out if \(n\) is big and hard enough to factor
- inverse_mod(x,n) calculates the inverse of \(x\) modulo \(n\)
- power_mod(x,i,n) gives \(x^i\) modulo \(n\)
- euler_phi(n) produces \(\varphi(n)\), the Euler totient of \(n\)
- g=mod(primitive_root(p),p) instructs Sage to select a primitive root modulo \(p\) and call it \(g\)
- p= random_prime(a, True) will return a random prime between 2 and \(a\)
- CRT_list([a1,a2,...,ak],[m1,m2,...,mk]) will solve a system of linear congruences, \(\{x \equiv a_1 \textrm{ mod } m_i \mid 1 \leq i \leq k\}\), provided that the moduli are pairwise relatively prime
- Mod(x,p).nth_root(n,all=True) asks Sage to produce a list of all remainders modulo \(p\) that, when squared, produce \(x\)
- Mod(x,p).sqrt(all=True) asks for all square roots of \(x\) modulo \(p\)
Tiny SageMath Programs
I've gathered several small bits of code that have been helpful in previous iterations of Cryptology. You can copy the code and paste it into the SageCell here, or on the SageMathCell site, to test it out. This is not organized in a reasonable way, and much of it is not explained ... explanations and elaborations will happen in class, so take good notes. Worst of all, some of this needs to be updated to match SageMath's current standards!
The Base 27 Code: Encoding
This bit of code will correctly handle phrases that are in lower-case and have no spaces. Evaluate the function and then call the function on a Python string; for example b27en('elizabeth') should return 2470610206256.
def b27en(str):
result = 0
nums = []
for i in [0..len(str)-1]:
castToNumber = ord(str[i]) - 96
nums.append(castToNumber)
result = result + castToNumber*(27^i)
return result