Question about affine cipher

105 Views Asked by At

So say we have some affine cipher $C\equiv mP+n$ mod($N$). In my number theory textbook it states that in this type of cipher, $m$ and $N$ must be coprime. I am wondering why that is. The transformation could still occur even if they weren't coprime.

So why do $m$ and $N$ have to be coprime?

3

There are 3 best solutions below

0
On

If $m$ is not coprime to $N$, the transformation will not be injective. For example, $P=0$ and $P=N/\gcd(m,N)$ would both produce $C=n$.

0
On

If $m$ and $N$ is not coprime, you are still able to produce the ciphertext $C$.

Now you might want to decipher it to uncover $P$ and how would you do so?

if $gcd(m,N)=1$, $m^{-1} \mod N$ exists and we can compute $$P \equiv m^{-1} (C-n) \mod N$$

0
On

We need to be able to decrypt, and the decrpytion formula is given by $P \equiv m'(C - n) \bmod N$, where $mm' = 1 \bmod N$. And $m'$ only exists if $m,N$ are coprime.