[Math] Find the Hill cipher key matrix that can realize this permutation

cryptography

Find the Hill cipher key matrix $K$ that can realize the permutation $$f: (1,2,3,4,5) \to (3,5,1,4,2).$$

I am not sure how to find a $5\times 5$ matrix that satisfies this.
My guess is

$$K=\begin{bmatrix} 0 & 0 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 1\\ 1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 1 & 0\\0 & 1 & 0 & 0 & 0\\ \end{bmatrix}.$$

I am not sure if this is correct.

Best Answer

I hope that I understand you question right. The block size corresponds to the size of the matrix. So the block size in this case is five.

When your key is $K$ and your plaintext is for example $HELLO$ corresponding to the vector $$ \pmatrix{8 \\ 5 \\ 12\\ 12\\ 15} $$ then you get $$ \pmatrix{ 0 & 0 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 1\\ 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0\\0 & 1 & 0 & 0 & 0} \pmatrix{8 \\ 5 \\ 12\\ 12\\ 15} = \pmatrix{12\\15\\8\\12\\5}.$$ So the ciphertext is $LOHLE$. This corresponds exactly to the permutation that you gave.