# What are Alternatives to basic ROT-n Ciphers which Don't Lose 'Context'?

I've got this neural network running like a champ on my machine. The data is concatenated works of shakespeare in a plaintext file. RNN trains on the data, then gives you a 'sample', aka it tries to freestyle its own shakespeare based on what it has learned.

So now I've encrypted the dataset with a standard mid ROT cipher, and gave that to the NN to train on. Which it did, and it returned a result which was ROT ciphered. Decrypting that yielded valid results. As it should have, training on data that kept all its 'context', without randomness, unpredictability, or 'fuzz'. Not sure if those are the exact words, but you get it.

I'm wondering if there are any other ciphers, or really any other algorithms like compression schemes or what have you, that may yield the same results as my previous experiment? That training on its encrypted data would likely yield a sample that could then be decrypted accordingly? Or would most other stuff be 'lossy' in some way?

• I have a hunch that diffusion will make or break your networks ability to do this. I suspect that you are looking for ciphers that do not possess diffusion. Mar 14 '17 at 16:28
• It does seem reasonable to assume that any algorithm that utilizes diffusion would not work for my use-case. Can you provide example(s) of potential protocols, other than pure simple substitution ciphers, which could potentially work in the manner I've described? Mar 14 '17 at 17:04
• Any classical cipher that is closer to an "encoding" then "encryption" should work. Modern encryption algorithms have known to incorporate diffusion since the time of Shannon's Communication Theory of Secrecy Systems, so you are not likely to find any modern designs that will exhibit this effect. As fgrieu mentions in their answer, any simple substitution cipher should exhibit this effect. It might work with simple transposition ciphers as well. Also, I removed the homomorphic-encryption tag; it did not appear relevant to your Q. Mar 14 '17 at 18:08
• I thought homomorphic encryption was completely relevant, based on what I read here. "A homomorphic encryption scheme is a crypto system that allows computations to be performed on data without decrypting it. A homomorphically encrypted search engine, for instance, could take in encrypted search terms and compare them with an encrypted index of the web." Computations, and arguable "meaning" is derived from the data without decrypting it. That's what I want to be able to do in this case. I'll check out transposition! Mar 14 '17 at 19:27
• In principle, (fully) homomorphic encryption is what you are looking for. Then you can encrypt your plaintext (Shakespeare in your case), define operations on the ciphertexts (as circuits) and evaluate them (in the best case, multiple times). At the end you decrypt and get your result. Whoever runs the RNN (as circuits) may use circuit privacy to hide no only the input but also the computation. However, all of this works in theory, but if is not really feasible for "normal" usage yet, it will be way too slow. Maybe in some years.
– CAR
Mar 14 '17 at 23:35

ROT-n is a particular case of substitution cipher, with a much smaller key set (if we restrict to uppercase letters, ROT-n has $26<2^5$ keys, versus $26!>2^{88}$ keys for a general substitution cipher; that less than 5 bits versus more than 88).