6
$\begingroup$

Considering the English alphabets to be encrypted why is the computation of mod 26 necessary after adding the pad to plain text. Is it just that it adds to another level of encryption or is it used so that two letters may end up with the same symbol in the cypher? 3 mod 26 is 3 and 29 mod 26 is 3.

$\endgroup$
4
  • 8
    $\begingroup$ Hints: (1) with mod used, and then not used, ask yourself the following: what is the highest possible ciphertext value? When would it occur? Would an adversary noticing that value in the ciphertext learn something about the plaintext? (2) Dig deeper: assume plaintext consisting of random independent characters, and a random pad: how much information (in bit or fraction thereof per plaintext character) is learned from the plaintext with mod used, and not used? $\endgroup$
    – fgrieu
    Aug 15 at 9:52
  • 1
    $\begingroup$ No two letters end up with the same symbol. Think of it like the alphabet repeats after 25. So 26 would be "a" again. 3 and 29 correspont to the same letter. Mod just makes the number smaller, so you only need 0 to 25 $\endgroup$
    – jjj
    Aug 16 at 12:34
  • $\begingroup$ Am I the only one whose first use of One Time Pad used five digit numbers with the numbers being nowhere close to either end? If it was random Gaussian rather than random uniform it leaks very little information. $\endgroup$
    – Joshua
    Aug 16 at 16:58
  • $\begingroup$ @Joshua No, you can't have a Gaussian OTP key. Unless you're missing the randomness extractor from your TRNG $\endgroup$
    – Paul Uszak
    Aug 16 at 20:48
21
$\begingroup$

There are two main reasons.

First, when we encrypt data with a symmetric algorithm, we generally want each unit to encrypt or decrypt to a unit of the same size (ignoring padding and MACs). In your case, when we're using English letters, we'd want to also get English letters out, and not a set of random numbers. Similarly, when we're encrypting a byte, we also want to get a byte out, since computers usually work with bytes and it's most convenient to process them that way.

Secondly, and more important, not using modular arithmetic here leaks information, sometimes a lot of information, about the data. For example, if we're using the range 0-25 to represent our letters, if we see a 0 as the encrypted output, we know that both the pad and the input were 0, and if we see 50, we know that both the pad and the input were 25. Similarly, 49 tells us that the two numbers involved were 24 and 25 in some order. With that type of information and statistical analysis, we can probably decrypt the ciphertext.

However, if we used modular arithmetic, then the output value doesn't teach us anything about the pad or the input, since every output value is equally likely. If the pad is truly random and used only once, then it provides perfect confidentiality.

$\endgroup$
14
  • 1
    $\begingroup$ "we can probably decrypt the ciphertext": assuming English without space, I think that's going to be challenging. Studying when that can be done is actually an interesting problem! $\endgroup$
    – fgrieu
    Aug 16 at 7:45
  • 1
    $\begingroup$ @fgrieu Challenging, but not necessarily impossible. $\endgroup$
    – user253751
    Aug 16 at 8:50
  • 1
    $\begingroup$ @user253751 With a random key stream I would say that a ciphertext only attack which succeeds in recovering the plaintext is typically impossible. What you can do is rule out some candidate plaintexts, so it definitely leaks information, but not generally enough for a complete break. For some shorter messages there might be enough information for a lucky guess, especially if there is some prior information about the likely content of the plaintext. $\endgroup$ Aug 16 at 11:46
  • 2
    $\begingroup$ @dan04 I'm going to assume it's not "congratulations, dramatic illustration, milfhunter privileges" (yes "milfhunter" seriously appears in google's 10k word list). But "congratulations" is a very likely starting word given the context, and "dramatic-" is also reasonably likely. Long words are much more likely to be guessed correctly because there are more constraints on them. Of course, it could just be a coincidence that "congratulations" fits. I did not try smaller words such as "congratulations, you have" or "congratulations, this is" $\endgroup$
    – user253751
    Aug 17 at 11:31
  • 2
    $\begingroup$ @dan04 "dramatic illustration, milfhunter privileges" is such a combination :P $\endgroup$
    – user253751
    Aug 18 at 8:15
19
$\begingroup$

Not using modulus leaks information.

For the English language, it's not so obvious. For an image, on the other hand...

what appears to be random noise on the left, and a noisy yet clearly identifiable tux on the right

Left half uses addition and modulus, right half uses addition and division by two (i.e. half brightness).

$\endgroup$
3
  • $\begingroup$ Not sure that young TUX is an appropriate example (re. OTPs), as uneven character values can't be divided into integers. So of course you've rounded your RBG values (integers). You really need a completely different algorithm/character/key mapping. Which then wouldn't be uniformly random, but rather a group of some sort. $\endgroup$
    – Paul Uszak
    Aug 17 at 23:12
  • 4
    $\begingroup$ @PaulUszak: To be technically correct, the output format would need to support RGB values in the range [0, 510], and use lossless compression. The image is just being approximated here because of technical restrictions. Point is, if you “encrypt” a raster image and get something that's easily recognizable to the human eye (albeit with random “noise”), then you have a really bad encryption algorithm. $\endgroup$
    – dan04
    Aug 17 at 23:48
  • $\begingroup$ @PaulUszak It's certainly possible to produce a 9-bit lossless image without division and rounding, but even if you have a monitor capable of displaying it, it won't change the conclusion. $\endgroup$
    – Fax
    Sep 30 at 15:28
3
$\begingroup$

It's not.

Encryption/decryption can be done in anyway you can think of. Maths isn't needed at all. All it represents is a 1:1 mapping (bijection) between the message and cipher text. The only important thing is that the key material is generated through a truly random (physical) process. It's just that either a modulo operation or XOR makes it simpler for a computer implementation.

This is encryption/decryption without maths using a reciprocal DIANA table:-

table

Also realise that there are more than 26 characters in cryptography. There are numbers, punctuation (very important as it can change the meaning of a sentence when declaring war on someone). Then there are enumerated codewords, like 73 (meaning something to someone). From the wiki page: " The JN-25 code used in World War II used a code book of 30,000 code groups superencrypted with 30,000 random additives. ". You might heretofore perform the mapping modulo 10, on a digit by digit basis.

$\endgroup$
3
  • 4
    $\begingroup$ The question reads: "why is the computation of mod 26 necessary after adding the pad to plain text". Your post is certainly interesting, but it doesn't answer the question. The second part of your answer is also at odds with the assumption in the first line of the question: "Considering the English alphabets to be encrypted" $\endgroup$
    – Maarten Bodewes
    Aug 15 at 13:45
  • 1
    $\begingroup$ and if you look into how the table is generated, you see e.g. under column N the two entries Ma and Nz next to each other. That tells of modular arithmetic. $\endgroup$
    – ilkkachu
    Aug 16 at 10:30
  • $\begingroup$ @MaartenBodewes My answer is correct because the question is moot. We can do "A/9" $\to$ 🙂 which only involves friendship, and no maths. $\endgroup$
    – Paul Uszak
    Aug 19 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.