Thinking About Encryption, Part 52


Two-Square
6×6 Two-Square

Hmm. #52 of this series looking at cipher types and how the ACA uses them. At one entry per week, that means I’ve been at this for something over 3 days, with no one ever leaving comments here. Maybe that means something.

I’ve written about Four-Square before, and I was really thinking that Two-Square would be a natural follow-up, in that it’s in the same family (along with Three-Square), and that the fewer number of squares would make it easier to crack.

In Four-Square, you have four 5×5 squares, labelled PT1, PT2, CT2 and CT2. PT1 and PT2 are both filled in with unkeyed alphabets (skipping “J”), and CT1 and CT2 both have keyed alphabets that can be written in rows or columns. You take the plaintext message in pairs of letters, and locate them in the PT1 and PT2 tables to form the opposite corners of a rectangle. The two ciphertext letters are taken from the other corners as CT1 then CT2. If the keys are “KEY” (CT1) and “WORD” (CT2), we get (top from left – PT1 and CT1; bottom from left – CT2 and PT1):

ABCDE | KEYAB
FGHIK | CDFGH
LMNOP | ILMNO
QRSTU | PQRST
VWXYZ | UVWXZ
-------------
WBHNU | ABCDE
OCIPV | FGHIK
REKQX | LMNOP
DFLSY | QRSTU
AGMTZ | VWXYZ

If the plaintext message starts with “THIS”, then “TH” becomes “RP” and “IS” becomes “FS” (taking CT1 then CT2).

Cracking Four-Square requires creating a filter based on the letter patterns of the crib, and matching the filter up with a section of the cipher message that has similar letter patterns. One thing that generally helps make this process a little easier is that the keyed alphabets are usually predictable in that the last 1-2 rows (or columns) of letters tend to come from the set “QRSTUVWXYZ”, assuming that “RST” are not in the keyword.

Ok, Two-Square is similar in that both squares use keyed 25-letter alphabets. Where it gets crazy-hard is that the alphabets can be entered into the squares in any order allowed by the Route Transposition Cipher. Recall that Route uses a rectangular box and the message can be written in rows, columns, alternating rows or columns, diagonals, alternating diagonals, or spirals, and that the rectangle can be horizontally and/or vertically flipped. The text is then pulled off in whatever way you want, but that last step is not important here for Two-Square. So, assuming that the keys are “KEY” and “WORD” again, but that we’ll fill in square 1 with alternating rows and square 2 in a spiral:

KEYAB | WORDA
HGFDC | NPQSB
ILMNO | MYZTC
TSRQP | LXVUE
UVWXZ | KIHGF

Now, “TH” “IS” becomes “VU” and “TH”. The plaintext pairs are placed as square 1 then square 2, and taken off as square 2 then square 1. If they are on the same row, such as “IT”, then they are simply reversed (i.g. – “TI”).

This latter point, of the letters inverting if they’re on the same row is one of Two-Square’s biggest weaknesses, since it can be expected to occur perhaps 20% of the time (depending on the plaintext message).

Decrypting a message is just the reverse process. Take your key words, use them to build up the key alphabets. Write the alphabets into the two squares as required. Then take the message in two-letter pairs, placing them in square 2, square 1 order, and reading off the plaintext as square 1, square 2.

Solving Two-Square, if you have a crib, is a matter of writing the crib out as pairs (twice, once for each possible shift of the first letter), and looking for repeating letter pairs. If the crib is “THISCRIBISTHICK”:

"TH IS CR IB IS TH IC K?"
"?T HI SC RI BI ST HI CK"

In the first line, with 0 offset, “TH” appears at relative positions 0 and 10, and “IS” at 2 and 8. If the ciphertext has repetitions at similar spacings, that’s probably where the crib goes. Otherwise, look at the second line, with 1 offset, and “HI” appearing at relative positions 1 and 11.

