I have a question about the first programming assignment in Dan Boneh's cryptography course on Coursera. You're given 10 ciphertexts that were encrypted with the same key and you can presumably assume that the plaintext consists of letters and whitespace only.
The hint gives that you should consider what happens when a whitespace is xor-ed with a letter. The idea is to check whether the xor-ed subparts of the ciphertext combinations correspond to a letter, which should allow us to figure out the key.
If we do find a letter, I think we should be able to recover that part of the key, that corresponds to the letter we're currently processing, by doing the following:
Let c_sub1 and c_sub2 be the sub-parts of the ciphertexts c1 and c2 that we currently check and let m_sub1 and m_sub2 be the corresponding sub-parts of the plaintexts. One of m_sub1 or m_sub2 must be a whitespace. To figure out which one, we try the following:
Assuming m_sub1 is a whitespace, get the corresponding sub-part of the key (k_sub) by xor-ing c_sub1 with 00100000 (the binary representation of a whitespace char), k_sub = xor(c_sub1,00100000), and check if encrypting the case-flipped letter (since xor-ing with a white space flips the case of a letter) with k_sub yields c_sub2, if it does we should know that k_sub is the correct sub-part of the key. If not, try the same with assuming that m_sub2 is a whitespace.
I can't find any logical mistake in that reasoning, but my implementation yields an incorrect solution and I'm fairly sure I've eliminated all other bug possibilities. Can anybody tell me whether this approach is wrong, please?