Subtracci encryption

© Francisco Ruiz, 2015

This page simplifies the paper-and-pencil Letteracci cipher by F. Ruiz so the Tabula Recta is easier to use, resulting in half the time required for encyption or decryption. The name has changed because the operations that are modular additions in Letteracci have become modular subtractions in Subtracci. Letteracci itself is a simplification of Numeracci so no encoding is used and operations are done directly with letters. All steps can be performed by hand without excessive effort.

We will use a piece of key text the length of the plaintext (after spaces and punctuation are removed), plus one in order to generate a "one-time pad" of sorts by processing the key text through a lagged Fibonacci generator (LFG) so it has better statistical randomness. The key difference between this cipher and the classic running key cipher is that the latter uses less than perfectly random text as keystream and can be attacked by making guesses from a dictionary. As dictionary words, or parts thereof, are obtained when other dictionary words are subtracted from the ciphertext (at different positions in the ciphertext), then both the plaintext and the key text are gradually recovered at the same time. This is not possible with this cipher. In order to provide more resistance against brute force and approach the perfect undecipherability of a one-time pad, a pseudo-Shannon compression can be applied to the key text before it is used to make a keystream; this compression has the effect of using three times as many words from the key text, resulting in a higher entropy.

The process is identical for encryption and decryption. After the plaintext or ciphertext is processed —spaces and punctuation are stripped, and all letters are converted to capitals; accented letters are replaced by their non-accented versions; numbers in plaintext are converted to letters as in 0=A,1=B,...9=J, but are not converted back— a piece of equally processed key text is selected and further randomized by a lagged Fibonacci process, which involves mod 26 subtraction of letters using the standard Tabula Recta below. If a key-derived alphabet is used, rather than the straight alphabet, this operation also involves a substitution of the letters in the second term of the subtraction (the negative one). Finally the plaintext (ciphertext, when decrypting) is subtracted letter by letter from the keystream (and substituted, if the alphabet is not the straight one). Using an alphabet derived from the key text makes the LFG step irreversible and the final ciphertext non-malleable.

Tabula Recta

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
---------------------------------------------------
a | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | a
b | B C D E F G H I J K L M N O P Q R S T U V W X Y Z A | b
c | C D E F G H I J K L M N O P Q R S T U V W X Y Z A B | c
d | D E F G H I J K L M N O P Q R S T U V W X Y Z A B C | d
e | E F G H I J K L M N O P Q R S T U V W X Y Z A B C D | e
f | F G H I J K L M N O P Q R S T U V W X Y Z A B C D E | f
g | G H I J K L M N O P Q R S T U V W X Y Z A B C D E F | g
h | H I J K L M N O P Q R S T U V W X Y Z A B C D E F G | h
i | I J K L M N O P Q R S T U V W X Y Z A B C D E F G H | i
j | J K L M N O P Q R S T U V W X Y Z A B C D E F G H I | j
k | K L M N O P Q R S T U V W X Y Z A B C D E F G H I J | k
l | L M N O P Q R S T U V W X Y Z A B C D E F G H I J K | l
m | M N O P Q R S T U V W X Y Z A B C D E F G H I J K L | m
m | N O P Q R S T U V W X Y Z A B C D E F G H I J K L M | n
o | O P Q R S T U V W X Y Z A B C D E F G H I J K L M N | o
p | P Q R S T U V W X Y Z A B C D E F G H I J K L M N O | p
q | Q R S T U V W X Y Z A B C D E F G H I J K L M N O P | q
r | R S T U V W X Y Z A B C D E F G H I J K L M N O P Q | r
s | S T U V W X Y Z A B C D E F G H I J K L M N O P Q R | s
t | T U V W X Y Z A B C D E F G H I J K L M N O P Q R S | t
u | U V W X Y Z A B C D E F G H I J K L M N O P Q R S T | u
v | V W X Y Z A B C D E F G H I J K L M N O P Q R S T U | v
w | W X Y Z A B C D E F G H I J K L M N O P Q R S T U V | w
x | X Y Z A B C D E F G H I J K L M N O P Q R S T U V W | x
y | Y Z A B C D E F G H I J K L M N O P Q R S T U V W X | y
z | Z A B C D E F G H I J K L M N O P Q R S T U V W X Y | z

