Short version:
What is the inversion of $f(x) = x \oplus (x \lll 1) \oplus (x \lll 5)$ when the last 4 bits of $x$ are known?
Long version:
Hi,
a friend a mine and I are giving each other crypto challenges to break. This time, he gave me a "one-way" function which is defined as followed:
$R(x)= x \oplus (x \lll 1) \oplus (x \lll (x\ AND\ 15)) \oplus ((x\ AND\ 15) \lll 1)$
Or if you define $i = x\ AND\ 15$:
$R(x) = x \oplus (x \lll 1) \oplus (x \lll i) \oplus (i \lll 1)$
Given you can bruteforce $i$ (since it is ranged from 0 to 15), there are a few things you can do:
For $i = 0$: $R(x)$ can be reduced to $R(x)=x \oplus (x \lll 1) \oplus x \oplus (i \lll 1)=(x \lll 1) \oplus (i \lll 1)$ which can easily be reversed.
The same applies to $i = 1$ which allowes you to reduce $R(x)$ to $x \oplus (i \lll 1)$.
However, things get more complicated for $i \ge 2$ since the xor's no longer negate themselves, but since you "know" the last 4 bits of $x$, you can try to reverse the function by building upon $i$:
Given that $x_{28-31} = i_{0-3}$ and $0 \le i \le 3$
$x_{27} = x_{27} \oplus x_{28} \oplus x_{27 + i}$
$x_{26} = x_{26} \oplus x_{27} \oplus x_{26 + i}$
...
$x_{n} = x_{n} \oplus x_{n + 1} \oplus x_{n + i}$
($x_n$ or $i_n$ are the $n$th bit of $x$ / $i$)
However, i really have no clue when it comes to $i \gt 3$ since you cant access the plain bits anymore.
// EDIT: The $f(x)=x\oplus (x \lll 1)$ can easily be broken by defining that $x_0=0$ and then calculating the rest using $x_{n}=x_{n-1} \oplus x_{n}$ but I wasn't really able to expand this to the problem above.