CONDI key algorithm

Here's a computer algorithm for calculating CONDI cipher keys when you have found a long string of plaintext.

Example

NPM TLE WBQ NNMMIBR GJXIFI YL TPRCZROZDSOAU

fbi for the federal bureau of investigation

You might have decoded the above ciphertext, getting the plaintext written below it.

It’s enough to solve for the key.

Key finding: basic idea

The basic idea is to loop through all possible pairs of plaintext letters, trying each pair at all possible key positions and finding those pairs and positions that can be extended to a complete key.

To generate new key positions from old ones you use the Basic Equation:

(key position of plaintext letter)+(key position of adjacent plaintext letter) = key position of corresponding ciphertext letter.

Using the plaintext in the second paragraph above, example equations are:

(key position of 'f')+(key position of 'b') = key position of 'p'.

(key position of 'b')+(key position of 'i') = key position of 'm'.

If you know any two of the positions in the Basic Equation, you can solve for the third position by simple addition or subtraction. (Since the key positions have to be between 1 and 26 you have to do the arithmetic 'MOD 26'. That is if the addition is more than 26 you subtract 26, or if the subtraction is less than 1 you add 26. )

Pseudo-code

The main loop in pseudo-code is:

for L1 for 1 to 25 (L1 represents a letter between A and Y)   

   for L2 from L1+1 to 26 (L2 represents a letter between L1's successor and Z)

       for key position p1 from 1 to 26

           for key position p2 from 1 to 26

               if p2 equals p1 skip to next p2

               call Key Extension Routine for L1, L2, p1, p2 (pseudo-code below)

               if Routine returns SUCCESS message

                   print completed key and exit program

                   

Key Extension Routine pseudo code:

(check if letter L1 at key position p1 and letter L2 at key position p2 generates a complete key)

set all key positions to empty.

put L1 in key position p1

put L2 in key position p2

To get loop started set change flag to true

(main loop follows)

WHILE change flag is true

   set change flag to false

   for each pair pl1 and pl2 of adjacent plaintext letters and corresponding

ciphertext letter cl

       Are pl1, pl2 and cl already in the key?

           If yes, check if position(pl1)+position(pl2) is equal to position(cl).

               If not equal, then key is inconsistent

                   send INCONSISTENT message and exit routine.

       Are pl1 and pl2 in the key, but cl not yet in the key?

           if yes,

               put cl in the key at the position equal to position(pl1)+position(pl2)

               set change flag to true

       Are pl2 and cl in the key but pl1 not yet in the key?

           if yes,

               put pl1 in the key at the position equal to position(cl)-position(pl2)

               set change flag to true

       Are pl1 and cl in the key but pl2 not yet in the key?

           if yes,

               put pl2 in the key at the position equal to position(cl)-position(pl1)

               set change flag to true

(end main loop)

Does the filled-in key contain two different letters at the same position?

   If yes, key is not 1-1

       send NOT 1-1 message and exit routine.

Does the key contain enough filled-in letters? (26 or 25 for complete key)?

   if no, key doesn't have enough letters.

       send NOT ENOUGH LETTERS message and exit routine.

(OK, key is consistent and has enough letters)

send SUCCESS message, send completed key, and exit routine.

(end pseudo-code)

       

Equivalent keys

A CONDI cipher always has 12 equivalent keys. (See my article "Finding CONDI cipher keys" in the March-April 2015 issue of the Cryptogram magazine.) Given one of the keys all of the others can be found by taking "right-to-left decimations" of the known key. See solved example below.

Solved example

For the example ciphertext and plaintext in second paragraph above, the key finding program outputs:        

Keys that passed checks using starting letters a and i

idqrjhugzlxscnpvftoa-webmy

Solutions = 1. Error types: not enough letters = 0, inconsistent = 49, not 1-1 = 0

Equivalent Keys:

idqrjhugzlxscnpvftoa-webmy

qhzspt-birulcvowmdjgxnfaey

jlpamrznobqgctedusfwihxv-y

un-dzverxtmhcaigpwqlfbjsoy

ztilodxaqs-rcwjnehpbuvmgfy

xwutqnml-hfdcbzajvisegorpy

progesivjazbcdfh-lmnqtuwxy <========= key phrase, "progressive jazz"

fgmvubphenjwcr-sqaxdolitzy

osjbflqwpgiachmtxrevzd-nuy

-vxhiwfsudetcgqbonzrmapljy

eafnxgjdmwovclurib-tpszhqy

mbew-aotfvpncsxlzguhjrqdiy