12

The question pertains to decrypting a Hill Cipher, but I am stuck on the part where I find the inverse of $70 \pmod{ 27}$. Does the problem lie in $70$ being larger than $27$?

I've tried Gauss's Method:

$\frac{1}{70} = \frac{1}{16} ^{\times2}_{\times2} = \frac{2}{32} = \frac{2}{5} = \frac{12}{30} = \frac{12}{3} = \frac{132}{33} = \frac{24}{6} = \frac{120}{30} $

And the denominators start repeating so I can never get 1 in the denominator.

And the Euclidean Algorithm

$\ 70 = 2(27) + 16 $
$\ 27 = 1(16) + 11 $
$\ 16 = 1(11) + 5 $
$\ 11 = 1(5) + 6 $
$\ 5 = 1(6) -1 $

Which is also not helpful. I think I'm trying to get + 1 on the last equation for $1 \pmod{ 27}$, but maybe I'm misunderstanding the method.

Am I approaching this incorrectly? I'm new to modular arithmetic.

Cameron Buie
  • 102,994
Amber
  • 369
  • 3
  • 11

6 Answers6

11

To illustrate how you would use your work here:

$$ 70 = 2(27) + 16 \\ 27 = 1(16) + 11 \\ 16 = 1(11) + 5 \\ 11 = 2(5) + 1 $$ (last line modified)

From this point, we start stacking these results together, so as to get $1$, $27$ and $70$ all in the same expression:

$$ 1=11-2(5)\\ 1=11-2(16-11)=3(11)-2(16)\\ 1=3(27-16)-2(16)=3(27)-5(16)\\ 1=3(27)-5(70-2(27))=13(27)-5(70) $$

Thus, $1\equiv 13(27)-5(70)\equiv 0 -5(70)\equiv 22(70)\pmod{27}$

Actually this can be shortened somewhat by reducing $70\equiv 16\pmod{27}$ ahead of time. Then you only have to deal with the last three equations in your list. Once you get to this point

$$ 1=3(27)-5(16) $$

you can conclude that $1\equiv 0-5(16)\equiv 22(70)$ and be done.

rschwieb
  • 153,510
10

Another way as $70=7\cdot 10$

$(70)^{-1}\equiv 7^{-1}\cdot 10^{-1}$

Now, as $7\cdot4=28\equiv1\pmod{27}\implies 7^{-1}\equiv4\pmod{27}$

and $27\cdot37=999\equiv1000-1\implies 10\cdot100\equiv1\pmod{27}\implies 10^{-1}\equiv100\pmod{27}\equiv19$

$\implies (70)^{-1}\equiv4\cdot19\pmod{27}\equiv22$

2

I notice that $70\equiv 16 \mod 27$.

Then $5\times 16=80 \equiv -1 \mod 27$ - which is just a lucky spot

So that $1\equiv (80)^2\equiv -1\times 5 \times 16\equiv -5\times 70\equiv 22\times 70\mod 27$

Which is unsystematic, but effective.

Mark Bennet
  • 100,194
2

A couple of ideas (working all the time modulo $\,27\,$):

$$\begin{align*}\bullet&\;\;70=14\cdot 5\\ \bullet&\;\;14\cdot2=28=1\implies& 14^{-1}=2\\ \bullet&\;\;5\cdot 11=55=2\cdot 27+1=1\implies&5^{-1}=11\end{align*}$$

Thus, finally, we get

$$70^{-1}=14^{-1}\cdot 5^{-1}=2\cdot 11=22$$

DonAntonio
  • 211,718
  • 17
  • 136
  • 287
1

We have $70\equiv16\pmod{27}\equiv2^4$

As $(2,27)=1,$

so using Carmichael function $\lambda(27)=\phi(27)=3^{3-1}(3-1)=18$ where $\phi$ is the Totient function

$\implies 2^{18}\equiv1\pmod{27}$

$\implies (2^a)^{-1}\equiv2^{18-a} \pmod{27}$

$\implies (2^4)^{-1}\equiv2^{14} \pmod{27}$

Now, $2^5=32\equiv5\pmod{27}\implies 2^{14}=(2^5)^2\cdot2^4\equiv5^2\cdot16\pmod{27}\equiv(-2)(-11)\equiv22$

We can apply this method to find inverse of any integer $a\pmod m$ where $m$ is an integer provided $(a,m)=1$

In fact, we can find smaller exponent $d(>0)$ than $\lambda(m)$ such that $a^d\equiv1\pmod m$

But,as $2$ is a primitive root of $3^2=9$

using this $,2$ is a primitive root of $3^n$ for integer $n\ge1$

$\implies $ord$_{27}2=\phi(27)=18$

1

It’s a good idea to know how to backtrack through the Euclidean algorithm, as illustrated in rschwieb’s answer, but here the numbers are small enough that simple brute force is actually quite effective. $70\equiv 16\pmod{27}$, so you want a multiple of $16$ that’s $1$ more than a multiple of $27$. And if $16k=27n-1$, then $16(-k)=27(-n)+1$, so finding a multiple of $16$ that’s $1$ less than a multiple of $27$ is just as useful. Run through the first few multiples of $16$: $16,32,48$, and $64$ don’t help, but $80$ is one less than $81=3\cdot27$, so $-80=-81+1\equiv 1\pmod{27}$. Thus, $-5$ is a multiplicative inverse of $16$ and hence of $70$ modulo $27$, and so is $-5+27=22$. I did all of that mentally before typing up this answer.

And as a check, $22\cdot70-1=1539=27\cdot 57$.

By the way, the process of backtracking through the Euclidean algorithm can be simplified and speeded up considerably via the extended Euclidean algorithm.

Brian M. Scott
  • 616,228