Suppose I have two sequences of binary bits m1 and m2, and an accompanying 'key string' K of bits with all three the same length.
Then if I define c1 and c2 as:
c1 = (m1 XOR K)
c2 = (m2 XOR K)
I find that
c1 XOR c2 = m1 XOR m2
Informally, I have found by trial and error that the XOR's with K are canceled out.
I would like to see this proven formally. Can anyone recommend a text or a website that would serve as a reference ? Or if this is simple to prove (I imagine it is for someone more experienced than me!), a proof would be great.
(For context: I am taking a cryptography course and this came up at the point where they covered why one should never use a stream cipher key more than once.)
Thanks !
UPDATE: great answers.. at my level of knowledge i should have opted for the truth table approach suggested by @peterwhy
XOR is the usual addition in abelian group $\mathbb Z/2\mathbb Z$, so it is associative and commutative. Moreover, $$n+n\equiv 2n \equiv 0 \pmod 2$$ so both bits are inverse to themselves with respect to XOR. Putting this together we have $$(m+k)+(n+k) \equiv m+(k+n)+k \equiv m+(n+k)+k\equiv (m+n)+(k+k) \equiv m+n \pmod 2.$$ Now, if we have strings of bits, for each positive integer $n$, bitwise XOR is given as addition in $(\mathbb Z/2\mathbb Z)^n$ which is defined pointwise so the above calculation is true for each bit, and therefore for strings of bits.