In this section, we discuss two types of encryption algorithms. The first is a simple algorithm that uses linear congruence functions to encrypt and decrypt. The second, despite being pretty simple to explain is one of the most common encryption algorithms in current use.
Our convention will be to use only capital English letters, A to Z. We will identify each letter with the remainders modulo 26. As our purpose is introducing basics of encryption, we wonβt encrypt punctuation or spaces.
An affine cipher is one in which letters are transformed via a linear function, \(e(x) = ax+b \pmod{n} \) where \(a, b\in \Z\) and \(n\in \Z^+\text{.}\) If \(a =1\text{,}\) this is a shift cipher.
Given that \(5^{-1} \equiv 21\pmod{26}\text{,}\) find the inverse of \(f(x)=5x+14\pmod{26}\text{.}\) Please ensure your coefficients are reduced modulo \(26\text{.}\)
RSA is an example of a public-key algorithm. Its security is based on the fact that factoring integers is a hard problem. The process is outlined below:
This works because \((M^e)^d = M^{ed} = M^1 \pmod{n}\text{.}\) Although we havenβt proven this, itβs a result of Eulerβs Totient Theorem which youβll revisit in future course on number theory.
Let \(p = 59, q=83\text{.}\) Choose \(e=15\) Encrypt βWHATS UPβ and then decrypt the result to confirm it worked. Do this by hand (with the help of a calculator).
In this activity, you will generate a public/private key-pair. You will send me the public key and keep your private key secret (but donβt lose it! If you lose your private key, you wonβt be able to complete the assignment and will receive no credit).
Pick two prime numbers \(p \and q\) of some interesting size. Make them at least six or seven digits long (use Sageβs next_prime).
Enter this information into the Sage cell below to decrypt it (using your \(n, d, \and c\)), change what_to_do to βdecryptβ, and then press Evaluate(Python).
Send me the decrypted message to confirm you decrypted it correctly (remove the padded Xβs if relevant, and put appropriate spaces to make it a normal English statement. For example βKEEPITSECRETKEEPITSAFEXXβ will not receive full credit.