tag:blogger.com,1999:blog-3722233.post1442502959825675643..comments2022-09-27T00:52:45.931-05:00Comments on Computational Complexity: How hard would this cipher be for Eve to crack?Lance Fortnowhttp://www.blogger.com/profile/06752030912874378610noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3722233.post-1153357340669820732015-08-17T02:34:46.804-05:002015-08-17T02:34:46.804-05:00It sounds strong, and certainly for large k there ...It sounds strong, and certainly for large k there are long messages for which it is impossible to determine the exact string with sub exponential probability (i.e. strings in which no k-tuple is repeated), however the security is significantly weaker than it may first appear. Part of the problem is that as the key gets longer, you need more cipher text if you want to do a cipher text only attack, and it may seem hard to imagine that much cipher text when you are considering encoding English language. <br /><br />However... the security should not depend on either the type of data you are sending, and when you convert this to encoding bit strings problems start to become obvious for certain types of data. Take the obvious extension to bit strings where you map strings of k bits onto other strings of k bits. Since there are (2^k)! such mappings, you cannot reasonably go above about 4 bytes.<br /><br />Now, if you take a uniformly random string and encrypt it, there is clearly no way to determine the corresponding plaintext with probability greater than the inverse of the number of keys. One way of seeing why this is true is because the randomness from the key maps every input string onto a uniform distribution over (2^k)! strings, but the length of the message is unchanged, so the message effectively loses log_2(2^k)! bits of information about the plaintext.<br /><br />However, the encryption scheme has a flaw: whenever I see the same value of a k bit block in the ciphertext, I know that in the plaintext, those values are the same. This can be enough to mount an attack if the plaintext comes from a sufficiently low entropy source (or equivalently that there is a sufficient corpus of ciphertext) so that the length of the message is significantly longer than the length of the key plus the Shannon information of the source. Below is an example of how one might accomplish such an attack:<br /><br />For simplicity, suppose that k=24 (in which case the key is around 378 million bits long). Now suppose we encrypt a clear uncompressed high resolution photograph with 24-bits per pixel. This means each pixel gets encoded separately, and pixels which have the same colour value will have the same ciphertext value. Since we can expect a reasonably high number of pixels in the same spatial region of the photograph to have the same colour, we can infer the dimensions of the image by finding the wrapping of the string which maximizes the spatial clustering of cyphertext pixels of the same value. Further more, we know that in most photographs pixels near each other will likely be of similar colour, so we can start to infer the distance RGB plaintext values corresponding to different ciphertext values. Once you have approximated these distances all that is left is to distinguish which extremes correspond to high vs low values of R, G and B. But there are only 8 possibilities for this, so you are basically done. Plus, now you have the key, so you can break non-image messages.<br /><br />I chose k=24 in the above since it exactly matched up with the length of each pixel, however even if it hadn't, this attack would still work provided that you consider blocks of ciphertext where the number of bits in between is a multiple of 24.<br /><br />The above is only a toy example of how one might attack the scheme, but it lacks an important form of security: to be truly secure, one would want it to be the case that it is hard to distinguish between any two chosen plaintext strings. This is not the case for your scheme, since for example the ciphertexts corresponding the the messages [AAA...A][BBB...B] and [AAA...A][AAA...A] (where [ and ] indicate the block boundaries) can be easily distinguished, since the first necessarily has different ciphertext values for each block, whereas the second necessarily has the same ciphertext value. As a result, it is easy to come up with situations where the security falls apart, as above.Joehttps://www.blogger.com/profile/11034966968414912132noreply@blogger.comtag:blogger.com,1999:blog-3722233.post-80332934130319907542015-08-09T21:57:06.145-05:002015-08-09T21:57:06.145-05:00> Question One: How big does k have to be befor...> Question One: How big does k have to be before this is impractical for <br />> Alice and Bob?<br /><br />Define impractical.<br /><br />The key length is log (26^k)!, which is more than k * 26^k ~ k * 2^{4.7k}. This becomes inefficient for k=3, unpleasant for k=9, and ridiculous for k=15.<br /><br />In contrast, AES has a key length of 256 bits (if you are paranoid).<br /><br />> Is it secure?<br /><br />Note first that it is trivially breakable under chosen-plaintext attacks, and probably known-plaintext attacks as well for reasonable values of k (e.g., k=8 or k=9). Beyond that, I would start looking at (bi-)word frequencies rather than letter frequencies.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-43644417019762483322015-08-09T01:51:37.686-05:002015-08-09T01:51:37.686-05:00About whether it would be easier or harder when $k...About whether it would be easier or harder when $k$ goes up, I would assume that it only gets easier. While it is true that looking up statistics becomes harder after a certain point, it would also be true that the entropy goes down very rapidly. For instance, I would assume that the triple "xkt" never appears in an English text.<br /><br />I should also say that I have done frequency analysis in reality when I was a child and on the encrypted (k=1) notes that my sister used to write (what can I say except that I was a nosy kid :-))) ). To my experience, it was easy to match the more frequent letters (it was in Farsi) but very hard to match the less frequent ones. So, from there, I actually used my intuition to think of two letter words and so on to find the whole translation table.<br /><br />I should also mention that, at the time, Internet was not widely accessible and I just wrote a program that read two texts and tried to match up the letters according to their frequencies. Nowadays, you can very easily write a program that reads wikipedia and generates the frequency table.<br /><br />Therefore, I would guess that, if you had a long enough encrypted text, as $k$ goes up, it would become easier to extract translation tables because the entropy decreases and, so, distinguishing frequent patterns from unfrequent ones becomes easier (the same way that compression would work better if you could compress longer words).Shahabhttps://www.blogger.com/profile/15635159089551928063noreply@blogger.com