I would like to know if it is possible to create a function, using logic gates for binary numbers, such that i can go back to the two variables a and x, knowing only y and k.
I used the XOR logic gate but, if this is indeed possible, you can also change it to any other gate, I accept any kind of advice!
y = (a ^ k) ^ (x ^ k)
That's a SAMPLE of the function that i must find, if it can be solved in other simpler ways let me know! Thank you
CodePudding user response:
You can, in a sense. What we know about the normal math we have encountered our whole lives is not the same here, so solving for a and x will not be so explicit. Firstly, there is not a nice concept of moving variables from one side of the equation to the other in boolean algebra. Second, the XOR function is not a continuous function, therefore it can only be expressed as a piecewise function. What that all means is solving for a and x is not going to happen like we're used to.
Let's break it apart to make it more clear.
y = f1 ^ f2
where f1 = (a^k)
where f2 = (x^k)
All we did here was to make a smaller function for each parenthesis.
Let's define f1 (XOR).
f1 = 0, a=k
f1 = 1, a!=k
Let's define f2 (XOR).
f2 = 0, x=k
f2 = 1, x!=k
Now, let's define y (XOR)
y = 0, f1=f2
y = 1, f1!=f2
If you know y, then you can determine whether f1 and f2 are equal or not. Since f1 and f2 are constructed the same way, they are identical except for their input arguments a and x. From this point, if you know k, you can show that if f1=f2, then a=x. You can also show that if f1!=f2, then a!=x. You can say how a and x are related, but unfortunately, you cannot determine their values. I urge you to try plugging it in yourself, you will find a and x can have two different values for each value of y.
CodePudding user response:
i'm assuming that ^ here means xor and not exponentiation.
Remember that ^ is both associative and commutative, so
y = (a ^ k) ^ (x ^ k) == a ^ x ^ k ^ k = a ^ x ^ (k ^ k) = a ^ x ^ 0 = a ^ x
The value of k
is completely irrelevant in this expression, so knowing the value of k
tells you absolutely nothing.
Knowing the values of two of a
, x
, or y
, you find find the third by xor-ing the other two. You cannot find the value of k
if you don't know it.