-
Notifications
You must be signed in to change notification settings - Fork 0
Deck Cipher
A deck cipher is a general implementation of a Group Autokey (GAK) cipher mechanism with a convenient physical interpretation. This is not to be confused with existing ciphers that happen to use decks, like the solitaire cipher, and instead is a specific type of deck-based mechanism, one which produces perfect isomorphs.
Start with a deck of
Next, define a plaintext alphabet, consisting of some number of distinct symbols, e.g. A-Z or A-Z0-9. The plaintext alphabet needs to be less than or equal to the deck size in order for the cipher to be uniquely reversible, and it needs to be strictly less than the deck size if you want to deterministically avoid doubles.
For each letter of the plaintext alphabet, assign a permutation of the deck, or a shuffle, which should be applied when that plaintext letter is used in a message. The only restriction on the shuffles that can be chosen is that starting from an unshuffled state, each plaintext letter needs to bring a unique card to the top of the deck. This is required for reversibility of the cipher. Some kinds of shuffles that can be used include rotations (equivalent to "cutting the deck"), decimations (taking every
To perform encryption of some plaintext message, start with the deck in the initial (unshuffled) state. At each step of encryption, look at the current plaintext letter, and apply the shuffle associated with that letter to the deck. Then use the label on the card that ended up at the top of the deck as the ciphertext output. Keep the deck in this shuffled state (including the card on top that was used for the ciphertext output), and advance to the next plaintext letter, continuing the same process until the entire message is encrypted.
Over the course of encryption, the deck becomes more and more shuffled, scrambling the state in a way that makes it extremely difficult to decrypt without knowing exactly what shuffles were used. If the shuffles are chosen completely arbitrarily, this cipher method ends up being equivalent to a GAK cipher with the underlying group being the symmetric group of all permutations of the cards,
There is something to be said about the massive key space of this cipher. If the shuffles are chosen completely randomly, there are
The good news is that there is considerable evidence that the permutations are not completely random, and there is actually a somewhat simple structure to them. The main evidence for this comes from the shared sections after a differing first character. In a GAK cipher, assuming that first character is actually part of the message, this seems to only be possible if the permutations associated with the plaintext letters in the cipher are all relatively close to each other, in terms of only being a few swaps away from each other from some shared base permutation.