# How can I get the message which was encrypted before (when decrypting a product cipher) ?

I want to make a product cipher containing s box and p box.
where message $m = \{m_1, m_2, m_3, m_4\}$ where $m_i \in \{0, 1, \dots 25\}$ for $i=1,2,3,4$.
p-box: $P(x_1, x_2, x_3, x_4) = (x_1, x_3, x_2, x_4)$
S-box: $\mathbb{Z}^2 \rightarrow \mathbb{Z}^2$ where $\mathbb{Z} \in \{0, 1, \dots, 25\}$
$S(x,y)=(x+k_1 y \bmod 26, k_2 x + y \bmod 26)$ $K = (k_1, k_2)$ where $k_1, k_2 \in \{1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25\}$

Encryption:

let key k = (k1, k2) = (3, 5)
Let M = {4, 8, 12, 13}
P - box: p(M) = {4, 12, 8, 13}
s - box: S(4, 12) = (4 + 12 × 3(mod 26), 5 × 12 + 12 (mod26)) = (14, 6)
S(8, 13) = (8 + 13 × 3(mod 26), 5 × 8 + 13 (mod26)) = (21, 1)
cipher Text = {14, 6, 21, 1}


Decryption using S - box:

S(14, 6)
a + 3b(mod26) = 14
5a + b(mod26) = 6


and

S(21, 1)
a + 3b(mod26) = 21
5a + b(mod26) = 1


I am however unable to solve these equations.

## Where I'm stuck

Solving for S(14, 6).

5a + b(mod26) = 6 multiplying this equation with 3 and then subtracting a + 3b(mod26) = 14.

We get 14a(mod26) = 4

To solve this I guess we need multiplicative inverse of 14 in Modulo 26 which does not exists. So we get multiple values for a and b.

So the message gets decrypted with multiple solutions. The original message plus some random messages.

How can I get exactly the message which was encrypted before?

$$14 a = 4 \mod 26$$
$$7 a = 2 \mod 26$$
$$a = 2 * 15 \mod 26$$
$$a = 4$$