Private set intersection protocols are about finding the common elements in two private sets. The easiest way to do this is, of course, to just share the sets, but that's not very private, is it? Also, that would prevent us from doing fun cryptography!
With the power of ✨cryptography✨.
But for real, this is a technique very related to ElGamal encryption and Diffie-Hellman key exchange. It is based on cyclic groups, which are really interesting and totally out of scope for this explanation. Just know that you can sorta kinda treat the group elements like numbers, but only for multiplication. This means that we can multiply elements together (or multiply an element by itself, giving us a bit of exponentiation too).
We start out with a generator, which is a special kind of group element. Let's call it g. We then pick a secret, random number, which we will call x. Then, gx is a random element in the group that only you know. We will be using it as an encryption key.
Now, you have some items in your private set. Let's hash each item into a string of 256 bytes, and then pretend that those bytes represent a number. That number, let's call it v, can be encrypted simply by computing gxv.
Now, that we have encrypted all of the values, we can send them to your friend. Since they are also following this guide, they also have a secret number. Let's call it y. Now, they will encrypt the thing you sent with their secret number, giving us the value gxyv for each item v.
Now, we also have to run the protocol in reverse, where they are the ones encrypting, and you encrypt their things with your secret. This means that at the end, you will both have your stuff that looks like gxyv, and their stuff which looks like gxyw. (Notice the w instead of your v.) Then we can clearly see that if v = w, the values are going to be the same, and then you both will know that v is present in both of your sets. Ta-da!
For the really nerdy: the cyclic group in question is secp256r1, so it would technically be more correct to use additive notation, but honestly—I prefer the multiplicative notation. Sue me.
Time to reset?
Let's generate a secret. Don't share this value with anyone!
Enter the private information here. Each item in the set should be on a new line. This page does not transmit or record anything that is entered; your data never leaves your browser.
Then, hash the value and encrypt it!
Now, it's time to send the hashed and encrypted data to your friend using your favorite, end-to-end encrypted messaging service. Your friend should, in turn, follow the same steps you did and send their hashed and encrypted data to you. Start by pasting the data they sent in the field below.
Now, it's time to encrypt their data using your secret.
Don't worry, they still won't be able to tell what your secret is!
Time to contact your friend again.
They will need to see their data in the doubly-encrypted format in order to gain any kind of information from this
protocol, and the same goes for you.
This is the part that requires trust, since you cannot guarantee that your friend will send the information you
need if you go first, and vice versa.
Once they have sent the information to you, go ahead and paste it below.
Now, the only thing left is to find the intersection, i.e. the lines in the last two text boxes that are equal.