Spent two days researching the subject, but so far I haven't come up with a satisfying answer as to whether there is a feasible solution to the following problem:
A has a secret $m$ whereby $0 \leq m \leq 320$ (so a pretty small set of options).
A then uses some sort of function $f$ to calculate $f(m)$ and sends the result to B.
B also has some sort of function $g$ and calculates $g(f(m))$ and sends it back to A.
B has a guess n what the secret may be and sends the guess g(n) to A
A can now its function $f$ to calculate $f(g(n))$:
If $f(g(n)) = g(f(m))$ then $m = n$
Things of note:
- B must not be able to guess what the function $f$ might be based on $f(m)$ (since the possible values are not that many, it is imperative that $f()$ cannot be guessed simply by brute-forcing)
- A must not be able to know what the guess $n$ is, unless $n = m$.
- A must not be able to guess what the function $g$ might be based on $g(f(m))$ (that means no simple XOR)
- There is literally no need to decipher. So does not matter whether we talk hashing, async or sync encryption.
- It should be fast, like in mobile-phone-browser fast.
- Should be save against an attacker with way more calculation power and time.
- Key-generation for functions $f$ and $g$ may take considerable time. No problem. That is one-time-setup.
- There is no third person C available to help as an impartial mediator.
Thankful for any input
PS: I looked at homomorphic encryption, but to me these things seem to be all-out focused on basic math like addition and/or multiplication, which would not be exactly what I am looking for (as far as my research went, they all boil down to RSA is probably the quickest one of them and if benchmarks published by others are true, then it would probably be too slow)
I also looked at ZK, but the point is: How would A or B calculate a proof over something they don't know? If A where to prove they know a point m that is in the given range, then that's nice for them, but to B this means nothing. B cannot generate a proof that they know A's secret, because, well, they do not know. Of course A (or B) can generate a proof that $m$ (or $n$) have been chosen and then one of them reveals and the other verifies that the reveal is what has been used to generate the proof. However, this would not work, because then, at a certain point, one needs to reveal and then the other one knows the secret regardless of whether $m = n$ or not.