This repository contains the client-side code for testing the secure median algorithm implemented within the Federated Secure Computing framework and SIMON. The related publication "A Secure Median Implementation for the Federated Secure Computing Architecture" can be found here. Below are detailed instructions for running the code in a local deployment (Windows users should use WSL).
To install the required packages and dependencies, follow the steps below:
pip install federatedsecure-server
pip install federatedsecure-simon
pip install connexion[flask,uvicorn,swagger-ui]
git clone https://github.com/federatedsecure/webserver-connexion
pip install federatedsecure-client
pip install pandas
To test the implementation for two clients in a local deployment, where each client runs its own server to calculate the median of arrays of random numbers, follow these steps:
- Start two servers on localhost, running on ports
55500
and55501
(you can use different ports if needed):
cd webserver-connexion/src
python __main__.py port=55500 &
python __main__.py port=55501 &
- Configure the servers in the servers.cfg file:
[UUID]
uuid=29854ef6-055d-4044-baf4-1378530ea037
[SERVER1]
host = http://127.0.0.1
port = 55500
[SERVER2]
host = http://127.0.0.1
port = 55501
- UUID refers to a unique identifier (you can use the provided one or generate a new UUID).
- The host is set to
http://127.0.0.1
, indicating the servers are running on localhost. - The ports are set to
55500
and55501
, corresponding to the servers' ports we specified previously.
- Run the benchmarking script (
benchmark_rand.py
) for each client in parallel. The script requires three arguments:
- Arg1: The client index (e.g.,
0
for client 1 and1
for client 2). - Arg2: The upper range of random numbers (e.g.,
100
generates numbers in the range of1
to100
). - Arg3: The number of elements for each party (e.g.,
100
generates 100 numbers per party).
To run the benchmarking for 200 inputs (100 per client within the range of 1
to 100
) in a new terminal window run:
python src/benchmark_rand.py 0 100 100 &
python src/benchmark_rand.py 1 100 100
Note: To increase the number of clients, start additional servers and add them to the servers.cfg
file.
- Start two servers as outlined in the previous section.
- Add both servers to the
servers.cfg
file. - Run the benchmarking script (
benchmark_ucml.py
) with the following arguments:- Arg1: The index of the client (e.g.,
0
or1
). - Arg2: The filename corresponding to the client (e.g.,
breast_cancer_wisconsin_diagnostic_1.csv
). - Arg3: The column over which to calculate the median (e.g.,
radius1
).
- Arg1: The index of the client (e.g.,
python src/benchmark_ucml.py 0 data/breast_cancer_wisconsin_diagnostic_1.csv radius1 &
python src/benchmark_ucml.py 1 data/breast_cancer_wisconsin_diagnostic_2.csv radius1
- Start four servers as described in the previous section.
- Add all four servers to the
servers.cfg
file. - Run the benchmarking script (
benchmark_ucml.py
) with the following arguments:- Arg1: The index of the client (e.g.,
0
,1
,2
, or3
). - Arg2: The filename corresponding to the client (e.g.,
heart_disease_cleveland.csv
). - Arg3: The column over which to calculate the median (e.g.,
age
).
- Arg1: The index of the client (e.g.,
python src/benchmark_ucml.py 0 heart_disease_cleveland.csv age &
python src/benchmark_ucml.py 1 heart_disease_hungarian.csv age &
python src/benchmark_ucml.py 2 heart_disease_switzerland.csv age &
python src/benchmark_ucml.py 3 heart_disease_va.csv age