2
$\begingroup$

I have this cypher which is as follows :

Take 2 numbers : A=1011 and B=1010

if the ith bit of A is 1 then shift B i times to the left. So in the end you will get something like

   1010
  1010
1010

So now you Apply XOR on these numbers which results in :

00001010
00010100 (XOR)
01010000 (XOR)
---------
01001110

So you end up getting 2 4-bit numbers from 01001110: that is 0100 & 1110

So now given 0100 & 1110 how do I reverse this and find the initial A & B

PS : I am a complete newbie when it comes to crypto so please explain it like how you would explain it to a noob.

$\endgroup$
  • 1
    $\begingroup$ Note that $A$ and $B$ may not be unique: For instance, $(0001,0101)$ and $(0011,0011)$ yield the same output $(0000,0101)$. $\endgroup$ – yyyyyyy Jul 7 '15 at 8:43
  • $\begingroup$ Cross-posted on math.SE, where there is an update. Cross-posting is against SE rules. Pick one site and stick with it. $\endgroup$ – mikeazo Jul 7 '15 at 16:08
5
$\begingroup$

While you're a crypto newbie, I hope that you know something about mathematics (because you've stumbled something that needs to be described in mathematical terms). What you've described here is actually polynomial multiplication (over polynomials in $GF(2)$ (that is, we do our computations modulo 2).

That is, you can interpret the numbers as specifying a polynomial (where each bit indicates whether the coefficient of the polynomial is either 0 or 1; for example, 1011 would correspond to the polynomial $x^3 + x + 1$, and 1010 would correspond to the polynomial $x^3 + x$. When you perform your operation, you generate the product polynomial, in this case $(x^3 + x + 1) \times (x^3 + x) = x^6 + 2x^4 + x^3 + x^2 + x = x^6 + x^3 + x^2 + x$ (this last step of dropping $x^4$ happens because we're computing everything in $GF(2)$

With that in mind, the problem of reversing the operation is actually a factorization problem (not factorization over the integers, which is what people generally think about when factorization is brought up, but its analogue over polynomials).

This implies that:

  • The values $A$ and $B$ need not be unique. For one, the operation is actually symmetric (even if your algorithm to perform it is not); swapping $A$ and $B$ will always result in the same product, and so another solution in your case is $A = 1010$ and $B = 1011$.

  • More generally, as yyyyyyy referenced, the factorization process can reduce the product to its prime factors, but there might be multiple ways to reassemble these prime factors (for example, the prime factorization of $1010 = 11 \times 11 \times 10$). It terms out that $1011$ is prime (and hence if we limit our multiplicands to 4 bits, $1011$ and $1010$ are the only two possible factors), however this won't be the case in general.

And if you're asking whether factorization is a hard problem, it is not. There are known polynomial time factorization methods over polynomials (this is one way where factorization over the integers differs from factorization over polynomials). However, those techniques are a bit beyond what a newbie can be expected to understand.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.