Foursquare Tutorial

Introduction

The Foursquare cipher is a digraphic substitution cipher similar to the Playfair. Unlike the Playfair cipher, which is based on a single Polybius square, Foursquare uses 4 Polybius squares arranged into a single large square. The four squares are labeled from 1 to 4 starting in the upper left and proceeding clockwise. Squares 1 and 3 contain unkeyed plaintext alphabets placed in the normal order. Squares 2 and 4 are keyed ciphertext alphabets and may be placed in the squares in any of the usual ways.

Message encipherment proceeds much like Playfair. The plain text message is broken up into digraphs. Unlike Playfair, double letter digraphs are acceptable and the introduction of nulls is not necessary. To encipher each plain text digraph, the first and second letters are located in squares 1 and 3 respectively. These cells are considered to be the opposite corners of a rectangle. The remaining corners of this rectangle are located and read off from squares 2 and 4 to obtain the first and second letters respectively of the ciphertext digraph. Deciphering is the inverse of the encipherment process.

Consider the following example

  • Msg: The early bird gets the worm.
  • Keywords: ROBIN, BLUEBIRD

Key Square:

a b c d e:R A G P V
f g h i k:O C H Q W
l m n o p:B D K S X
q r s t u:I E L T Y
v w x y z:N F M U Z
- - - - -:- - - - -
B L U E I:a b c d e
R D A C F:f g h i k
G H K M N:l m n o p
O P Q S T:q r s t u
V W X Y Z:v w x y z
pt: th ee ar ly bi rd ge ts th ew or mx
CT: LC VI AO SV PD TL WL LS LC AZ DS KW

Note that the keyed ciphertext in alphabets 2 and 4 were placed in the squares by two different methods. Further, the plaintext digraph ‘ee’ did not require a null separator as is necessary in Playfair. If you are not familiar with the Foursquare cipher, study this example. The cryptanalysis of this cipher type requires a good working knowledge of the substitution scheme.

Example

The example we will be working on is JF04 E-23:

E-23. Foursquare. Funny money. (within our means) KOSTY

DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
CT QD FD KS NZ QS NS OT.

We are given the plain text crib ‘within our means’. As with Playfair we break this crib up into digraphs in the two possible ways and see if there are any repeat digraphs. If repeats exist, we would look in the ciphertext for a similar pattern to allow us to place the crib. In this case, the digraphic breakdowns provide:

1: wi th in ou rm ea ns
2: *w it hi no ur me an s*

Note that neither of the breakdowns contains repeated digraphs! What is a poor Cryptanalyst to do?

In cases like this, it becomes necessary to independently look for patterns within the first and second letters of the digraphs. This method was demonstrated by LIONEL at the 2002 East Coast mini-con and is called “The Method of Isomorphism”!

Essentially, this involves assuming any desired alphabet for squares 2 and 4 (Remember, squares 1 and 3 are always the same). This trial key square will be used to encipher the crib. The ciphertext, which results from the use of this trial key square, will not be correct. However, because the alphabets in squares 1 and 3 are fixed, any patterns we find in either the first letters or the second letters of these trial cipher digraphs must exist in the real CON. Let’s try this method with the following trial key square:

a b c d e:A B C D E
f g h i k:F G H I K
l m n o p:L M N O P
q r s t u:Q R S T U
v w x y z:V W X Y Z
- - - - -:- - - - -
A B C D E:a b c d e
F G H I K:f g h i k
L M N O P:l m n o p
Q R S T U:q r s t u
V W X Y Z:v w x y z
pt1: wi th in ou rm ea ns
 CT: YG SI HO PT RM AE NS

pt2: it hi no ur me an 
 CT: IT IH ON RU PB CL

Notice that the first trial encipherment contains no repeats of either the first or second letters of the cipher digraphs. However, the second breakdown does provide a pattern. The first letter of the first and second digraph is the same. We search through the CON and find this pattern at two locations:

Digraph 31: OT OL PM EY VI GA 
Digraph 44: CP CT QD FD KS NZ 

Note that digraph 44 can not be the position of our plain string crib. The third and fourth digraphs at this position have identical second letters. This pattern did not show up in our trial encipherment of the crib. Therefore, our crib can not be placed there. This leaves only digraph 33 as a possible position for our crib. We will adopt this as our working hypothesis.

Our crib provides:

pt: it hi no ur me an 
CT: OT OL PM EY VI GA

Substitution of these equivalencies into the key square provides:

