The ExternalIO directory contains an example of managing I/O between external client processes and parties running MP-SPDZ engines. These instructions assume that MP-SPDZ has been built as per the project readme.
bankers-bonus-client.cpp and bankers-bonus-client.py act as a client to bankers_bonus.mpc and demonstrates sending input and receiving output as described by Damgård et al. The computation allows up to eight clients to input a number and computes the client with the largest input. You can run the C++ code as follows from the main directory:
make bankers-bonus-client.x
./compile.py bankers_bonus 1
Scripts/setup-ssl.sh <nparties>
Scripts/setup-clients.sh 3
PLAYERS=<nparties> Scripts/<protocol>.sh bankers_bonus-1 &
./bankers-bonus-client.x 0 <nparties> 100 0 &
./bankers-bonus-client.x 1 <nparties> 200 0 &
./bankers-bonus-client.x 2 <nparties> 50 1
<protocol>
can be any arithmetic protocol (e.g., mascot
) but not a
binary protocol (e.g., yao
).
This should output that the winning id is 1. Note that the ids have to
be incremental, and the client with the highest id has to input 1 as
the last argument while the others have to input 0 there. Furthermore,
<nparties>
refers to the number of parties running the computation
not the number of clients, and <protocol>
can be the name of
protocol script. The setup scripts generate the necessary SSL
certificates and keys. Therefore, if you run the computation on
different hosts, you will have to distribute the *.pem
files.
For the Python client, make sure to install
gmpy2, and run
ExternalIO/bankers-bonus-client.py
instead of
bankers-bonus-client.x
.
Only the sint
methods used in the example are documented here, equivalent methods are available for other data types. See the reference.
The example uses the Client
class implemented in
ExternalIO/Client.hpp
to handle the communication, see
this reference for
documentation.