As additional confirmation, or if the crib lacks this kind of pattern, look for places where the letters are flipped (i.e. – “CR” and “RC”, or “CI” and “IC”.

TS HY KW SS VW LM RC LU VL BA CI ML KA
.. .. .. .. TH IS CR IB IS TH IC K

Ok, this was the easy part. Next, we want to recreate the key alphabet squares. Say we have a cipher message that reads:

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR

And, we’re told that the crib is: “found a friend”. First, we want to place the crib.

FO UN DA FR IE ND
or:
?F OU ND AF RI EN D?

While there are no repeat patterns in either string, there are two reversed pairs that match up with the second string (“?F OU ND AF RI EN D?”):

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .F


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN D. .. .. .. .. .. .. .. .. .. ..

OU = UO and RI = IR. Promisingly, we also have FE = ?F, but we can leave that lead for later. Right now, we’re looking for pair combinations that have the most letters in common with the other pairs throughout the crib. The first really good candidate is EC = ND. We start by creating a little grid, with P1 (plaintext letter 1) on the left, P2 on the right one line down, C1 (ciphertext letter 1) on the right directly above P2, and C2 on the left, directly below P1, as follows:

N | E
C | D

If we follow the rules for encryption, ND creates a rectangle with EC at the opposing corners. The next pair should be EX = EN. Here, the letters EN don’t align with anything we have in the table, so we put them on a new row and a new column. But for EX, the “E” matches the “E” on the right side of the divider, so P1 will be on the same row as C1 E, C2 will be below P1, and P2 will be on the same line as C2, directly under C1. Like this:

EN | E
.C | D
X. | N

If we look at DS = D?, and compare that with EX = EN, we don’t really know what the unknown character “?” could be. But for FE = ?F, it’s guaranteed that we have a mirror flip. In order for P1 to be F and C2 to be the same letter, P2 and C1 also have to be the same, meaning that FE = EF.

EN | EF
.C | D
X. | N

This is as far as we can go with the table, so let’s see if we can add to the plaintext.

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
.. .. .. EE .. .. .. .. .. .. .. .. ND .. .. EF


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN D. .. .. .. .. .. .. .. .. .. ..

Obviously, I wrote this message, so I can claim some kind of magic knowledge and wave my hands here. But, that “ND” does show up in “FOUND” as well as “FRIEND”, or it could be part of “AND”. However, if we look at “EC HI WY FE”, there’s a chance that “HI” is a mirror flip, which could give us “IH ?? EF”. “I HAVE FOUND A FRIEND” is not too outrageous a leap, so let’s try it.

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
.. .. .. EE .. .. .. .. .. .. .. .. ND IH AV EF


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN D. .. .. .. .. .. .. .. .. .. ..

Unfortunately, it doesn’t give us anything to work with table-wise. “BN EC” = “?A ND” is a deadend, too. There’s nothing to lose by trying to plug in “FRIEND”.

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
.. .. .. EE .. .. .. .. .. .. FR IE ND IH AV EF


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN D. .. .. .. .. .. .. .. .. .. ..

This at least gives us BN = IE, and that fits in with what we already have in the table.

.EN | EF
..C | D
.X. | N
..I | BH


HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
IH AV E. EE .. .. .. .. .. .. FR IE ND IH AV EF


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN D. .. .. .. .. .. .. .. .. .. ..

And, we just repeat the process. Since my goal is to recreate the table, I’ll just fill in the rest of the plaintext.

HI WY EK EE FW CD BQ FC OF PW TT BN EC HI WY FE
IH AV EB EE NL OO KI NG FO RA FR IE ND IH AV EF


UO EC GY IR EX DS CW OD SF BO OD XF TM SO FC YR
OU ND AF RI EN DI NA DO GT HE DO GW AS HU NG RY


YEN | EF
A.C | DG
.X. | N
.KI | BH
..W | .LA
.Q. | I
..R | ..P

Running from IH = HI to AF = GY, I get the above table. Note that are 7 rows, but there are a couple gaps in two of the rows that could be merged down. Specifically, rows 5 and 7 could merge into either rows 3 or 6. However, the next solved letter pair, RI = IR, is going to force the merger of row 7 into 6.

YEN | EF
A.C | DG
.X. | N
.KI | BH
..W | .LA
.QR | I.P

And that means row 5 merges into 3.

YEN | EF
A.C | DG
.XW | NLA
.KI | BH
.QR | I.P

Going through the entire CON, I get the below assignments.

.OYEN | EFC.U.V
FDA.C | DGO.T.W
...XW | NLA
GHMKI | BH..S.X
.S.QR | I.P..Y
T.... | ....R

It looks like, based on the right-hand column of the right-hand side that Square 2 is in columns. However, the left-hand column of Square 2 is running the opposite direction. So, maybe Square 2 was filled in alternating columns. It’s too early to say anything much about Square 1. But, Square 2 columns 6 and 7 can be merged, and the rows reordered.

.OYEN | EFCUV
FDA.C | DGOTW
GHMKI | BH.SX
T.... | ...R
.S.QR | I.P.Y
...XW | NLA

Rows 4 and 5 can be merged. We can guess that “QZ” can go at the right end of the last row.

.OYEN | EFCUV
FDA.C | DGOTW
GHMKI | BH.SX
TS.QR | I.PRY
...XW | NLAQZ

Square 2 columns 4 and 5 are in the correct locations, and it looks like columns 1 and 2 are also matched (B, D, E, F, G, H). Column 3 seems to be out of place, so let’s move that to column 1 and see what happens.

.OYEN | CEFUV
FDA.C | ODGTW
GHMKI | .BHSX
TS.QR | PI.RY
...XW | ANLQZ

The letters missing from Square 2 are J, K and M. Two-Square doesn’t use J, and anagraming the letters COPANIMK might give COMPANI-something (actually, COMPANION). Fill those in. Then, looking at rows 2 and 3 of Square 1 shows that that’s been filled in alternating rows.

LONEY | CEFUV
FDCBA | ODGTW
GHIKM | MBHSX
TSRQP | PIKRY
UVWXZ | ANLQZ

The keys are “LONELY” and “COMPANION.”

===============

Closely related to the above cipher-type is 6×6 Two-Square. The unkeyed alphabet for 6×6 is “a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwxyz”.

This took me a while to figure out, but when you write in the keyword, you do so in letter+digit pairs. That is, if you want a keyed alphabet using the word “Derby,” in rows, you get:

D4E5RB
2YA1C3
F6G7H8
I9J0KL
MNOPQS
TUVWXZ

The larger table does make it a little harder to recover the plaintext from the cipher, but the letter+digit pairs are an almost immediate giveaway for how the keyed alphabets were entered in the squares.

I went through 15 year’s worth of Cm newsletter archives (2001-2015), with about 30 Two-Square, and five 6×6 Two Square, ciphers. The regular CONs showed a fairly even mix of routes (rows, columns, diagonals, spirals, alternations and mirror flips). The 6×6’s were largely on-by-rows and on-by-columns. But, out of 90 total issues, Two-Square isn’t one of the more popular, or consistent cipher types. I’ve written an encipher script, and a print-out script when given the solution keys. But, I haven’t bothered tackling a full solver yet. I’ve tried using Bion’s Two-Square gadget, but that’s clunky when I need to have several extra scratchpad rows and columns to work with. Instead, I’m still at the pencil and paper point. We’ll see if I ever get to writing up something a little more useful.

Summary:
1) Two-Square is a two-alphabet substitution cipher-type, in the same family as Three- and Four-Square.
2) Both squares use 25-letter keyed alphabets (minus the J), filled in any way legal within the Route Transposition cipher.
3) The plaintext is taken in pairs. The first letter goes into square 1, and the second into square 2, to form the opposite corners of a rectangle. The cipher pair is read off as square 2/square 1 from the other two corners.
4) If the plaintext pair is on the same row, just flip the order for the cipher pair (i.e. – “RI” = “IR”).
5) Decrypt the cipher by reversing the process.
6) Solving Two-Square involves placing a crib, if any, by looking for pair repetitions in the plaintext crib, and the shifted plaintext crib, then aligning those repetitions with repetitions of the same spacing in the ciphertext. If there are no repetitions in the crib, then look for letter pair inversions (i.e. – “RI”/”IR”).
7) Use the crib-to-ciphertext match-ups to reconstruct the squares.
8) When adding new letters to the squares, put them on new rows or columns. When you have enough information to confirm that two rows or columns are actually the same, merge the entire row or column.
9) Use alphabet ordering to identify the route used to fill the table. If enough information exists, you can use the reconstructed table to further solve the plaintext.
10) 6×6 Two-Square uses the alphabet: “a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwxyz”.
11) The letter+digit pairs (a-1, b-2…) can be used to fill in the keyed squares, which is a useful clue for reconstructing the squares later.
12) For me, Two-Square is actually harder to solve than Four-Square. And, I think Four-Square is difficult.

Previous Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: