# Black box solver [closed]

I want to know if there is any mathematical or brute force approach to decipher simple black box

A: Is only one digit (0...9) B: Is 2 digits (00..99) C: Is a result of a linear function between A & B, for example it could be C=A2+8-10B or C=A*A-B ... we have this table:

How can we find C ? What if there is non-liner function between A&B ?

• There are infinite number of solutions for this. This is not a crypto question. its mathematics – Aven Desta Dec 25 '20 at 8:55
• Per what definition of "linear" is A*A-B (one of the examples) "a linear function between A & B"? It looks like a polynomial from where I stand. – fgrieu Dec 25 '20 at 9:29
• This question was closed because it is not about a cryptographic problem as that's defined on crypto-SE; and it can't be migrated, at least because the OP did not make it rigorous: the above comment pointing that the characteristics of the function leading to C are ill-defined was not addressed. – fgrieu Jan 7 at 6:40

The general solution to such puzzle is to write a general form of the function of $$A$$ and $$B$$ that the problem statement allows, and solve using the givens. So for example if we posit $$f(A,B)=u\,A^2+v\,A\,B+w\,B^2+x\,A+y\,B+z$$, we know $$f(A,B)$$ for 8 pairs of inputs, and that gives us 8 linear equations of the 6 unknowns $$u$$, $$v$$, $$w$$, $$x$$, $$y$$, $$z$$. If we find a solution to that, we have solved the puzzle.

Here the system goes: $$\begin{array}{r} u&+&25\;v&+&625\;w&+&x&+&25\;y&+&z&=&30\\ 4\;u&+&100\;v&+&2500\;w&+&2\;x&+&50\;y&+&z&=&104\\ 9\;u&+&210\;v&+&4900\;w&+&3\;x&+&70\;y&+&z&=&213\\ 16\;u&+&232\;v&+&3364\;w&+&4\;x&+&58\;y&+&z&=&234\\ 25\;u&+&160\;v&+&1024\;w&+&5\;x&+&32\;y&+&z&=&161\\ 36\;u&+&594\;v&+&9801\;w&+&6\;x&+&99\;y&+&z&=&594\\ 49\;u&+&147\;v&+&441\;w&+&7\;x&+&21\;y&+&z&=&146\\ 64\;u&+&560\;v&+&4900\;w&+&8\;x&+&70\;y&+&z&=&558 \end{array}$$ and has (single) solution $$u=0,v=1,w=0,x=-1,y=0,z=6$$ Thus $$f(A,B)=A\,B-A+6$$, thus $$f(9,66)=591$$.

It's a simple matter with the right tools. Try it online!.

Here $$f$$ is so simple that it was probably possible to find the solution by intuition, trial and error. But why bother when there is math?

More seriously: this shows that using any second-degree polynomial of $$A$$ and $$B$$ does not make the problem hard. This generalizes to any degree and in any field, including finite, e.g. the integers modulo $$p$$. This has applications in crypto, e.g. Shamir secret sharing can be thought as a variant of that where we reconstruct the coefficients of a polynomial given enough examples.

• Thanks for responding in details, very helpful. What if there is a bitwise operations between A & B, or bit shifts and XOR. Is there any method to solve that knowing A is only one digit and B is only 2 digits, is there any sort of brute force or other method having enough dataset ? – Jackal Dec 27 '20 at 3:55
• @Jackal : The method I described requires a polynomial in a field. Thus it won't work for arbitrary combination of operations. Yet in modern crypto we assume that the cryptosystem is public, only its keys can be secret, and we have techniques to find the key of simple-enough constructions given enough examples. There's no general answer to your new question. – fgrieu Dec 27 '20 at 8:55