How to compare two datasets „anonymously”? Ok, I hope this question makes some sense because I am not so sure how to word it any differently… Imagine the following situation:


There are 10 defined colors (blue, orange, yellow etc.) 
There are 2 Persons and each of them has 1 favorite, secrete color
The 2 persons don't know each other's favorite color, however, they
want to know if they share the same


My question: How can they do a comparison without exposing their own favorite color to the other person (or to anyone else!) in case they do not match? 

Or, to explain the problem with other words: Person A should only know the favorite color of Person B if they share the same. Hence, the result of the comparison must only be True or False.

My first thought was: Every person could simply create a hash of their favorite color using the same hash algorithm (MD5, SHA etc.) and then they can compare the hashes. But obviously, that doesn't work, because it’s easy to find out which hash belongs to which color.

Is there a solution for such a use case? Any help would be highly appreciated.
That sort of thing is known as multi-party computation, and you

should use a Socialist Millionaire Protocol for your particular instance.