lschoe / mpyc

MPyC: Multiparty Computation in Python
MIT License
367 stars 76 forks source link

Example of Just Concatenating Files? #39

Closed KoSpades closed 1 year ago

KoSpades commented 1 year ago

Hi, I am going through the examples, and many examples I have looked at skip the step of "each party holds a secret file, and they concatenate it together", and assume that this step is done. (for example, the id3gini.py).

My question is on how this step is done, exactly. Is there an example that shows this in action? It can be very simple, like just concatenating files and output the total number of lines in the result file.

lschoe commented 1 year ago

You can search the demos and examples for calls to mpc.input() to see how parties provide private input to a secure computation. One of the more elaborate demos to see this in action is kmsurvival.py, Starting with

https://github.com/lschoe/mpyc/blob/61752b75d63815fe991d0ccf2d4614dd2f3c0f41/demos/kmsurvival.py#L250-L252

the dataset is divided evenly between the $m$ parties running the demo, and each party computes the maximum in the times column of its rows of the dataset df[]. And a bit further down the code there is a second call to mpc.input().

Another demo to look at is multilateration.py, where the parties also prepare their private inputs in a particular way:

https://github.com/lschoe/mpyc/blob/61752b75d63815fe991d0ccf2d4614dd2f3c0f41/demos/multilateration.py#L172-L188

The demo is meant to be run with $m=5$ parties, but the modulo reduction in line 176 ensures that the demo can be run with any $m\geq1$ parties.

For simpler examples you may look at, for instance, oneliners.py and unanimous.py.