To subtract two letters: find the second letter on the top and then go down that column until the first letter is found; then follow that row all the way to the left or to the right to find the result at the edge. Example with straight alphabet: R - H = K (first find H at the top, then go down until R is found, then go left or right to find K).

 

Step 1. Tabula preparation

We begin by making a scrambled alphabet out of the key text, which is placed at the top and the sides of the Tabula Recta. This is why we input the key text before the plain text. The box is blue to indicate that it can be written on. Do this to make a scrambled alphabet: 1, take the first sentence in the key text (up to the first period) and write down new letters in the order they appear; if a letter in the key text has already been written, write instead the first letter before it in the alphabet that is still available (wrap around to the end if needed); 2, then write the rest of the alphabet in reverse order.

When a plaintext is written, the key text is processed in the same way as the plaintext (capitals rather than lowercase) and a piece of it one letter longer than the processed plaintext is taken and placed in the seed box. If it is too short, it will be repeated and a warning will appear below the key text. This key text will be used to encrypt the plaintext (or decrypt the ciphertext), and then it will never be used again.

Key Text

This is where the warning will appear

We first select whether this will be used as-is, or a pseudo-Shannon compression will be applied first. This consists of taking only the first letter from each word, for words containing four or fewer letters, or the first and last, for longer words:

     No compression     Apply compression

Let us also select whether the alphabet that forms the basis of the Tabula Recta will be scrambled according to the key text, or the straight alphabet will be used:

     Key text-derived alphabet     Straight alphabet

 

Step 2. Plaintext preparation

Now the message to be encrypted.

Plaintext / Ciphertext

Which is converted to this, after spaces, punctuation and diacritics are removed, and everything is turned into lowercase:

Processed Plaintext / Ciphertext

 

Step 3. Keystream Generation

The next step is to generate the keystream. In this version, we can enter in the box below the number of rows that the lagged Fibonacci generator will produce. Typically, 3 rows is enough.

LFG rows

Allowed values are 1 to 9.

Because of the non-linearity of the LFG with a key-derived alphabet, it is possible to prepend a random nonce made of letters to the key text in order to reuse the key text. Here is were we optionally enter the nonce, which should never be reused with the same key text. This should not be done when using the straight alphabet.

Nonce (optional, key-derived only)

We begin by taking a piece of the nonce + encoded key text that is one letter longer than the encoded plaintext, which will become the seed for the LFG. If the key text is not long enough, it will be repeated and a warning will appear below the key text box.

Then the key text can be optionally shuffled as it is entered in order to reduce the correlation between consecutive letters. First we must decide the period:

Shuffling Period

(a value of 1 means no shuffling)

And the raw seed taken from the key text:

Raw Seed

We shuffle the raw seed this way, by writing it letter by letter on a grid. Write the first letter at position 1, then the second at position "shuffling period" (if the period is 12, for instance, the second letter is written in the 12th box), then the third the same number of spaces away from the 2nd (24th if the period is 12), and so on until we reach the last position. Then the next one goes at position 2, the next at the position right after the location of the second letter, and so on, starting on the first available box whenever we come back to the beginning, until all boxes are filled. Here is the result, which will be used as seed:

Seed

Now the seed is used to initialize a lagged Fibonacci generator, where each letter after the seed is the difference, using the Tabula Recta, of the previous letter and the one located a number of spaces equal to the encoded plaintext length before the current letter. This is best done by rows, subtracting from the letter immediately to the left of the one we are filling the one above it. We stop when the set number of rows are completed. The process is initialized by putting the seed in row one, except for the last letter, which becomes the first in row two.

And take the last row as the keystream.

Keystream

Information about keystream quality will appear here

 

Step 4. Encrypted Ciphertext / Decrypted Plaintext

We now use the Tabula Recta to subtract and encode letter by letter the processed plaintext (ciphertext, when decrypting) from the keystream, resulting in the ciphertext (plaintext, when decrypting). The lower box contains the same, but split into codegroups of five characters each.

Ciphertext / Plaintext

Formatted output