how can i get $f(x)$ from equation with modular

75 Views Asked by At

in a book it is written: " we have $$7= 19a + b \pmod{26}$$ and $$4= 14a +b \pmod{26}$$

after solving we get: $f(x)=11x + 6 \pmod{26}$"

how do they solve that and get the $f(x)$?

actually my question is the answer of an exercise:

the original question is:

An affine cipher is a type of simple substitution where each letter is encrypted according to the rule $c = a\cdot p + b \pmod{26}$ . Here, $p$, $c$, $a$, and $b$ are each numbers in the range $0$ to $25$, where $p$ represents the plaintext letter, $c$ the ciphertext letter, and $a$ and $b$ are constants. For the plaintext and ciphertext, $0$ corresponds to a, $1$ corresponds to b, and so on. Consider the ciphertext QJKES REOGH GXXRE OXEO, which was generated using an affine cipher. Determine the constants $a$ and $b$ and decipher the message. Hint: Plaintext t encrypts to ciphertext H and plaintext o encrypts to ciphertext E.

2

There are 2 best solutions below

3
On BEST ANSWER

You want to find the linear function $f(x)=ax+b$ from two values, I suppose. The method is just like it would be over $\Bbb R$ except that all arithmetic is odulo $26$ and division has to be done by multiplying by modular inverses:

Subtracting $14a+b = 4\pmod{26}$ from $19a+b = 7 \pmod{26}$ gives (the $b$ falls out):

$$5a = 3 \pmod{26}\tag{1}$$

and we have to find the inverse of $5$ in the ring $\Bbb Z_{26}$, which exists as $\gcd(5,26)=1$. Write (the Bézout theorem, using the extended Euclidean algorithm)

$$1 = 21 \cdot 5 - 26 \cdot 4$$ from which it follows that $$21 \cdot 5 = 1 \pmod{26}$$

so multiplying $(1)$ by $21$ on both sides gives

$$a = 3\cdot 21 = 63 = 11 \pmod{26}$$

Now, plug in $a=11$ in $$4 = 14a + b = 14 \cdot 11 + b = 154 +b = -2+b \pmod{26}$$

giving $b=6$ and so $f(x)=ax+b= 11x+6 \pmod{26}$, as claimed.

The $f$ is the encryption function, so you have to solve $p$ in terms of $c$ to find the decryption function.

$c=11p+6\pmod{26}$ so $$c-6 = c+20 = 11p \mod{26}$$ and we can find by the extended Euclidean algorithm that $$11^{-1} \pmod{26}= 19$$

and so $$p = 19(c+20) = 19c + 16 \pmod{26}$$

and so Q (which equals $16$) decrypts to $19 \cdot 16 + 16 = 8 \pmod{26}$ which means i etc.

1
On

I assume you want to find $$f(x)=ax+b$$

You have the equations:

$$\begin{align}7\equiv_{26}19a+b\tag{1}\\4\equiv_{26}14a+b\tag{2}\end{align}$$ Subtracting $(1)$ from $(2)$ yields $$\begin{align}3\equiv_{26}5a\\5^{-1}\cdot 3\equiv_{26}a\\21\cdot3\equiv_{26}a\\11\equiv_{26}a\end{align}$$ Can you take it from here?