<s>
In	O
classical	B-Algorithm
cryptography	I-Algorithm
,	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
is	O
a	O
polygraphic	O
substitution	O
cipher	O
based	O
on	O
linear	B-Language
algebra	I-Language
.	O
</s>
<s>
The	O
following	O
discussion	O
assumes	O
an	O
elementary	O
knowledge	O
of	O
matrices	B-Architecture
.	O
</s>
<s>
To	O
encrypt	O
a	O
message	O
,	O
each	O
block	O
of	O
n	O
letters	O
(	O
considered	O
as	O
an	O
n-component	O
vector	O
)	O
is	O
multiplied	O
by	O
an	O
invertible	O
n	O
n	O
matrix	B-Architecture
,	O
against	O
modulus	O
26	O
.	O
</s>
<s>
To	O
decrypt	O
the	O
message	O
,	O
each	O
block	O
is	O
multiplied	O
by	O
the	O
inverse	O
of	O
the	O
matrix	B-Architecture
used	O
for	O
encryption	O
.	O
</s>
<s>
The	O
matrix	B-Architecture
used	O
for	O
encryption	O
is	O
the	O
cipher	O
key	O
,	O
and	O
it	O
should	O
be	O
chosen	O
randomly	O
from	O
the	O
set	O
of	O
invertible	O
n	O
n	O
matrices	B-Architecture
(	O
modulo	O
26	O
)	O
.	O
</s>
<s>
The	O
Hill	B-Algorithm
cipher	I-Algorithm
has	O
achieved	O
Shannon	O
's	O
diffusion	O
,	O
and	O
an	O
n-dimensional	O
Hill	B-Algorithm
cipher	I-Algorithm
can	O
diffuse	O
fully	O
across	O
n	O
symbols	O
at	O
once	O
.	O
</s>
<s>
In	O
order	O
to	O
decrypt	O
,	O
we	O
turn	O
the	O
ciphertext	O
back	O
into	O
a	O
vector	O
,	O
then	O
simply	O
multiply	O
by	O
the	O
inverse	O
matrix	B-Architecture
of	O
the	O
key	O
matrix	B-Architecture
(	O
IFKVIVVMI	O
in	O
letters	O
)	O
.	O
</s>
<s>
We	O
find	O
that	O
,	O
modulo	O
26	O
,	O
the	O
inverse	O
of	O
the	O
matrix	B-Architecture
used	O
in	O
the	O
previous	O
example	O
is	O
:	O
</s>
<s>
Two	O
complications	O
exist	O
in	O
picking	O
the	O
encrypting	O
matrix	B-Architecture
:	O
</s>
<s>
Not	O
all	O
matrices	B-Architecture
have	O
an	O
inverse	O
.	O
</s>
<s>
The	O
matrix	B-Architecture
will	O
have	O
an	O
inverse	O
if	O
and	O
only	O
if	O
its	O
determinant	O
is	O
not	O
zero	O
.	O
</s>
<s>
The	O
determinant	O
of	O
the	O
encrypting	O
matrix	B-Architecture
must	O
not	O
have	O
any	O
common	O
factors	O
with	O
the	O
modular	O
base	O
.	O
</s>
<s>
If	O
the	O
determinant	O
is	O
0	O
,	O
or	O
has	O
common	O
factors	O
with	O
the	O
modular	O
base	O
,	O
then	O
the	O
matrix	B-Architecture
cannot	O
be	O
used	O
in	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
,	O
and	O
another	O
matrix	B-Architecture
must	O
be	O
chosen	O
(	O
otherwise	O
it	O
will	O
not	O
be	O
possible	O
to	O
decrypt	O
)	O
.	O
</s>
<s>
Fortunately	O
,	O
matrices	B-Architecture
which	O
satisfy	O
the	O
conditions	O
to	O
be	O
used	O
in	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
are	O
fairly	O
common	O
.	O
</s>
<s>
For	O
our	O
example	O
key	O
matrix	B-Architecture
:	O
</s>
<s>
Since	O
and	O
,	O
25	O
has	O
no	O
common	O
factors	O
with	O
26	O
,	O
and	O
this	O
matrix	B-Architecture
can	O
be	O
used	O
for	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
.	O
</s>
<s>
Consequently	O
,	O
a	O
useful	O
variant	O
of	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
adds	O
3	O
extra	O
symbols	O
(	O
such	O
as	O
a	O
space	O
,	O
a	O
period	O
and	O
a	O
question	O
mark	O
)	O
to	O
increase	O
the	O
modulus	O
to	O
29	O
.	O
</s>
<s>
The	O
matrix	B-Architecture
K	O
is	O
invertible	O
,	O
hence	O
exists	O
such	O
that	O
.	O
</s>
<s>
The	O
basic	O
Hill	B-Algorithm
cipher	I-Algorithm
is	O
vulnerable	O
to	O
a	O
known-plaintext	O
attack	O
because	O
it	O
is	O
completely	O
linear	O
.	O
</s>
<s>
Calculating	O
this	O
solution	O
by	O
standard	O
linear	B-Language
algebra	I-Language
algorithms	O
then	O
takes	O
very	O
little	O
time	O
.	O
</s>
<s>
While	O
matrix	B-Architecture
multiplication	O
alone	O
does	O
not	O
result	O
in	O
a	O
secure	O
cipher	O
it	O
is	O
still	O
a	O
useful	O
step	O
when	O
combined	O
with	O
other	O
non-linear	O
operations	O
,	O
because	O
matrix	B-Architecture
multiplication	O
can	O
provide	O
diffusion	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
appropriately	O
chosen	O
matrix	B-Architecture
can	O
guarantee	O
that	O
small	O
differences	O
before	O
the	O
matrix	B-Architecture
multiplication	O
will	O
result	O
in	O
large	O
differences	O
after	O
the	O
matrix	B-Architecture
multiplication	O
.	O
</s>
<s>
Indeed	O
,	O
some	O
modern	O
ciphers	O
use	O
a	O
matrix	B-Architecture
multiplication	O
step	O
to	O
provide	O
diffusion	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
MixColumns	O
step	O
in	O
AES	B-Algorithm
is	O
a	O
matrix	B-Architecture
multiplication	O
.	O
</s>
<s>
The	O
function	O
g	O
in	O
Twofish	B-Algorithm
is	O
a	O
combination	O
of	O
non-linear	O
S-boxes	O
with	O
a	O
carefully	O
chosen	O
matrix	B-Architecture
multiplication	O
(	O
MDS	O
)	O
.	O
</s>
<s>
There	O
are	O
matrices	B-Architecture
of	O
dimension	O
n	O
×	O
n	O
.	O
Thus	O
or	O
about	O
is	O
an	O
upper	O
bound	O
on	O
the	O
key	O
size	O
of	O
the	O
Hill	B-Algorithm
cipher	I-Algorithm
using	O
n	O
×	O
n	O
matrices	B-Architecture
.	O
</s>
<s>
This	O
is	O
only	O
an	O
upper	O
bound	O
because	O
not	O
every	O
matrix	B-Architecture
is	O
invertible	O
and	O
thus	O
usable	O
as	O
a	O
key	O
.	O
</s>
<s>
The	O
number	O
of	O
invertible	O
matrices	B-Architecture
can	O
be	O
computed	O
via	O
the	O
Chinese	O
Remainder	O
Theorem	O
.	O
</s>
<s>
I.e.	O
,	O
a	O
matrix	B-Architecture
is	O
invertible	O
modulo	O
26	O
if	O
and	O
only	O
if	O
it	O
is	O
invertible	O
both	O
modulo	O
2	O
and	O
modulo	O
13	O
.	O
</s>
<s>
The	O
number	O
of	O
invertible	O
n	O
×	O
n	O
matrices	B-Architecture
modulo	O
2	O
is	O
equal	O
to	O
the	O
order	O
of	O
the	O
general	O
linear	O
group	O
GL(n,Z2 )	O
.	O
</s>
<s>
Equally	O
,	O
the	O
number	O
of	O
invertible	O
matrices	B-Architecture
modulo	O
13	O
(	O
i.e.	O
</s>
<s>
The	O
number	O
of	O
invertible	O
matrices	B-Architecture
modulo	O
26	O
is	O
the	O
product	O
of	O
those	O
two	O
numbers	O
.	O
</s>
<s>
Additionally	O
it	O
seems	O
to	O
be	O
prudent	O
to	O
avoid	O
too	O
many	O
zeroes	O
in	O
the	O
key	O
matrix	B-Architecture
,	O
since	O
they	O
reduce	O
diffusion	O
.	O
</s>
<s>
The	O
net	O
effect	O
is	O
that	O
the	O
effective	O
keyspace	O
of	O
a	O
basic	O
Hill	B-Algorithm
cipher	I-Algorithm
is	O
about	O
.	O
</s>
<s>
For	O
a	O
5	O
5	O
Hill	B-Algorithm
cipher	I-Algorithm
,	O
that	O
is	O
about	O
114	O
bits	O
.	O
</s>
<s>
When	O
operating	O
on	O
2	O
symbols	O
at	O
once	O
,	O
a	O
Hill	B-Algorithm
cipher	I-Algorithm
offers	O
no	O
particular	O
advantage	O
over	O
Playfair	B-Algorithm
or	O
the	O
bifid	B-Algorithm
cipher	I-Algorithm
,	O
and	O
in	O
fact	O
is	O
weaker	O
than	O
either	O
,	O
and	O
slightly	O
more	O
laborious	O
to	O
operate	O
by	O
pencil-and-paper	O
.	O
</s>
<s>
A	O
Hill	B-Algorithm
cipher	I-Algorithm
of	O
dimension	O
6	O
was	O
implemented	O
mechanically	O
.	O
</s>
<s>
Hill	O
and	O
a	O
partner	O
were	O
awarded	O
a	O
patent	O
(	O
)	O
for	O
this	O
device	O
,	O
which	O
performed	O
a	O
6	O
6	O
matrix	B-Architecture
multiplication	O
modulo	O
26	O
using	O
a	O
system	O
of	O
gears	O
and	O
chains	O
.	O
</s>
<s>
(	O
The	O
much	O
later	O
Even-Mansour	B-Algorithm
cipher	I-Algorithm
also	O
uses	O
an	O
unkeyed	O
diffusive	O
middle	O
step	O
)	O
.	O
</s>