a b c d e:* * G * *
f g h i k:* * * O *
l m n o p:* * * P V
q r s t u:* E * * *
v w x y z:* * * * *
- - - - -:- - - - -
* I * * *:a b c d e
* * L * *:f g h i k
A * M * *:l m n o p
* * * T Y:q r s t u
* * * * *:v w x y z
DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
** ** ** ** ** ds ** ** ** ** ** ** ** ou ch ** ** ** ** ** ** **

CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
** ** ** ** an ** ** ** it hi no ur me an ** ** ni ** ** ** ** **

CT QD FD KS NZ QS NS OT
** ** ** ** ** ** ** it 

Note the positions of L, M, T, and Y in square 4. This suggests that the keyword is written into this square in vertical columns. The gap between M and T suggests only one of the intervening letters is in the keyword. The gap between T and Y is exact. This allows us to fill in the letters from T to Z in square 4. This provides:

a b c d e:* * G * *
f g h i k:* * * O *
l m n o p:* * * P V
q r s t u:* E * * *
v w x y z:* * * * *
- - - - -:- - - - -
* I * * V:a b c d e
* * L * W:f g h i k
A * M * X:l m n o p
* * * T Y:q r s t u
* * * U Z:v w x y z
DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
** ** ** ** ** ds ug ** ** ** ** ** ** ou ch ** ** ** ** ** ** **

CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
** eh ** py an ** ** ** it hi no ur me an ** ** ni ** eh ** ** **

CT QD FD KS NZ QS NS OT
** ** ** ** ** ** ** it 

Examining the partial plain text, the fragment ‘ds ug’ suggests the word ‘suggest’. Further, the fragment ‘eh ** py’ suggests ‘happy’. This will provide ge = UI, ap = TA, and st = QN. Substituting these equivalencies provides:

a b c d e:* * G * T
f g h i k:* * * O U
l m n o p:* * * P V
q r s t u:* E * Q *
v w x y z:* * * * *
- - - - -:- - - - -
* I * * V:a b c d e
* * L * W:f g h i k
A * M * X:l m n o p
* * N T Y:q r s t u
* * * U Z:v w x y z
DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
** ** ** ** ** ds ug ge st ** ** ** ** ou ch ** hu ** ** ** ** **

CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
** eh ap py an ** ** ** it hi no ur me an ** ** ni ** eh ** ** **

CT QD FD KS NZ QS NS OT
** ** ** ** ** ** ** it

Note how well the last substitutions fit into the key square. This provides us with confidence we are on the right track. Examining our crib and the second line of the CON suggests the partial text ‘happy and live within our means’. This will provide dl = WS, iv = IU, and ew = DZ. Substituting these equivalencies provides:

a b c d e:W D G * T
f g h i k:I * * O U
l m n o p:* * * P V
q r s t u:* E * Q *
v w x y z:* * * * *
- - - - -:- - - - -
* I * * V:a b c d e
* * L * W:f g h i k
A * M S X:l m n o p
* * N T Y:q r s t u
* * * U Z:v w x y z
DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
** ** ** ** ** ds ug ge st ** ** ** ** ou ch ** hu ** ** ** ** al

CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
** eh ap py an dl iv ew it hi no ur me an ** ** ni ** eh ** ** **

CT QD FD KS NZ QS NS OT
** ** ** ** ** to ** it

Again, note how well the last substitutions fit into the key square. Now, note the positions of E, G, and O in square 2. As with square 4, this suggests that the keyword has been written into this square in vertical columns. Further, now that the letter I has been placed, the position of the remaining unplaced letters between E and O is apparent. Making this substitution provides:

a b c d e:W D G N T
f g h i k:I * H O U
l m n o p:* * K P V
q r s t u:* E L Q *
v w x y z:* F M * *
- - - - -:- - - - -
* I * * V:a b c d e
* * L * W:f g h i k
A * M S X:l m n o p
* * N T Y:q r s t u
* * * U Z:v w x y z
DK XP VF EO DK GT EW UI QN NV SB LQ NK VT GL ZQ UN PD AD NY LY WA
** ** ** ** ** ds ug ge st ed ** ** ** ou ch ** hu ** ** et us al

CC GW TA PZ GA WS IU DZ OT OL PM EY VI GA XH YC PL BE GW WE NY CP
** eh ap py an dl iv ew it hi no ur me an ** ** ni ** eh ** et **

CT QD FD KS NZ QS NS OT
** ** ** on ey to do it

At this point, several more words and phrases become apparent. You should be able to finish this example on your own.