We assume that the message $$!IWGVIEX!ZRADRYD$$ has been encrypted using Hill Cipher and with the correspondence $A=0,...,Z=25,\ \_=26, ? =27,!=28$. We know that the last five letters of plaintext are sender's signature $MARIA$.
We want to find the deciphering matrix and read the message.
My attempt: At first we suppose that $m=2,\ P=C=\Bbb{Z}_{29}$ and $K=\mathrm{GL_2}(\Bbb{Z_{29}})$. By the hypothesis, we know that $MARIA \leftrightarrow ADRYD \iff (12,0,17,8,0)\leftrightarrow (0,3,17,24,17)$.
This implies that, if we assume that the key matrix is $A\in \mathrm{GL_2}(\Bbb{Z_{29}})$, the diciphering function is $$ E_A: (\Bbb{Z}_{29})^2 \longrightarrow (\Bbb{Z}_{29})^2,\\ (12,0)\mapsto (12,0)\cdot A =(0,3), \\ (17,8) \mapsto (17,8)\cdot A=(17,24) $$ so, $ \begin{pmatrix} 12 & 0 \\ 17 & 8 \end{pmatrix} \cdot A = \begin{pmatrix} 0 & 3 \\ 17 & 24 \end{pmatrix} $. We define $B:=\begin{pmatrix} 12 & 0 \\ 17 & 8 \end{pmatrix}$. Then, $\det B=9 \in U_{29} \iff B \in \mathrm{GL}(\Bbb{Z_{29}})$. Also, $\mathrm{adj} B= \begin{pmatrix} 8 & 0 \\ 12 & 12 \end{pmatrix} $ and $9^{-1}=13 \in U_{29}$. So, $$B^{-1}=13 \begin{pmatrix} 8 & 0 \\ 12 & 12 \end{pmatrix} = \begin{pmatrix} 9 & 0 \\ 11 & 11 \end{pmatrix}.$$ And from this, $$A = \begin{pmatrix} 9 & 0 \\ 11 & 11 \end{pmatrix} \cdot \begin{pmatrix} 0 & 3 \\ 17 & 24 \end{pmatrix} = \begin{pmatrix} 0 & 27 \\ 13 & 7 \end{pmatrix} \in \mathrm{GL}(\Bbb{Z_{29}}). $$
But if we use this matrix as a key and encipher the word $MARIA$, we will not take the word $ADRYD$ that we expect, so something is wrong. Is this method correct? Do I miss something?
Thank you.
You have to split the ciphertext in pairs, and your ciphertext corresponds to the following pairs of elements of $\mathbb{Z}_{29}$:
And the last 4 letters of your assumed plain text are "ARIA" (two pairs) that equal
(0, 17), (8, 0)We cannot use the M, as then we'd have to guess the letter before M too, as encryption is done by pairs. But 4 unknowns with 4 equations should suffice. So if we denote by $E$ the $2 \times 2$ encryption matrix we have that these 2 pairs must become the final two pairs of the cipher text, or written out as a matrix equation $EP = C$ where $P$ is a matrix of plain texts, and $C$ the corresponding ciphertexts:$$E \cdot \begin{bmatrix} 0 & 8 \\ 17 & 0 \end{bmatrix} = \begin{bmatrix} 3 & 24\\ 17 & 3 \end{bmatrix}$$
As the $P$ matrix is invertible, we compute $E$ as $CP^{-1}$ (using mod $29$ arithmetic and the easy formula for inverses of $2 \times 2$ matrices). Then compute $D$ as $E^{-1}$ and you'll find a nice plaintext indeed ending in
ARIA; I checked and it works out.