For Wednesday, September 21

For Wednesday:

1. BRING A LAPTOP TO CLASS, WE WILL DO A WORKSHOP DAY.
2. In class you received your Module 2 assessment back, along with solutions (on paper).  Please compare your solutions to the published solutions and take time to understand all your (and my!) errors.
3. There is an opportunity to replace one grade from among the Part B questions (four questions each worth 10 points):
1. If you wish to replace a grade of 7, 8, or 9, I will provide a similar problem and ask you to hand in a solution on canvas.  I will announce this after I have finished the in-person replacements for other students.
2. If you wish to replace a grade less than or equal to 6, then we will meet in person, and I will ask you to solve a similar problem.  If you wish to do this, then please schedule a time with me (zoom or in person).  This time can be anytime in the next week or so, but you must contact me to schedule it before Wednesday.  Just email me to set this up.
4. Just some extra info.  I have a very special place in my heart for the euclidean algorithm.  I have written up my explanation from class in the overleaf course notes (available in “Notes/Videos” in the top bar).  I also have two videos about it under “Notes/Videos” in the top bar.  These videos explain the same algorithm, but not exactly the same (more “coats of paint” to your understanding) and you may wish to watch them for review at some point.
5. Compute gcd(183,105).  Show the process by hand.
6. Solve the Diophantine equation (meaning, find all integer solutions, show the process by hand):
1. 183x + 105y = 0
2. 183x + 105y = 3
3. 183x + 105y = 1
7. Looking at your work above, what is the gcd of 61 and 35 (it should not require new computations, it’s there for you to see)
8. Looking at your work above, what is the full set of solutions to $35x + 61y = 1$?  (it should not require new computations, it’s there for you to see in your work above)
9. Find the inverse of 35 modulo 61.  This should not require new computations either; it should be discernible from your work above.   Hint:  To find the inverse of $a$ modulo $n$, you need to solve $ax \equiv 1 \pmod n$, which is to say, $ax + ny = 1$.

For Monday, September 19, 2022

For Monday:

1. Rest and relax over the weekend!  Give yourself full credit for the daily post and no need to submit anything.
2. I apologize for the errors in the exam problems.  There will be a make-up opportunity of some sort, which I will decide on over the weekend.

Due Friday September 16th:

Due Friday:

1. The Module 2 Test is on Friday in class.  First and foremost, please study for that.
2. The test covers Module 2 and also covers part of Module 1.   Written test, no calculators or cheat sheets.  I will include the mod 26 addition/multiplication tables in the test packet.  See the Goals page for a list of topics (those with checkmarks; that’s all updated).  Textbook review questions are listed under Modules 1 and 2 on that page.
3. I will have an office hour on Thursday at noon on the classroom zoom link (available on discord and canvas).  I will try to be especially available on discord.
4. Useful tips:  You can click “archive” in the top bar for a day-by-day list of notes (my written notes from class) and resources.  All lecture recordings (except one) are available on canvas.
5. As something to upload to canvas for today’s daily, please make sure your daily post evaluation sheet is up to date and upload a copy of that.

Due Wednesday September 14th

For Wednesday:

1. The Module 2 Test is on Friday in class.  It also covers part of Module 1.   Written test, no calculators or cheat sheets.  I will include the mod 26 addition/multiplication tables in the test packet.  See the Goals page for a list of topics (those with checkmarks; I’ll further update the checkmarks after Wednesday’s class, depending on what we manage to cover).  Textbook review questions are listed under Modules 1 and 2 on that page.
2. I will have an office hour on Thursday at noon on the classroom zoom link.
3. You can find some index calculus examples that work out nicely in this replacement video (9:18), its accompanying notes, and in the course notes I’m writing (currently section 2.8.3).  Please use these as resources rather than the live lecture video where I made and had to correct errors.
4. Solve the discrete logarithm problem for $p=131$, $g=2$, $h=17$, using the Index Calculus method.  You may use the Index Calculus Tools and Sage’s modular arithmetic and plain arithmetic computations to avoid by-hand computations, but please solve the linear system by hand (i.e. choosing which equations to subtract from which etc.).  Note:  this is a randomized algorithm, so you will get different relations than someone else, or next time you run the tool.  If you are not finding a very nice linear system, just try to get some more relations and pick simple manageable ones.
5. Please spend the remainder of your time studying for the Module 2 Test on Friday.

Due Monday September 12th, 2022

For Monday:

1. ANNOUNCEMENT:  The first assessment will be a full-period in-class test on Module 2 and portions of Module 1, on Friday September 16th, 2022.  As we finish up information I am updating the Goals page with checkmarks.  Checkmarks indicate material that will be covered.  It will involve demonstrating the ability to reason about material covered, to implement algorithms by hand, and to do small mathematical proofs (some proofs, like that of Euler’s theorem, should be studied so you can reproduce them).
2. Compare your solutions for daily posts due Sept 2Sept 7 and Sept 9.  Look these over carefully (this is a great learning opportunity!) and ask if you have questions.
3. Use exhaustive search or any method to compute $L_2(3)$ modulo $13$.  You can use Sage’s modular arithmetic functions such as the tables on this page.
4. It is a fact that $p=101$ is prime, and $2$ is a primitive root modulo $p$.  It is a fact that $L_2(3)=69$ and $L_2(5)=24$ modulo $p$.   It is also a fact that the integer factorization of $24$ is $24 = 2^3 \cdot 3$.  Using these facts, evaluate $L_2(24)$ modulo $p$ with minimal work (just combine the facts above).
5. We finished class Friday before I could do an example of the Baby-Step-Giant-Step algorithm.  Please check the notes (which have an example) or watch this video of the example (3:22), and review the method.  I’ve now added it to the latex course notes.  Your text also has a discussion (Chapter 7, Section 7.2.2 in 2nd ed).
6. Use the Baby-Step-Giant-Step algorithm (and show all steps) to solve the discrete logarithm problem $34 = 3^x \pmod{113}$.  You may use Sage’s functionality to compute the lists, including the tools on the BabyStepGiantStep page if you want to (ask for help on discord if you need some explanation of the page), so it shouldn’t involve much work by hand.  But please present the solutions tidily and in a well-explained and well-labelled way (indicate where each term in each list comes from, not just the value you get), so the algorithm is evident.
7. Analyse the runtime of the Baby-Step-Giant-Step algorithm.  That is, clearly answer the following.  This is similar to what we did for modular exponentiation in class (see the notes from class).
1. What is the input?
2. What is the size of the input?
3. What is the runtime?
4. What is the runtime as a function of the input size?

Due Friday September 9th

For Friday:

1. For each of the following pairs of functions, determine if $f=O(g)$ and if $g=O(f)$.
1. $f(x) =|sin(x)|$ and $g(x) = 1/2$.
2. $f(x) = 2^x$ and $g(x) = 3^x$.
2. Read your textbook, Section 2.9 “One Time Pads”.  This explains the “add your message to the shared key” approach I used in the last daily post.  (Let me know if you don’t have access to the text yet.)
3. Fill in this Google Form collecting some info on how you want to do office hours and whether you want some extra tutorial on proofs.
4. A bit of math practice that shows that the parity (even or oddness) of the discrete log can be discovered easily.  Let $p$ be a prime number.
1. Show that if $ab \equiv 0 \pmod p$ then $a \equiv 0 \pmod p$ or $b \equiv 0 \pmod p$
2. Use part (1) on the expression $(x+1)(x-1)$ to show that the only two solutions to $x^2 \equiv 1 \pmod p$ are $1$ and $-1$.
3. Let $g$ be a primitive root mod $p$.  Show that $g^{(p-1)/2} \equiv -1 \pmod p$.  (This uses the previous part.)
4. Suppose $h \equiv g^x \pmod p$ is given to you (but $x$ is not known).  Show how you can determine if $x$ is even or odd.  Hint: Raise the equation $h\equiv g^x \pmod p$ to the $(p-1)/2$ power and see what you get using the previous part.
5. Note that $2$ is a primitive root modulo $11$.  Use the test above to determine if $x$ so that $2^x \equiv 5 \pmod{11}$ is even or odd.
6. Check whether you are correct by finding $x$ (by any method).
7. Comment on the runtime of this test for the parity of $x$.
5. If you are so inclined, try to break one of the ciphertexts on discord from our Diffie-Hellman Key Exchange.  We discussed this in class and saw that the Sage server wasn’t having it, with my little for loop.  But maybe you can make it work!

