-1
$\begingroup$

Having confusion. Plaintext = 25, Key=15 and modulus =26. Cipher=(15 + 25) mod 26=14. Now , plaintext = (15-14) mod 26=1

Here I am not getting the plaintext correctly. How to do it?

$\endgroup$
  • 1
    $\begingroup$ Why 15-14? 14-15. $\endgroup$ – Meysam Ghahramani Jul 7 '18 at 19:58
1
$\begingroup$

Let CT be the ciphertext, PT the plaintext, K the key, n the modulus.

Since CT=(PT+K) mod n, PT=(CT-K) mod n. In your case, PT=(14-15) mod 26= -1 mod 26=25, as expected. Remember that for x<0, x mod n= (n+x) mod n (not n-x, as -x would be positive) by definition.

What you did was PT=(K-CT) mod n, which is not true, because this would imply PT=(K-(PT+K)) mod n= -PT mod n, which in general is not true.

For example, 10 mod 26=10, while -10 mod 26=(26-10) mod 26=16, and clearly 10 is not 16.

In fact, this is only true for PT=n/2(and its multiples) because only in that case PT=(n-PT) mod n.

$\endgroup$
  • $\begingroup$ Okay. Understood the solution. So PT=(CT-K) mod N is giving the correct answer. Thank you ☺ $\endgroup$ – Avisek Manna Jul 7 '18 at 18:36
  • $\begingroup$ One more thing, if I use CT=(PT +K1+K2) mod N, then PT=(K2-K1-CT)mod N. Is it correct? $\endgroup$ – Avisek Manna Jul 7 '18 at 18:44
  • $\begingroup$ @avisekmanna No, it's PT=(CT-K1-K2) mod n. First, CT, then the key or keys. Indeed, if you consider K=K1+K2 as a single key, applying the formula I wrote in my answer you have PT=(CT-K) mod n, which is (CT-(K1+K2)) mod n or, equivalently, (CT-K1-K2) mod n. $\endgroup$ – A. Darwin Jul 7 '18 at 18:48

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.