Cryptography
Cryptography
Cipher Text: The message we want to send is called the plain text and the disguised
message is called the cipher text.
Message Units: The plain text and cipher text are broken up into message units. A
message unit might be a single letter, a pair of letters (digraph), a triple of letters
(trigraph), or a block of 50 letters.
Enciphering transformation: An enciphering transformation is a function that takes any
plaintext message unit and gives us a ciphertext message unit. In other words, it is a
map 𝑓 from the set P of all possible plaintext message unit to the set 𝐶 of all possible
ciphertext message units. We shall always assume that 𝑓 is a 1-to-1 correspondence.
Deciphering transformation: Deciphering transformation is the map f −1 which goes
back and recovers the plaintext from the ciphertext.
Example 1. Suppose we are using the 26-letter alphabet A-Z with numerical
equivalents 0-25. Let the letter 𝑃 ∈ {0,1, … , 25} stands for a plaintext message unit.
Define a function 𝑓 from the set {0,1, … ,25} to itself by the rule
𝑃 + 3 𝑖𝑓 𝑃 < 23
𝑓 (𝑃 ) = {
𝑃 − 23, 𝑖𝑓 𝑃 ≥ 23.
In other words, 𝑓 simply adds 3 modulo 26: 𝑓(𝑃) ≡ 𝑃 + 3 𝑚𝑜𝑑 26.
To encipher the word “YES” we first convert to numbers 24 4 18, then add 3 modulo
26: 1 7 21, then translate back to letters: “BHV”.
To decipher a message, one subtracts 3 modulo 26. For example, the ciphertext “ZKB”
yields the plaintext “WHY”. This cryptosystem was apparently used in ancient Rome
by Julius Caesar, who supposedly invented by himself.
Shift transformation: This example can be generalized as follows. Suppose we are
using an N-letter alphabet with numerical equivalents 0,1, … , N − 1. Let b be a fixed
integer. By a shift transformation we mean the enciphering function defined by the rule
𝐶 = 𝑓 (𝑃) = 𝑃 + 𝑏 𝑚𝑜𝑑 𝑁. Julius Caesar’s cryptosystem was the case 𝑁 = 26, 𝑏 = 3. To
decipher a ciphertext message unit 𝐶 ∈ {0,1, … , 𝑁 − 1}, we simply compute 𝑃 =
𝑓 −1 (𝐶 ) ≡ 𝐶 − 𝑏 𝑚𝑜𝑑 𝑁.
Cryptanalysis: Now suppose that you are not privy to the enciphering and
deciphering information, but you would nevertheless like to be able to read the coded
messages. This is called breaking the code, and the science of breaking codes is called
cryptanalysis.
In order to break a cryptosystem, one needs two types of information. The first is the
general nature (the structure) of the system. The second type of information is knowledge
of a specific choice of certain parameters connected with the given type of cryptosystem.
Special cases: As a special case of the affine crypto systems, we can set 𝑎 = 1, thereby
obtaining the shift transformation.
Digraph transformation: We now suppose that our plain text and ciphertext message
units are two-letter blocks, called digraphs. This means that the plaintext is split up
into two-letter segments. If the entire plaintext has an odd number of letters, then in
order to obtain a whole number of digraphs we add on an extra letter at the end; we
choose a letter which is not likely to cause confusion, such as a blank if our alphabet
contains a blank, or else "X" or "Q" if we are using just the 26-letter alphabet.
Each digraph is then assigned a numerical equivalent. The simplest way to do this is
to take 𝑥𝑁 + 𝑦, where 𝑥 is the numerical equivalent of the first letter in the digraph, 𝑦
is the numerical equivalent of the second letter in the digraph, and 𝑁 is the number of
letters in the alphabet. Equivalently, we think of a digraph as a 2-digit base 𝑁 integer.
This gives a 1-to-1 correspondence between the set of all digraphs in the 𝑁- letter
alphabet and the set of all nonnegative integers less than 𝑁 2 .
Example: Suppose we are working in the 26-letter alphabet and using the digraph
enciphering transformation C ≡ 159P + 580 mod 676. Then the digraph "NO" has
numerical equivalent 13 ⋅ 26 + 14 = 352 and is taken to the ciphertext digraph 159 ⋅
352 + 580 ≡ 440 mod 676, which is "QY". The digraph "ON" has numerical equivalent
377, and is taken to 359 = "NV". Notice that the digraphs change as a unit, and there
is no relation between the encryption of one digraph and that of another one that has
a letter in common with it or even consists of the same letters in the reverse order.
Example. You know that your adversary is using a cryptosystem with a 27-letter
alphabet, in which the letters A-Z have numerical equivalents 0-25 and blank=26. Each
digraph then corresponds to an integer between 0 and 728 = 272 − 1 according to the
rule that, if the two letters in the digraph have numerical equivalents 𝑥 and 𝑦, then the
digraph has numerical equivalent 27x + y, as explained earlier. Suppose that a study
of a large sample of ciphertext reveals that the most frequently occurring digraphs are
in order “ZA”, “IA”, and “IW”. Suppose that the most common digraphs in the
English language are “E”, “S”, “T”. You know that the cryptosystem uses an affine
enciphering transformation modulo 729. Find the deciphering key, and read the
message “NDXBHO”. Also find the enciphering key.
Solution. We know that plaintexts are enciphered by means of the rule C ≡ aP +
b mod 729, and that ciphertexts can be deciphered by means of the rule P ≡ a′ C +
b′ 𝑚𝑜𝑑 729; here a, b form the enciphering key, and a′ , b′ form the deciphering key. We
first want to find a′ and b′. We know how three digraphs are deciphered, and, after
we replace the digraphs by their numerical equivalents, this gives us the three
congruences:
1 = 145 − 72 ⋅ 2
= 145 − 72(292 − 2 ⋅ 145)
= 145 ⋅ 145 − 72 ⋅ 292
= 145(437 − 292) − 72 ⋅ 292
= 145 ⋅ 437 − 217 ⋅ 292
= 145 ⋅ 437 − 217(729 − 437)
≡ 362 ⋅ 437 𝑚𝑜𝑑 729.
Thus a′ ≡ 362 ⋅ 142 ≡ 374 mod 729, and then b′ ≡ 134 − 675 ⋅ 374 ≡ 647 mod 729.
Now applying the deciphering transformation the digraphs “ND”, “XB” and “HO” of
our message – they correspond to the integers 354, 622 and 203, respectively – we
obtain the integers 365, 724 and 24. Writing 365 = 13 ⋅ 27 + 14, 724 = 26 ⋅ 27 +
22, 24 = 0 ⋅ 27 + 24, we put together the plaintext digraphs into the message “NO
WAY”. Finally, to find the enciphering key we compute a ≡ a′(−1) ≡ 374−1 ≡
614 𝑚𝑜𝑑 729 and b ≡ −a′(−1) 𝑏′ ≡ −614 ⋅ 647 ≡ 47 𝑚𝑜𝑑 729.
Enciphering Matrices.
Suppose we have an N- letter alphabet and want to send digraphs (two-letter blocks)
as our message units. In previous section we saw how we can let each digraph
correspond to an integer considered modulo N 2 , that is, to an element of 𝑍/𝑁 2 𝑍. An
alternate possibility is to let each digraph correspond to a vector, that is, to a pair of
integers (𝑥𝑦) with x and y each considered modulo N. For example, if we’re using the
26-alphabet A − Z with numerical equivalents 0 − 25, respectively, then the digraph
NO corresponds to the vector (13
14
).
Linear Algebra modulo N. The matrix A has an inverse matrix given by the same
formula as in the real case:
−1
A−1 = ( 𝐷 −1𝑑 −𝐷−1 𝑏)
−𝐷 𝑐 𝐷−1 𝑎
𝑎 𝑏
Where A = ( ) and D = ad − bc.
𝑐 𝑑