Announcements
- No class on Friday, 5/5. Good luck during the last few days of classes and finals week!
- Office hours remaining:
- Wednesday, 5/3 from 1:50 - 2:45 in 450 Shineman
- Monday, 5/8 from 10:30 - 12 in 174D MCC
- Tuesday, 10 - 11 in 450 Shineman
- Wednesday, 5/10 from 11:30 am until 12:30 am in 450 Shineman
- Demo Sessions:
- Wednesday, 5/10 from 10:30 - 11:30 in 444 Shineman
- Wednesday, 5/10 from 2 - 4 in 444 Shineman
- Friday, 5/12 from 10:30 - 12:30 in 150 Shineman
Values for In-Class Activities
Thank you, University of Toronto - Mississauga Primes Pages, for the primes!
- EC Activity
- p =1332297598440044874827085558802491743757193798159
- A = 297190522446607939568481567949428902921613329152
- B =173245649450172891208247283053495198538671808088
- x =1089473557631435284577962539738532515920566082499
- y =127912481829969033206777085249718746721365418785
- RSA Practice Activity
- 22953686867719691230002707821868552601124472329079
- 30762542250301270692051460539586166927291732754961
- 29927402397991286489627837734179186385188296382227
- 46484729803540183101830167875623788794533441216779
- 95647806479275528135733781266203904794419563064407
- 64495327731887693539738558691066839103388567300449
- 58645563317564309847334478714939069495243200674793
- 48705091355238882778842909230056712140813460157899
- 15452417011775787851951047309563159388840946309807
- 53542885039615245271174355315623704334284773568199
- DHKE Activity: \(p=4669523849932130508876392554713407521319117239637943224980015676156491\)
- Other Activity: \(p=1078834318169\)
Due Dates, Exam Dates, Etc.
Problem set due dates will be added as problem sets arise. The plan is to have more problem sets at the start of the semester, so that you can work on your projects more as the semester progresses.
- May:
- May 3 - Exam 2 (paper, class period)
- May 12 - Public Demo to Your Class for Programming-Component Project (in person, during final exam period)
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: M. 1:50 - 3:30 in 174D MCC, W. 1:50 - 2:45 in 450 Shineman, F. 1:50 - 2:45 in 446 Shineman
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
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!
Checking For Solutions of a Quadratic Congruence
To figure out all solutions to \((x-3)(x+2) == 0\) modulo 15, one way to do this is to let \(x\) range from 1 to 14 (all possible remainders) and calculate each factor (i.e., calculate \(x - 3\) and \(x + 2\)). Then calculate the product modulo 15 and check if you get 0. Here's a tiny program to get that done:
for x in [0..14]:
i = Mod(x-3,15)
j = Mod(x+2,15)
k = Mod(i*j,15)
print (x,k)
There are faster, more clever and conservative ways to achieve the same result, though, and you might spend some time optimizing your approach.
Fermat's Factorization Scheme
You can do these calculations by hand if your calculator has enough memory and stores enough digits, but if \(p\) and \(q\) are far apart then you have to check a lot of things .... note that this program uses \(n = 23360947609\), and it also requires that you have an idea of how many steps you'll need before you can actually find \(t, s\). If you get fancy, you can write the same output using a while loop so that the loop runs as long as "fake \(s\)" is not an integer.
for i in [0..5]:
# Define the "potential t"
ft = ceil(sqrt(23360947609))+i
# "potential s" = sq rt of (ft^2 - n)
fs = N(sqrt(ft^2-23360947609))
# print the potentials, as well as potential p and q
print (i, ft, fs, ft+fs,ft-fs)
# look on the list for the integers
Marcello Cierro and Christian Sumano wrote a while loop that produces the final answer:
n=1433811615146881
i=0
while (True):
t = ceil(sqrt(n))+i
s = sqrt(t^2-n)
print ("i", ":", i, ", t:", t , ", s:", s)
i += 1
if (s.is_integer() == True):
break
Calculating Powers
This next tiny program runs through the powers of \(g\) (modulo \(p\)) until it gets to \(h\), and the prints out the exponent. If \(g\) is not a primitive root modulo \(p\), the program may just time out ... and if you change \(g\), \(h\), and/or \(p\) to be very large then Sage may not be able to finish the computation.
g = 2
h = 38679
p = 56509
h1 = h%p
# Now run through the powers of g to see if any equal h1
# Print n if g^n is congruent to h1 modulo p
for n in range(p-1):
if Mod(g^n,p)==h1:
print n
To get the picture of the discrete log function modulo \(p\), check out this tiny bit of code that produces the graph:
p=53
R = Integers(p)
a = R.multiplicative_generator()
v = sorted([(a^n, n) for n in range(p-1)])
G = plot(point(v,pointsize=50,rgbcolor=(0,0,1)))
H = plot(line(v,rgbcolor=(0.5,0.5,0.5)))
G + H
And then, we also consider the different powers of an element modulo a prime. Here's a tiny program that will show you the order of each element in \(\mathbb{Z}/p\mathbb{Z}^*\).
# A program to print out the powers of all of the values modulo 23
# i is the base
for i in [1..22]:
print ("The powers of ",i," are ...")
# j is the exponent, it should start cycling at 1
j = 1
# as long as i^j is not congruent to 1, increase the exponent j
while (i^j)%23 > 1:
j1 = j + 1
j = j1
# once i^j is congruent to 1, print out j
print (j, " - ", (i^j)%23)