If you’re reading this, you’re probably planning on asking that special someone out on a date, or want to figure out if a good friend might be more than a good friend. Also, you’re most likely afraid of asking them out, or you would have done so already.
If you could just know whether the other person liked you as well, it would be so much easier! If they like you, well, great 🙂. If they don’t like you, then you don’t need to ask them out in the first place, saving yourself from potential gossip and embarrassment.
But don’t worry: mathematicians, maybe due to their lack of social skills and confidence, have invented a way to ask people out without embarrassing themselves!
There is a method for both of you to determine whether you like each other without needing to reveal your individual preferences. That is, the other person only learns that you like them if they also like you; if they don’t like you, they never find out whether you like them or not. Sorry, that’s a bit of a mouthful.
How can we translate this mathematically? Let and be the intentions of you (Alice) and the other person (Bob), respectively. If a person is interested in moving towards a romantic (casual, …) relationship, they set , or otherwise. You end up going out together if , and you don’t otherwise. This function can be expressed either as (logical AND) or as .
Obviously, this can be easily computed if you both reveal your preferences, but then you might as well just ask the person out normally. Alternatively, you could ask a friend to help you: both of you tell your friend whether you are interested in the other person, and your friend then just tells you the result. But then both of you would need to trust this friend not to tell anyone about your individual preferences or use that information for personal gain. Note that if you write a piece of software to return the answer, and you both just enter your value into the software, it’s the same problem: both of you need to trust the software with your personal preferences.
There are two ways this can be solved, but we’ll only cover the simple method here. The other is more secure, but it is more advanced and requires far too many computations: you’ll lose the person 20% of the way through because they’ll get bored, unless they really love math. If you’re interested, check out multi-party computation for Boolean circuits. You’ll also need to read up on oblivious transfer.
The simpler method can be done with just a few slips of paper, and it is easy enough to understand for someone who didn’t study mathematics. Unfortunately, it still requires your friend, but unlike before, they’ll never learn either of your individual preferences in the process: the friend just gives you some numbers, and you don’t reveal anything to your friend.
The protocol
Step 1 (friend): prepare a Beaver triple. Your friend prepares six numbers such that the following holds:
Suggestion: randomly choose some , and pick random numbers such that , and .
Give to Alice, and to Bob. For future notation: variables subscripted with 1 are for Alice, those with 2 are for Bob.
Step 1 (Alice): split your preference. Your preference is itself sensitive and cannot be shared with Bob. We therefore split it randomly, in a way that the pieces individually reveal no information about your preference. Simply pick some random number , and set and . Note how . Keep and share with Bob.
Step 1 (Bob): split your preference. You do the exact same step as Alice, but with different numbers of course. Keep and share with Alice.
Step 2 (Alice). Alice just received from Bob, and from the friend. She computes
Step 2 (Bob). Bob just received from Alice, and from the friend. He computes
Step 3: reveal and . Alice reveals , and Bob reveals . These values reveal nothing about the preferences, or . Both of you compute
Step 4 (Alice). Compute .
Step 4 (Bob). Compute .
Step 5: get the result. Both of you reveal your share or ; the result of the function is . If you did everything correctly, you should have if and only if you both set your preferences to 1, and otherwise.
You can verify that these steps make sense by replacing the variables with their definitions; after simplifying, you should find .
Warning: Please do not use these steps in a production setting, or in any other scenario where confidentiality is business-critical.
A variation for polygamous relationships
Assume you wanted to know how many people in a given group were interested in starting a polygamous relationship. (An alternative would be to check whether everyone was interested, revealing no information if a single person is not, but we skip that scenario here.) This boils down to computing the sum of preferences, assuming the same preference values as before: 1 if interested and 0 if not.
This is, in fact, easier than the previous setting. Say we have four people with preferences , . Everyone creates random numbers such that , and shares the 1s with , the 2s with , …, and the 4s with . In the end, the -th person holds the values , from which they compute the temporary value . Everyone reveals their , which lets them compute the result . Substituting the variables shows that this is indeed the sum of all preferences.
Warning: It is very easy for a person to choose a preference that is not 0 or 1, allowing them to skew the result (by choosing negative values, or values greater than 1).
You might ask why we didn’t use this method for the monogamous setting. Whatever the final result, both people would instantly know the other person’s preference (the other person’s preference is the result minus your own). With more people there are more unknowns, so these deductions can no longer be made deterministically.
