osu-crypto / libPSI

A repository for private set intersection.
Other
168 stars 47 forks source link

Is there any examples or demos? #37

Closed tanjuntao closed 2 years ago

tanjuntao commented 2 years ago

Hi, I cannot find any example codes or demos under this repo, so it's a bit hard for users like me came from Python world to run a specific PSI protocol. So would you please provide some tutorials on how to use this library and how to switch from one protocol to another?

Thanks in advance for your help.

ladnir commented 2 years ago

I suggest using KKRT as the default protocol.

If you run frontend then it prints this stuff with some instructions https://github.com/osu-crypto/libPSI/blob/master/frontend/main.cpp#L470

here is how to read sets from a file and then perform the PSI. https://github.com/osu-crypto/libPSI/blob/master/libPSI/Tools/fileBased.cpp#L162

Its called from here https://github.com/osu-crypto/libPSI/blob/master/frontend/main.cpp#L438

Here is some code that runs the benchmark https://github.com/osu-crypto/libPSI/blob/master/frontend/OtBinMain.cpp#L459

Here are some unit tests https://github.com/osu-crypto/libPSI/blob/master/libPSI_Tests/BinOtPsi_Tests.cpp#L1003

If you have further questions im happy to help.

Cheers, Peter

tanjuntao commented 2 years ago

Thanks for you informative comments.

After some trials, I finally successfully installed this library on my macOS Monterey, but I got one question.

Q: using multi-threading didn't seems to get a great speedup

The set size is 10 million for both the sender and the receiver, and the PSI protocol is KKRT. Here is the result when using only one thread at each party:

[21:22:02] tanjuntao@mbp-2:~/libPSI/out/build/osx/frontend (master)$ ./frontend.exe  -kkrt -r 0 -n 10000000
protocol     n      threads      total(ms)    online(ms)     comm (MB)        bandwidth (Mbps)
------------------------------------------------------------------------------------------------
  kkrt100000001 1.000000         51125         47191           1126.73     127.06, 49.25

And here is the result when using four threads:

[21:23:48] tanjuntao@mbp-2:~/libPSI/out/build/osx/frontend (master)$ ./frontend.exe  -kkrt -r 0 -n 10000000 -t 4
protocol     n      threads      total(ms)    online(ms)     comm (MB)        bandwidth (Mbps)
------------------------------------------------------------------------------------------------
  kkrt100000004 1.000000         46325         43525           1126.73     140.22, 54.36

As you can see the speedup is not good. I'm not sure whether I use the command line arguments correctly.

ladnir commented 2 years ago

It's not multi threaded

tanjuntao commented 2 years ago

Then how can I use multi threading in the command line?

ladnir commented 2 years ago

You would have to implement it. It's currently single threaded.

tanjuntao commented 2 years ago

I got it, thanks.