# 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.

-
I think private set intersection should be what you are looking for. –  Maeher Apr 30 '13 at 21:16
That's way more complicated that what's needed for his situation. $\hspace{2.2 in}$ See $\:$ en.wikipedia.org/wiki/Socialist_millionaire . $\;\;$ –  Ricky Demer Apr 30 '13 at 21:40
@RickyDemer, post that as the answer, because it's the answer. –  John Deters Apr 30 '13 at 21:45
add comment

## 2 Answers

That sort of thing is known as multi-party computation, and you
should use a Socialist Millionaire Protocol for your particular instance.

-
add comment

Comparing data sets can also be done using "order preserving Encryption" techniques

-
There is no order in a privacy preserving set intersection protocol. Only equality –  curious Jun 10 '13 at 9:36
so this answer is wrong? –  Mike Jul 1 '13 at 0:14
add comment