Due Wednesday, September 7th

For Wednesday:

1. Here are solutions to the last daily post, please compare and make sure you feel good about it.
2. Today you will perform a Diffie-Hellman Key Exchange in order to send a message to someone on the #ciphertexts channel.  Big picture:  you’ll do a Diffie-Hellman Key Exchange to make a shared secret and then use that shared secret as a key for a very simple encryption (a sort of Caesar Cipher or One-Time Pad):
1. Create a secret message which is at most 6 letters long.  It should answer “Why CU?”  Please don’t make it longer or this exercise won’t work.  Use only the 26 letters of the alphabet, but you can use lower or upper case.
2. Turn it into an integer using the Text to Integer tool.  (This turns it into an integer by writing the letters in ASCII and making an integer base 255 with those digits.  There’s an Integer-to-Text tool on the same page to undo this process.)
3. If you need a review of Diffie-Hellman, check the lecture notes/video and Section 7.4 of the textbook.
4. We will use prime $p=10^{15}+37$, and its primitive root $g=2$.  The first box in the Diffie-Hellman Tools page will initialize this modular ring for you.
5. Use the Diffie-Hellman Tools (second box) to find a random secret a.  We’ll call this your secret key.  Keep it secret, maybe in your underwear drawer. (Joking! — actually safer if you copy it into a text file on your computer, because if you write it by hand you’ll make an error.)
6. Compute $g^a$ using the Diffie-Hellman Tools third box (no need to do this by hand!) We’ll call this your public key.
7. Announce your public key on discord #ciphertexts.
8. Find someone else’s public key ($g^b$) on discord.  Let’s call that other person Bob.  Use it to generate your shared secret ($g^{ab}$) with Bob (you’ll need your secret key for this).  Again, you can use the third box in the Diffie-Hellman Tools page to do the computations (no need to work by hand).
9. Add the shared secret to your message mod p.  Announce the result on discord as the secret message for BobInclude your public key for them, because they will need it.  You post might look like “My message for @soandso is X and my public key is Y.”
10. When someone sends you a secret message, figure out how to decrypt it and announce the result.  You may need to use the Diffie-Hellman Tools and the Text to Integer converter.
3. Here’s another exponent problem to practice on.  Try to compute $13^{453^{2022}}$ modulo $100$.  For multiplying two digit numbers, you can use a calculator. 🙂
4. If time remains, try to break someone else’s message that wasn’t directed to you!

Due Friday, September 2nd

For Friday:

1. Write me a paragraph “check-in”; how do you feel the class is going?  What are challenges, what can I do to help with those?
2. Compare your last daily post solutions with my solutions.  Make sure you understand your errors or incomplete questions (if any).  Ask me if you have questions, I’m easy to find on discord.
3. Use Euler’s And Fermat’s Little theorems (and maybe successive squaring or double-and-add/square-and-multiply) to compute $59^{(7^{115})} \pmod{26}$ by hand.
4. Use Euler’s Theorem to prove the following:  Let $a \in (\mathbb{Z}/n\mathbb{Z})^*$ have multiplicative order $k$.  Then $k$ divides $\varphi(n)$ (the Euler phi function of $n$).  I will provide some hints on discord using the ‘spoiler’ feature.

Due Wednesday, August 31st

For Wednesday:

