Bifid Cipher - Description and Cryptanalysis

Cryptography Home Classical Cryptography Classical Cryptanalysis Modern Cryptography Modern Cryptanalysis Latest Updates Links

Back to: [Classical Cryptography and list of ciphers] [Classical Cryptanalysis] [Cryptography Home]

On this page: [Introduction] [Example] [Javascript Example] [Cryptanalysis] [Code] [References]

Introduction

Bifid is a cipher which combines the Polybius square with transposition, and uses fractionation to achieve diffusion. It was invented by F�ix Delastelle. Delastelle was a Frenchman who invented several ciphers including the bifid, trifid, and the four-square ciphers. The first presentation of the bifid appeared in the French Revue du G�ie civil in 1895 under the name of cryptographie nouvelle.
It has never been used by a military or government organisation, only ever by amateur cryptographers.

The Algorithm

Keys for the Bifid cipher usually consist of a 25 letter 'key square'. e.g.
  1 2 3 4 5
1| p h q g m 
2| e a y l n
3| o f d x k
4| r c v s z
5| w b u t i
When enciphering a plaintext, each letter is replaced by the numbers on the left hand side and top of the keysquare. These are then written one on top of the other as shown in step 1. Step 2 shows the new text broken up into blocks of 5 characters (this is known as the period). The period is not especially important, as long as it is agreed upon by both sender and receiver ahead of time. Step 3 shows that the rows are now read (this is the fractionating step that makes bifid slightly more difficult to crack than a simple substitution cipher), with the bottom part of each period being concatenated with the top. The entire string is then re-enciphered using the original keysquare.

An example encryption using the above key:
plaintext:   defend the east wall of the castle
step 1: row  323223 512 2245 5222 33 512 424522
        col  312153 421 1244 1244 12 421 224441
step 2:      32322 35122 24552 22335 12424 522 
             31215 34211 24412 44124 21224 441 
step 3:      3232231215 3512234211 2455224412 2233544124 1242421224 522441
step 4:      f f y h m  k h y c p  l i a s h  a d t r l  h c c h l  b l r
thus 'defendtheeastwallofthecastle' becomes 'ffyhmkhycpliashadtrlhcchlblr' using the key square shown above and a period of 5 during the enciphering step. It is interesting to note that a period of 1 results in no change to the plaintext.

Javascript Example

The keysquare in this example has been written on a single line. To convert to the cube shape, simply write the first 5 characters on the first line, the second 5 characters on the second line etc.
Plaintext

keysquare =

Period =

Ciphertext

Cryptanalysis

Cryptanalysis of bifid is actually fairly difficult. The 'fractionating' nature of the cipher i.e. each letter is substituted by 2 characters, then these characters are jumbled (which will pull them apart) makes the cipher much stronger than substitution ciphers or transposition ciphers on their own.

With computers, however, bifid is not all that secure. A good description of cracking the bifid cipher is provided in "", which is freely available on the net. The following discussion will outline the procedure as described in the paper.

The first step is to determine the period in use.

Code

I have included here some C code that does encryption and decryption of the Bifid cipher. It is only meant to show the working of the algorithm, not be a final polished solution.
Bifid_encrypt.c Bifid_decrypt.c
There is also some code that utilises a markov model to automatically solve a Bifid cipher. Note that very short ciphertexts may not be cryptanalysed properly. The longer the ciphertext the better, several hundred characters ideal.
Bifid_crack.c

References

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

[2] Kahn, D (1973) The CodeBreakers. Macmillan: New York

Choose your way out: [Classical Cryptography and list of ciphers] [Classical Cryptanalysis] [Cryptography Home]
[Modern Cryptography] [Modern Cryptanalysis]

Copyright James Lyons - 2007 - No reproduction without permission
dsplabslinuxkamilcryptojames