title: linear transformation function
body: <p>I need to write a function that takes 4 bytes as input, performs a reversible linear transformation on this, and returns it as 4 bytes.</p>
  
  <p>But wait, there is more: it also has to be distributive, so changing one byte on the input should affect all 4 output bytes.</p>
  
  <p>The issues:</p>
  
  <ul>
  <li>if I use multiplication it won't be reversible after it is modded 255 via the storage as a byte (and its needs to stay as a byte)</li>
  <li>if I use addition it can't be reversible and distributive</li>
  </ul>
  
  <p>One solution:
  I could create an array of bytes 256^4 long and fill it in, in a one to one mapping, this would work, but there are issues: this means I have to search a graph of size 256^8 due to having to search for free numbers for every value (should note distributivity should be sudo random based on a 64*64 array of byte). This solution also has the MINOR (lol) issue of needing 8GB of RAM, making this solution nonsense.</p>
  
  <p>The domain of the input is the same as the domain of the output, every input has a unique output, in other words: a one to one mapping. As I noted on "one solution" this is very possible and I have used that method when a smaller domain (just 256) was in question. The fact is, as numbers get big that method becomes extraordinarily inefficient, the delta flaw was <code>O(n^5)</code> and omega was <code>O(n^8)</code> with similar crappiness in memory usage.</p>
  
  <p>I was wondering if there was a clever way to do it. In a nutshell, it's a one to one mapping of domain (4 bytes or 256^4). Oh, and such simple things as N+1 can't be used, it has to be keyed off a 64*64 array of byte values that are sudo random but recreatable for reverse transformations.</p>