The question of whether affine ciphers preserve frequency is a pertinent one within the realm of classical cryptography, particularly when examining the principles of modular arithmetic and historical ciphers. To address this question comprehensively, it is essential to understand the mechanics of affine ciphers, their mathematical foundations, and the implications of these mechanics on the frequency distribution of characters in the plaintext.
An affine cipher is a type of monoalphabetic substitution cipher, which means it substitutes each letter in the plaintext with a corresponding letter in the ciphertext based on a fixed system. The general form of the affine cipher can be expressed mathematically using the function:
![]()
where:
–
is the encryption function.
–
is the numerical equivalent of the plaintext letter.
–
and
are keys of the cipher, with
being a multiplicative key and
being an additive key.
–
is the size of the alphabet (for the English alphabet,
).
The decryption function, conversely, is given by:
![]()
where
is the numerical equivalent of the ciphertext letter and
is the modular multiplicative inverse of
modulo
.
To understand whether affine ciphers preserve frequency, consider the nature of monoalphabetic substitution ciphers. These ciphers map each letter of the plaintext to a unique letter of the ciphertext. Therefore, if a particular letter appears frequently in the plaintext, its corresponding letter will appear with the same frequency in the ciphertext. This characteristic is inherent to all monoalphabetic ciphers, including affine ciphers.
For example, if the letter 'E' is the most frequent letter in a given plaintext (as it typically is in English text), and it is encrypted to the letter 'K' using an affine cipher, then 'K' will be the most frequent letter in the ciphertext. The frequency distribution of the letters is thus preserved because the mapping is one-to-one and consistent across the entire text.
To illustrate this with a concrete example, consider an affine cipher with
and
for the English alphabet. The encryption function would be:
![]()
Encrypting a plaintext message "HELLO" (with
):
– ![]()
– ![]()
– ![]()
– ![]()
– ![]()
Thus, "HELLO" encrypts to "RCLLA". If "L" is the most frequent letter in the plaintext, it remains the most frequent letter in the ciphertext.
However, while affine ciphers preserve the frequency of individual letters, they do not preserve the frequency of digraphs (pairs of letters) or larger n-grams. This limitation makes them vulnerable to frequency analysis attacks, a common method used in cryptanalysis. Frequency analysis exploits the fact that certain letters and combinations of letters appear with predictable frequencies in a given language. For instance, in English, the letter 'E' is the most common, followed by 'T', 'A', 'O', 'I', 'N', etc.
To break an affine cipher using frequency analysis, a cryptanalyst would analyze the frequency distribution of the ciphertext and compare it to the known frequency distribution of the plaintext language. By identifying the most common letters in the ciphertext and hypothesizing their plaintext equivalents, the cryptanalyst can derive the keys
and
.
For example, if 'R' is the most frequent letter in the ciphertext and 'E' is the most frequent letter in typical English text, the cryptanalyst might hypothesize that 'R' corresponds to 'E'. Using this hypothesis, the cryptanalyst can set up a system of linear congruences to solve for
and
:
![]()
where
and
are the numerical equivalents of 'E' and 'R', respectively. Solving this system would reveal the keys and allow decryption of the entire message.
While affine ciphers preserve the frequency of individual letters, making them susceptible to frequency analysis attacks, they do not preserve the frequency of letter pairs or larger n-grams. This property limits their security and effectiveness, especially in the context of modern cryptographic standards. Nonetheless, understanding the principles of affine ciphers provides valuable insights into the evolution of cryptographic techniques and the importance of robust encryption methods.
Other recent questions and answers regarding Modular arithmetic and historical ciphers:
- In a shift cipher, are the letters at the end of the alphabet replaced with letters from the beginning of the alphabet according to modular arithmetic?
- Is an exhaustive key search effective against substitution ciphers?
- What does the value K stand for in a shift cipher?
- Is mod K arithmetic used in a shift cipher, where K is the value of the key and denotes the number of shifted letters?
- How many equivalence classes are there in modulo 3 arithmetic?
- Will a shift cipher with a key equal to 4 replace the letter d with the letter h in ciphertext?
- Do identical plaintext map to identical cipher text of a letter frequency analysis attact against a substitution cipher
- Are 7 and 12 equivalent in mode 5 operation
- Are mod 2 addition and subtraction different operations?
- How can an affine cipher be injective?
View more questions and answers in Modular arithmetic and historical ciphers

