|Perl Monk, Perl Meditation|
Re^2: Japh algebra, GF(128) editionby ambrus (Abbot)
|on Oct 02, 2010 at 22:16 UTC||Need Help??|
Let's start from a bit farther. This series of obfus works by storing a polynomial and evaluating it at different places to get the message.
For example, suppose you wanted to print the message 3, 8, 0. You could then create the polynomial f(x) = 3 + 11.5*x - 6.5*x**2, for which f(0), f(1), f(2) gives the values you want, and write code like this to evaluate that polynomial.
Now the problem with this method is numeric precision: if you wanted to do the same thing if you want to get 26 values (the character codes of a 26 character long message), you either couldn't do it with floating point at all, or you'd have to give the coefficients to lots of decimal digits of precision.
There's however an easy solution, which is to compute the polynomial modulo a convenient prime, namely 127. This is what Japh algebra, Japh algebra revisited, and ASCII arithmetic does (read the first one, for that has almost no obfuscation layer apart from this). We call this computing over the finite field of size 127, that is, over GF(127). (The name GF stands for Galois field originally.)
Now, computing over a prime field like GF(127) is easy because you just add or multiply two elements by adding or multiplying them as integers and then taking the result modulo 127. The obfu is thus as simple as
Now, if a field is not a prime field, such as GF(128), then it's not so simple to do the computation, though it's also not too complicated as the brevity of the obfus show in hindsight. That's why I wondered what such an obfu would look like before martin wrote one, and before I dreamt this one.
As for why I asked for GF(128) instead of some other field, the reason is brevity. To make the code simple enough, the field should be large enough that each element could encode a character of the output, but small enough that each element in the coefficient vector can be stored as a single character in the obfu. (There could be a challenge here though, seeing whether it's possible to do calculations over GF(125) or similar in just a few lines, or using two characters per field element for a larger field.)
Update: hide all behind spoiler tags.