1
$\begingroup$

I'm studying encryption in class and we're doing "One-Time-Pad" encryption and I've come across this situation. I want to code $1100$, where my key is $0110$). In my book it says that the cipher is $1010$ - done through binary addition.

$$1100+0110=1010$$

but how does that make sense. In a $4$-bit system the numbers can only go to $2^4-1=15$ digits. So $1100+0110=10010$ ($12+6=18$). Am I missing something?

$\endgroup$
  • $\begingroup$ Your calculations are correct. Please name and shame the book. $\endgroup$ – Rob Arthan Mar 17 '18 at 0:08
  • 4
    $\begingroup$ One could say you got carried away (try adding without carry) $\endgroup$ – Dan Robertson Mar 17 '18 at 0:27
3
$\begingroup$

The usual encryption for a one-time pad is not addition, but the XOR (exclusive or) operation where you

  1. line up the digits

  2. If they're both one or both zero, they make a zero.

  3. If one is zero and the other is one, they make a one

You can see that this is consistent with what your book has for the answer.

$\endgroup$
  • 1
    $\begingroup$ This is the right answer. I’m not sure I really like saying “digitwise” as it implies that we are working with numbers when (most of the time) we’re actually working with vectors over $\Bbb F_2$. $\endgroup$ – Dan Robertson Mar 17 '18 at 0:16
  • $\begingroup$ @DanRobertson True (I could have been fancier :)) $\endgroup$ – spaceisdarkgreen Mar 17 '18 at 0:18
  • $\begingroup$ I only mention it because it’s obvious that the question came from either confusion about vectors vs numbers or about $+$ vs $\oplus$. $\endgroup$ – Dan Robertson Mar 17 '18 at 0:25
1
$\begingroup$

$$1100+0110=10010$$ is correct and as a result $$1100+0110=1010$$ is wrong.

Notice we are simply adding $$12+6=18$$ and not $$12+6= 10$$

Unless something else is going on instead of simple adding.

$\endgroup$

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.