# Trifid Cipher

## Introduction §

The Trifid cipher combines substitution with transposition and fractionation. It was invented by Felix Delastelle. Delastelle was a Frenchman who invented several ciphers including the bifid, trifid, and the four-square ciphers.

Trifid is very similar to Bifid, except that instead of a 5 by 5 keysquare (in bifid) we use a 3 by 3 by 3 key cube.

## The Algorithm §

The key is in the form of 3 squares:

```key = EPSDUCVWYM.ZLKXNBTFGORIJHAQ

square 1   square 2   square 3

1 2 3      1 2 3      1 2 3
1 E P S    1 M . Z    1 F G O
2 D U C    2 L K X    2 R I J
3 V W Y    3 N B T    3 H A Q
```

As an example, we will encipher the text DEFEND THE EAST WALL OF THE CASTLE. The first step means locating the plaintext letters in the squares above, D is in square 1, row 2, column 1, so D becomes 121. In the same manner, E becomes 111. If we write down the numbers corresponding to each letter vertically, it becomes:

```D E F E N D T H E E A S T W A L L O F T H E C A S T L E .
1 1 3 1 2 1 2 3 1 1 3 1 2 1 3 2 2 3 3 2 3 1 1 3 1 2 2 1 2
2 1 1 1 3 2 3 3 1 1 3 1 3 3 3 2 2 1 1 3 3 1 2 3 1 3 2 1 1
1 1 1 1 1 1 3 1 1 1 2 3 3 2 2 1 1 3 1 3 1 1 3 2 3 3 1 1 2
```

At the moment this is still a substitution cipher and fairly easy to break. The next step is to use a 'period', which is a number usually 5 - 20, which is part of the key material agreed on by both sender and receiver. If we take a period of 5,

```DEFEN DTHEE ASTWA LLOFT HECAS TLE.
11312 12311 31213 22332 31131 2212
21113 23311 31333 22113 31231 3211
11111 13111 23322 11313 11323 3112
```

we group the numbers. We now read off the numbers in each group horizontally, and do the substitution back to letters using the original keysquare.

```113122111311111 123112331113111 312133133323322 223322211311313
S  U  E  F  E   C  P  H  S  E   G  Y  Y  J  I   X  I  M  F  O

311313123111323 221232113112
F  O  C  E  J   L  B  S  P
```

Which means DEFEND THE EAST WALL OF THE CASTLE. is enciphered to SUEFE CPHSE GYYJI XIMFO FOCEJ LBSP using the key square above and a period of 5.

Coming soon

## Cryptanalysis §

A good description of cracking the trifid cipher is provided in lecture 17 of the LANIKI Crypto Course Lessons Lecture 17.

## References §

• [1] Wikipedia has a good description of the encryption/decryption process, history and cryptanalysis of this algorithm