1. Remember that you only need to spend 1 hour.  If you get stuck on a problem, don’t spin your wheels; try some others instead and sleep on it.  You can come back to things.  I will post full solutions for these.
2. Here are some solutions to the last daily post, which you should compare to your own answers from last time.
3. Compute the Euler phi functions $\varphi(12)$, $\varphi(26)$, $\varphi(27)$.  For each of these $n$, verify your answer by computing the set $(\mathbb{Z}/n\mathbb{Z})^*$.
4. Another ciphertext exchange on discord!
• Use Hill cipher to encrypt the answer to the question “What is your favourite vegetable?”  You can use some Hill Cipher tools here, to avoid by-hand computations.  Or you can write your own encryption/decryption program.  You can choose your own (valid!) key.
• Post your key and ciphertext.  Use someone else’s key & ciphertext to get their plaintext and announce the result.  There’s a #ciphertexts channel for this.
5. Can you find the Hill cipher key?  The Hill cipher (with 2×2 matrices) was used to encrypt the plaintext SOLVED to get the ciphertext GEZXDS.
6. Consider Hill cipher with the matrix $$\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$$ modulo $26$.  Can you find two plaintexts that encrypt to the same ciphertext?  (The plaintexts don’t need to be english, they can just be any letters.)  What’s wrong with this matrix?
7. Prove that
• if you take successive powers of $a$ mod $n$, i.e. $a,a^2,a^3,a^4,a^5,\cdots$, that eventually you will get a repeat (the same residue will appear more than once, e.g. $a^2$ might equal $a^7$)
• if $a$ is invertible, then eventually you will get a $1$
• Remind yourself how to use the Multiplicative Dynamics tools.  Can you find an example where you never get a $1$ in that list?

Due Monday, August 29th

For Monday:

• A note about daily posts!  Sometimes the tasks may take more than an hour, or be frustrating.  Sometimes I give you tasks BEFORE I’ve taught you how to do them.  (My philosophy is that that’s part of the exploratory, messy nature of effective mathematics learning.)  In these circumstances, you should feel you have done your due diligence after one hour and hand in what you have (maybe skip over the frustrating task, at least at first).  Then you can come back to them later sometime, as needed.  For example, after Friday’s class, the Wednesday tasks should seem doable if they were not before, and you can go back to them to solidify understanding.
• Quick review question:  What is the inverse of 7 mod 11?  What is the inverse of 7 mod 14?  (Watch for trick questions!)
• I’m assuming you know about binary, and how to write things in binary.  If not, this PBS YouTube video gives a good review in the first four minutes.  (The rest of the video is also relevant and interesting (about ASCII and unicode etc.) if you are curious.)
• I’ve warned you several times that you cannot reduce an exponent modulo $n$ even when you are working in $\mathbb{Z}/n\mathbb{Z}$.  So we might sometimes need to compute large exponents.  Let’s suppose we need to compute $2^5$.  We could start with $2$, and then:
1. multiply by $2$ to get $2^2=2 \times 2 =4$
2. multiply by $2$ to get $2^3=4 \times 2=8$
3. multiply by $2$ to get $2^4=8 \times 2=16$
4. multiply by $2$ to get $2^5=16 \times 2=32$
• That’s four multiplications.  Instead, we could do this:
1. multiply by $2$ to get $2^2=4$
2. now that we have $2^2=4$, we could multiply it by itself to get $2^4 = 4 \times 4 = 16$
3. multiply by $2$ to get $2^5 = 32$
• That was only three multiplications!  That’s more efficient.  So, the challenge is to compute a high power by doing as few multiplications as possible.
• Your challenge is to compute $2^{148}$ modulo $1000$.  Imagine you have a calculator that will multiply two numbers modulo $1000$ for you (for example, you can use google, wolfram alpha or Sage on the course website), but WON’T just do big exponents.  (Remember, it’s always efficient to reduce mod n between each multiplication, so you never get more than 3 digit numbers to work with.)  How can you do this with the fewest multiplications possible?  Try to do the best you can, and count the multiplications you use.
• Then, watch this video (6:09) which gives a general algorithm.
• Use the double-and-add algorithm of the video (by writing 148 in binary) to demonstrate an efficient way to compute $2^{148}$.
• What you just learned is what computers do, when implementing cryptosystems in modular arithmetic.
• Now read Section 3.5 “Modular Exponentiation” of your textbook for another, different approach.  Now work out this method for $2^{148}$?  Better or worse?  This is an easier algorithm to internalize and remember for use on a test.
• Time left?  I wouldn’t want you to get bored.  If you still have some time left, you can optionally try to create a nice implementation of the double-and-add algorithm in your favourite language.  I’d be happy to see that in the canvas inbox if you do.  If you are new to programming, implementing the simpler algorithm of just multiplying by 2 repeatedly using a for-loop is a good first challenge.  There are tons of “learn python” resources online; here’s a YouTube playlist that seems popular.  Reach out to me!