The Difficulty of Private Contact Discovery
As Moxie notes, this problem is known as private set intersection: how can two parties P1 &amp; P2 discover which elements they have in common, without revealing all their elements to each other or to a third party?  His error is in describing scenarios where P1 is Open Whisper Systems and P2 is one of its users: yes, it would be insane to use a protocol where OWS must transmit its entire user database (hashed, encrypted or permuted) due to bandwidth reasons.  But that&#x27;s crazy anyway: OWS can see who is talking to whom on its servers already.  Let&#x27;s not do that!<p>The Right Thing is for individual users of Signal to privately compute set intersections between their own contacts. If Alice knows Bob, Charlie &amp; Dan, and Bob knows Alice, Charlie &amp; Eve, then when Alice &amp; Bob add each other then they could each execute a protocol which would reveal that they both know Charlie.<p>In the last discussion of this, pbsd posted a link [1] to a great Microsoft paper covering private set intersection [2].  It works its way through a number of different protocols, but what it ends up with is this:<p>- Alice generates three sets of dummy data D1, D2 &amp; D3 (where the lengths of all three sets are equal to a security parameter t, and the items in the sets are invalid phone numbers (perhaps, elements of the form &#x27;invalid:$RANDOM_DATA&#x27;) and sends them to Bob securely.  These dummy sets will be used to observe if the server is cheating.<p>- Bob checks that they are well-formed (i.e., of the right length and invalid phone numbers).<p>- Alice &amp; Bob then generate a shared key K1 using a simulated coin-tossing protocol.<p>- Bob then generates a shared key K2 with the server (in this case, the OWS server) using the simulated coing-tossing protocol.<p>- Alice then sends to the server SHUFFLE{HMAC(K1, Charlie:1), HMAC(K1, Charlie:2), … HMAC(K1, Charlie:n), HMAC(K1, Dan:1), HMAC(K1, Dan:2), … HMAC(K1, Dan:n), HMAC(K1, D1_1), HMAC(K1, D1_2) … HMAC(K1, D1_t), HMAC(K1, D2_1), HMAC(K1, D2_2), HMAC(K1, D2_t)}, where n is another security parameter, Charlie is Charlie&#x27;s phone number and Dan is Dan&#x27;s phone number.  Since the server doesn&#x27;t know K1 and it doesn&#x27;t know how the set was shuffled, it has no idea which of the hashes is which phone number, nor which is a dummy.<p>- The server then generates a random SEED and sends to Alice KEYED_SHUFFLE(SEED, {HMAC(K2, HMAC(K1, Charlie:1)), HMAC(K2, HMAC(K1, Charlie:2)), … HMAC(K2, HMAC(K1, D2_t))}).    Since Alice doesn&#x27;t know K2, and since she doesn&#x27;t know how the set was shuffled, she learns nothing yet.<p>- Bob sends SHUFFLE{HMAC(K2, HMAC(K1, Charlie:1)), HMAC(K2, HMAC(K1, Charlie:2)), … HMAC(K2, HMAC(K1, Charlie:n)), HMAC(K2, HMAC(K1, Eve:1)), HMAC(K2, HMAC(K1, Eve:2)), … HMAC(K2, HMAC(K1, Eve:n)), HMAC(K2, HMAC(K1, D2_1)), HMAC(K2, HMAC(K1, D2_2)), … HMAC(K2, HMAC(K1, D2_t)), HMAC(K2, HMAC(K1, D3_1)), HMAC(K2, HMAC(K1, D3_2)), … HMAC(K2, HMAC(K1, D3_t))} to Alice.<p>- Alice is know able to compute the intersection of the message she received from the server and the message she received from Bob.  She does so, and sends the intersection {HMAC(K2, HMAC(K1, Charlie:1)), HMAC(K2, HMAC(K1, Charlie:2)), … HMAC(K2, HMAC(K1, Charlie:n)), HMAC(K2, HMAC(K1, D2)} to Bob.<p>- Bob knows K1 &amp; K2, and can calculate HMAC(K2, HMAC(K1, X)) for any X he knows (including the members of the three dummy sets D1, D2 &amp; D3).  He can now check that neither Alice nor the server has cheated.  First, he finds the original X for each HMAC(K2, HMAC(K1, X)) in the intersection.  Then, if any member of D2 is missing from the result, or if any member of D1 or D3 is in the result, then someone has cheated, or if he doesn&#x27;t see all of Charlie:1, Charlie:2 … Charlie:n then someone has cheated.  In this case, Bob knows that neither Alice nor the server cheated, and now he knows that they share Charlie in common.<p>- Bob tells the server &#x27;continue&#x27; and the server sends Alice the random seed used to in the KEYED_SHUFFLE; Alice uses this to determine which item she sent the server corresponds to which item the server sent to her, and from that which item in the intersection she sent to Bob corresponds to Charlie:1, Charlie:2, … Charlie:n, Dan:1, Dan:2, … Dan:n and so forth.  Alice, too, can see if either Bob or the server cheated.<p>At the end of this protocol, Alice &amp; Bob both know that they share a contact in common with the same phone number.  In place of phone numbers, of course, one might use pseudonyms, public keys &amp;c.  They&#x27;ve sent relatively small messages (just a few times the size of their contact lists), and the server doesn&#x27;t know how many they have in common, or whether they have anyone in common.<p>So, problem solved.<p>Edit: I should note that there&#x27;s no way for Alice to know that Dan also has an account if they don&#x27;t know any other user in common, and of course Bob &amp; Alice need to exchange identities offline in person first.  But, once that exchange has happened, everything else Just Works™ and due to the small-world phenomenon as more users use it, more users discover one another using it.  Users who know one another can even re-run the protocol every once in awhile, when discovering new contacts.<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7009674" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7009674</a>
[2] <a href="http:&#x2F;&#x2F;research.microsoft.com&#x2F;pubs&#x2F;194141&#x2F;sapsi2.pdf" rel="nofollow">http:&#x2F;&#x2F;research.microsoft.com&#x2F;pubs&#x2F;194141&#x2F;sapsi2.pdf</a>