Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 $\:$ . $\;\;$ – 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

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

share|improve this answer

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

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.