Key-space for a restricted substitution cipher

262 Views Asked by At

How can one calculate the key-space for a restricted substitution cipher? A restricted substitution cipher is one where no letter is assigned to itself. For an alphabet with 26 letters how many keys are there for a restricted substitution cipher? What is the correct way to approach this question? I have been adviced to look into cycle notations, Markov chains and the structure of the symmetric group and its conjugacy classes.

1

There are 1 best solutions below

2
On

A key for a substitution cipher on an alphabet $A$, is just a permutation of $A$ so there are $a!$ many keys in total (setting $a = |A|$, the size of the alphabet). With the restriction that no letter is mapped to itself we get that a key must be a so-called derangement.

As the linked page explains, the number of those on an alphabet of size $a$ is

$$a!\sum_{i=0}^a \frac{(-1)^i}{i!} \approx \lfloor \frac{a!}{e}\rfloor $$

so has the same order of size as $a!$.

For a $26$ letter alphabet the full key space size is $403291461126605635584000000$ and the restricted size is $148362637348470135821287825$ according to Wolfram alpha.