# A Secure Median Implementation for the Federated Secure Computing Architecture
## 3 Materials and Methods
### Implementation
#### 3.2.2 Client Setup

Client setup is easily implementable in Python and for two parties, a function to compute the median is displayed in Listing 4 (The full client-side code used here is available under [[https://github.com/federatedsecure/publications/tree/main/secure-median](https://github.com/federatedsecure/publications/tree/main/secure-median)]([https://github.com/federatedsecure/publications/tree/main/secure-median](https://github.com/federatedsecure/publications/tree/main/secure-median)), last accessed: 20 August 2024). ```
1 importfederatedsecure.client
2 defsecure_median(my_data,my_index)
4#therearetwoFederatedSecureComputingservers
5 SERVER_PARITY_1=\"[[http://127.0.0.1:55500](http://127.0.0.1:55500)]([http://127.0.0.1:55500](http://127.0.0.1:55500))\"
6 SERVER_PARITY_2=\"[[http://127.0.0.1:55501](http://127.0.0.1:55501)]([http://127.0.0.1:55501](http://127.0.0.1:55501))\"
7
8#thepeer-to-peernetworkisdefinedbythenodesand
9#byauniquedientifierforthisparticularcalculation
10 SHARED_NUDES=[SERVER_PARITY_1,SERVER_PARITY_2]
11 SHARED_NUID=\"c54 ebeb59-b780-4878-9647-b0867 dcac6635\"
12
13#eachclientconnectsto'their'node
14#here,my_indexiseither0 or1
15 my_node=SHARED_NUDES[my_index]
16 my_network={\"nodes',SHARED_NUDES,
17'build':SHARED_NUID,
18'myself':my_index}
19#theclientconnectstotheAPIoftheirnode
2 api=federatedsecure.client.Api(my_node)
20
21#theclientrequentsSimon,anMPCCmicroservice
22 microservice=api.create(protocol=\"Simon\")
23
24#theserverisaskedtocomputethemedian
25#usingthe\"SecureMedian\"microprotocolresult=\"microservice.compute(
26 microservice1=\"SecureMedian\",
27 data=my_data,
28 network=my_network)
29#theresultofthecomputationisdownloadedotheclientand
30#printed
31 print(api.download(result))
```

Listing 4: An exemplary client script for computing the secure median. Each party has to call this function, providing their respective data as an array and the corresponding member index. #### 3.2.3 Test Data

We generated synthetic data as arrays of varying sizes and data ranges by systematically varying the size from \(10^{2}\) to \(10^{7}\) and the range from \(10^{1}\) to \(10^{3}\) using Pythons own _random.randint()_ function while ensuring the inclusion of both the lower and upper bounds of the respective range. Public Dataset on Breast Cancer

We utilized a publicly available breast cancer dataset obtained from the University of Wisconsin Hospital, Madison, WI, USA. This dataset, comprising 569 samples, includes features related to breast cancer diagnosis, such as radius, texture, perimeter, area, smoothness, compactness, concavity, symmetry, and fractal dimension. Specifically, we focused on the \"Radius1\" feature for our evaluation. To simulate a dual-centric study, we divided the dataset into two portions, each containing 284 and 285 samples, respectively. Similarly, to simulate a multicentric study, we utilized a public heart disease dataset. This dataset encompasses a total of 920 patients in four databases recorded in four university hospitals: the Cleveland Clinic in Cleveland, OH, USA (303 patients), the Hungarian Institute of Cardiology in Budapest, Hungary (294 patients), the Veterans Administration Medical Center in Long Beach, CA, USA (200 patients) and the University Hospitals in Zurich and Basel, Switzerland (123 patients). The dataset features a variety of attributes, including age, sex, chest pain type, resting blood pressure, serum cholesterol levels, maximum heart rate achieved during exercise, and the presence of specific electrocardiographic abnormalities. We focused our analysis primarily on the \"age\" column. ## 4 Results

The following results are based on both local deployment to eliminate networking overhead and AWS EC2 instances deployed in several regions to simulate a real-world scenario.