1

I am looking for a formula for the number of possible invertible matrix keys that can be used for a Hill Cipher. From what I can tell the formula a^n^2 (where a is the alphabet size and n is the matrix key size) will provide the total number of possible matrices however this is an overestimation because many matrices will not have an inverse due to either having 0 determinant or having a determinant that is coprime with the alphabet size.

edit: in my use case the alphabet size, a, is prime

Thanks for any help,

Will
  • 11
  • When $a$ is prime, see this question. The answer here has the ideas needed to generalize to all $a$, but is very abstract. – Misha Lavrov Nov 01 '22 at 05:27
  • a is prime in my case so that is not a problem but I was just wondering if the method described in the question you linked to (using the general linear group), would account for the fact that the matrix is not invertible if the determinant is a multiple of the alphabet size (I believe this applies even if it is prime). However taking this into account makes the problem significantly more complicated I could still use the other method which should provide a slightly overestimated value. – Will Nov 01 '22 at 06:39
  • The formula for $GL_n(\mathbb F_q)$ does take that into account. Essentially, if $a$ is prime and the determinant is a multiple of $a$, the determinant is $0$ when working modulo $a$ - so when we work in the finite field, the two cases are the same. (Also, that answer just goes after invertibility directly, without going through the determinant.) – Misha Lavrov Nov 01 '22 at 13:45

0 Answers0