Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
8a1b641
feat: skeleton for mpcstats library and mean impl
mhchia Jun 20, 2024
83b215b
add docs and docstrings
mhchia Jun 20, 2024
88e5224
Merge pull request #1 from ZKStats/mpcstats-lib-skeleton
JernKunpittaya Jun 22, 2024
0cc81b9
feat: add join
mhchia Jun 24, 2024
3ca5ced
Merge pull request #2 from ZKStats/join
JernKunpittaya Jun 25, 2024
eb78a34
first 5 operations
JernKunpittaya Jun 25, 2024
a82bc1a
use if_else
mhchia Jun 26, 2024
003415c
Merge pull request #3 from ZKStats/more_ops
mhchia Jun 26, 2024
38b07bf
add geometric mean function
exfinen Jun 29, 2024
83d9472
remove unnecessary use of @if
exfinen Jun 30, 2024
ddff71a
revert change
exfinen Jun 30, 2024
76ea4e2
add tester
exfinen Jun 30, 2024
ead7975
dynamically generate computation function
exfinen Jun 30, 2024
9c499aa
wip
exfinen Jun 30, 2024
429db4b
wip
exfinen Jun 30, 2024
e6c241b
wip
exfinen Jun 30, 2024
5ba1dc2
factor out python statistics function call to outside computation
exfinen Jun 30, 2024
6a34dd4
change test script for ci
exfinen Jul 2, 2024
e67fd01
add ci scripts
exfinen Jul 2, 2024
0dfd5f2
add github action for geometric mean
exfinen Jul 2, 2024
3583d46
install dependencies in ci
exfinen Jul 2, 2024
7ce0af2
fix ci script
exfinen Jul 2, 2024
5de7509
wip
exfinen Jul 2, 2024
13834a6
fix ci script
exfinen Jul 2, 2024
42705d7
wip
exfinen Jul 2, 2024
8531ade
wip
exfinen Jul 2, 2024
58451a2
check out in child workflow
exfinen Jul 2, 2024
3b6f9c9
wip
exfinen Jul 2, 2024
17508e3
add jobs for other stat functions
exfinen Jul 2, 2024
22e5d7e
wip
exfinen Jul 2, 2024
1a67f3b
add debug print
exfinen Jul 2, 2024
bb83a3d
compile semi.x in child workflow
exfinen Jul 2, 2024
cc92ff0
drop ubuntu-setup.yml
exfinen Jul 2, 2024
f3f6006
remove checks from geometic mean
exfinen Jul 2, 2024
33684ac
migrate to pytest
exfinen Jul 2, 2024
ec4cf2b
Merge branch 'data61:master' into mpcstats-lib
exfinen Jul 2, 2024
99be841
wip
exfinen Jul 2, 2024
2e4d3b0
wip
exfinen Jul 2, 2024
740c4f8
checkout the repository at the beginning of steps
exfinen Jul 2, 2024
7cb7546
wip
exfinen Jul 2, 2024
1460412
limit to execute tests under repository root/tests
exfinen Jul 2, 2024
3500de0
add where test
exfinen Jul 2, 2024
590e84f
add join test
exfinen Jul 3, 2024
76801e0
clean up data load code
exfinen Jul 3, 2024
e8996a4
remove redundant code
exfinen Jul 3, 2024
54140fd
Merge pull request #4 from exfinen/add-geometric-mean
exfinen Jul 3, 2024
acd6177
Merge branch 'data61:master' into mpcstats-lib
exfinen Jul 3, 2024
0f45aff
remove unnecessary code and comment. return stdout only from run_mpcs…
exfinen Jul 3, 2024
ae49303
add join tests and fix indexing issue in the join op code
exfinen Jul 3, 2024
4fd4d68
ci: run ci on PRs
mhchia Jul 4, 2024
62cf4cc
fix comment
exfinen Jul 4, 2024
115770d
fix comment
exfinen Jul 4, 2024
a58e511
Merge pull request #5 from exfinen/add-join-tests
exfinen Jul 4, 2024
9bc63c0
fix comment
exfinen Jul 4, 2024
f12bae8
add `concurrency`
mhchia Jul 5, 2024
d2d13cf
Merge pull request #6 from ZKStats/ci/run-for-pr
mhchia Jul 5, 2024
c54a890
Merge pull request #7 from exfinen/add-one-join-test-case
exfinen Jul 5, 2024
05f054f
add mode function
exfinen Jul 10, 2024
97bc0d5
avoid creating reversed data array
exfinen Jul 11, 2024
2b8ea61
clean up
exfinen Jul 11, 2024
ddae6cb
change to use sorting scheme in mode function wip
exfinen Jul 13, 2024
4c5a631
support data with magic numbers in mode
exfinen Jul 13, 2024
eb3dff4
update comment
exfinen Jul 13, 2024
2dccd09
revert sort-based implementation with O(n^2) one w/ small improvement
exfinen Jul 13, 2024
ecadb52
Merge pull request #8 from exfinen/add-mode
exfinen Jul 15, 2024
1520688
add variance and linear_regression functions
exfinen Aug 11, 2024
b4c6151
revert changes to covariance
exfinen Aug 11, 2024
45f0fdc
use data size - 1 denominator in variance function
exfinen Aug 11, 2024
adfeaba
add test for variance
exfinen Aug 11, 2024
fdf237c
enrich variance tests and fix divisor problem
exfinen Aug 12, 2024
e6af2a2
use the same magic number indices for all columns
exfinen Aug 12, 2024
3376364
add debug output
exfinen Aug 12, 2024
cec0ae3
let covariance test use randomly generated inputs
exfinen Aug 12, 2024
69cd55f
update comment
exfinen Aug 12, 2024
57360f3
add harmonic mean
exfinen Aug 13, 2024
60b41f7
add remaining functions. use percent-based tolerance
exfinen Aug 13, 2024
04df5bb
change tolerance of harmonic mean test. return float instead of sfloa…
exfinen Aug 13, 2024
b7be3c7
avoid using float in harmonic mean
exfinen Aug 13, 2024
f504381
handle input contains 0 in harmonic mean
exfinen Aug 13, 2024
189047b
wip
exfinen Aug 13, 2024
d6c4ffd
improve comment
exfinen Aug 14, 2024
7e499de
replace sint with sfix. reflect pr comments
exfinen Aug 20, 2024
3d19367
set higher precision to sfix
exfinen Aug 20, 2024
b63a46f
make hardcoded mpspdz configuration configurable
exfinen Aug 20, 2024
3f6dc4d
Merge pull request #9 from exfinen/linear-regression
exfinen Aug 21, 2024
6ed56f6
remove commented out code
exfinen Aug 21, 2024
66fdb4e
Merge pull request #10 from exfinen/clean-up
exfinen Aug 22, 2024
346b61e
create mpcstats dir and move files there
exfinen Aug 23, 2024
6c57e18
Merge pull request #11 from exfinen/create-mpcstats-dir
exfinen Aug 23, 2024
bec6327
wip
exfinen Sep 3, 2024
169dce6
add verbose option to compile.py
exfinen Sep 3, 2024
38ff8a9
use common_lib.compile_computaiton from lib.py
exfinen Sep 3, 2024
0b39516
rename run_mpcstats_func to execute_computation and move to common_lib
exfinen Sep 3, 2024
44e62d6
add execute_silently to common_lib
exfinen Sep 3, 2024
774261f
wip
exfinen Sep 4, 2024
97c7201
add working sum computation with hardcoded config
exfinen Sep 9, 2024
3968754
wip
exfinen Sep 9, 2024
bced7e5
add mean script
exfinen Sep 10, 2024
d04d6c9
add output parser
exfinen Sep 10, 2024
81e3a76
pass options to internally called scripts
exfinen Sep 11, 2024
29ea926
add memory usage
exfinen Sep 12, 2024
9863934
add dataset gen script
exfinen Sep 12, 2024
5639d5e
parse data sent by party 0 and rounds
exfinen Sep 12, 2024
daeae34
use column as input data
exfinen Sep 12, 2024
cc26dc8
add highest level benchmarking scripts
exfinen Sep 14, 2024
930e326
instantiate computation defs from templates
exfinen Sep 14, 2024
d7be69e
add readme
exfinen Sep 14, 2024
382a5d3
wip
exfinen Sep 14, 2024
6d498ad
add comptations for most of the stat functions
exfinen Sep 14, 2024
b7ee4e1
fix problems with 2 col functions. use constatns for identical strs
exfinen Sep 14, 2024
b8205f7
wip
exfinen Sep 14, 2024
5a5573c
add scenario script
exfinen Sep 15, 2024
a87d1ad
wip
exfinen Sep 15, 2024
2dfba98
add were template
exfinen Sep 16, 2024
dd3c386
add join template
exfinen Sep 16, 2024
aac5ac6
integrate scenario.py to driver.py
exfinen Sep 16, 2024
ca8cdaf
include compile.py and make args to protocol desc
exfinen Sep 16, 2024
836e885
add all protocols including 2 non-working ones
exfinen Sep 24, 2024
6f18135
wip
exfinen Sep 24, 2024
af2102a
add header to build rep4-ring-party.x
exfinen Sep 25, 2024
610defc
add flag for spdz2k
exfinen Sep 25, 2024
d7a6b0d
add computation_defs/templates diretory
exfinen Sep 25, 2024
0995e9f
wip
exfinen Sep 25, 2024
217482f
wio
exfinen Sep 25, 2024
0a0faee
wip
exfinen Sep 25, 2024
81fa3cd
fix tests
exfinen Sep 26, 2024
9dd8ced
ad mean_incl_magic_num
exfinen Sep 26, 2024
98bfa3d
wip
exfinen Sep 26, 2024
75a4f3d
let driver activate dataset
exfinen Sep 26, 2024
9010495
add special handling for 2pdz2k
exfinen Sep 26, 2024
6c11f1f
drop unused file
exfinen Sep 26, 2024
1d7ce88
check if program file exists
exfinen Sep 26, 2024
b5fc74f
make num parties a parameter todriver.sh
exfinen Sep 27, 2024
34ead5d
add remote option
exfinen Oct 1, 2024
b3826c6
ignore HOSTS
exfinen Oct 1, 2024
13a562b
make remote str
exfinen Oct 1, 2024
e0b258b
use args.remote when the value is 0 as well
exfinen Oct 1, 2024
2381e7d
use args.remote when the value is 0 as well
exfinen Oct 1, 2024
7273a48
add LD_LIBRARY_PATH when running remote mpc
exfinen Oct 1, 2024
c8a9e7b
wip
exfinen Oct 1, 2024
caabcc5
wip
exfinen Oct 1, 2024
282dd20
wip
exfinen Oct 1, 2024
21589c0
wip
exfinen Oct 1, 2024
d5288b9
return stdout and stderr
exfinen Oct 1, 2024
5c0daf4
add -v to remote exec
exfinen Oct 1, 2024
6c4da73
conditionally add "result" to output
exfinen Oct 1, 2024
683630c
add N/A when result is not available
exfinen Oct 1, 2024
8521efa
wip
exfinen Oct 2, 2024
4b4dc1b
remove -N option for rep-field protocols
exfinen Oct 2, 2024
45c2bab
use vm name instead of protocol name for remote execution
exfinen Oct 2, 2024
193f736
add finer-grained verbose option
exfinen Oct 2, 2024
7bc5981
wip
exfinen Oct 2, 2024
82d3670
wip
exfinen Oct 2, 2024
8714ba0
wip
exfinen Oct 2, 2024
fcbb8a4
wip
exfinen Oct 2, 2024
afe82f0
wip
exfinen Oct 2, 2024
593cfaa
remote -N from all rep protocols
exfinen Oct 2, 2024
c399c30
wip
exfinen Oct 2, 2024
e727db2
wip
exfinen Oct 2, 2024
7a62ca5
wip
exfinen Oct 2, 2024
1ca28f2
wip
exfinen Oct 2, 2024
647da60
wip
exfinen Oct 2, 2024
c084f7d
wip
exfinen Oct 2, 2024
6577fcf
wip
exfinen Oct 2, 2024
2023c33
wip
exfinen Oct 5, 2024
7b0e82c
wip
exfinen Oct 7, 2024
57aa8dc
wip
exfinen Oct 7, 2024
4b59a6e
wip
exfinen Oct 7, 2024
7a7a4dd
wip
exfinen Oct 7, 2024
c8ea4f5
make base port number configurable
exfinen Oct 7, 2024
0b03639
wip
exfinen Oct 7, 2024
bff6084
wip
exfinen Oct 8, 2024
eab1fd8
wip
exfinen Oct 8, 2024
1724f81
wip
exfinen Oct 8, 2024
fbfe660
wip
exfinen Oct 8, 2024
f8980e9
wip
exfinen Oct 8, 2024
688689c
wip
exfinen Oct 8, 2024
e0a9515
wip
exfinen Oct 8, 2024
26c7772
support tlsn
exfinen Oct 10, 2024
78d2000
make Circuits dir by script
exfinen Oct 10, 2024
ce2292d
add tlsn test datasets
exfinen Oct 10, 2024
03c834e
fix make Programs/Circuits
exfinen Oct 10, 2024
35d147e
wip
exfinen Oct 10, 2024
c65ce85
wip
exfinen Oct 10, 2024
7ac800c
wip
exfinen Oct 10, 2024
96e5abf
wip
exfinen Oct 12, 2024
94f70ba
wip
exfinen Oct 12, 2024
e5b4699
wip
exfinen Oct 12, 2024
f6a1ac1
wip
exfinen Oct 12, 2024
04d34b2
wip
exfinen Oct 12, 2024
63ce459
wip
exfinen Oct 12, 2024
fba1f84
wip
exfinen Oct 12, 2024
96b516e
wip
exfinen Oct 12, 2024
486e660
wip
exfinen Oct 12, 2024
34dc785
wip
exfinen Oct 13, 2024
e97fbe6
wip
exfinen Oct 13, 2024
134b8d2
wip
exfinen Oct 13, 2024
2335c8b
wip
exfinen Oct 14, 2024
51852f6
wip
exfinen Oct 15, 2024
5983020
wip
exfinen Oct 15, 2024
fe9dcee
wip
exfinen Oct 15, 2024
d72c87e
add optimization flags
exfinen Oct 15, 2024
f34ac95
add optimization flags
exfinen Oct 15, 2024
b8dd286
wip
exfinen Oct 15, 2024
85c6545
wip
exfinen Oct 15, 2024
49cdee0
wip
exfinen Oct 15, 2024
7c9b320
wip
exfinen Oct 15, 2024
845ccfa
wip
exfinen Oct 15, 2024
031223f
wip
exfinen Oct 15, 2024
b13e8e6
wip
exfinen Oct 15, 2024
1ce7ae1
wip
exfinen Oct 16, 2024
a3c0a9e
wip
exfinen Oct 16, 2024
2ef5e8a
wip
exfinen Oct 16, 2024
224b60b
wip
exfinen Oct 16, 2024
7d788d0
use range_for in _mean
exfinen Oct 16, 2024
8307270
wip
exfinen Oct 16, 2024
cb469f2
wip
exfinen Oct 17, 2024
15a0eed
wip
exfinen Oct 17, 2024
e9a2fb6
wip
exfinen Oct 17, 2024
7a8e43d
wip
exfinen Oct 17, 2024
e1e220a
wip
exfinen Oct 17, 2024
f397159
wip
exfinen Oct 17, 2024
d22e2e3
wip
exfinen Oct 17, 2024
ddc12a7
wip
exfinen Oct 17, 2024
cda7c08
wip
exfinen Oct 17, 2024
5fd4711
wip
exfinen Oct 17, 2024
bf4cd8b
wip
exfinen Oct 17, 2024
4d1eee0
wip
exfinen Oct 17, 2024
eec7fc6
wip
exfinen Oct 17, 2024
4f43aed
wip
exfinen Oct 18, 2024
1155a6e
wip
exfinen Oct 18, 2024
0c218f6
wip
exfinen Oct 18, 2024
6abe736
wip
exfinen Oct 18, 2024
74e72e5
wip
exfinen Oct 18, 2024
04e5d75
wip
exfinen Oct 18, 2024
75831c7
wip
exfinen Oct 18, 2024
dd5be9e
wip
exfinen Oct 19, 2024
0912225
wip
exfinen Oct 20, 2024
dc2f24b
Merge pull request #18 from exfinen/benchmarker
exfinen Nov 19, 2024
8c0d862
add result spreadsheets
exfinen Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/mpcstats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: mpcstats

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-on-ubuntu-latest:
runs-on: ubuntu-latest
steps:
- name: Check out MP-SPDZ
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'

- name: Install Python dependencies
run: pip install -r requirements.txt

- name: Install MP-SPDZ dependencies
run: sudo apt-get install -y automake build-essential clang cmake git libboost-dev libboost-iostreams-dev libboost-thread-dev libgmp-dev libntl-dev libsodium-dev libssl-dev libtool

- name: Build MP-SPDZ
run: make setup

- name: Build semi-party.x
run: make -j8 semi-party.x

- name: Run tests
run: cd mpcstats && pytest tests -v
1 change: 1 addition & 0 deletions GC/Rep4Prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "Protocols/Rep4.hpp"
#include "Protocols/Rep4Input.hpp"
#include "Protocols/Replicated.hpp"
#include "Protocols/ReplicatedPrep.hpp"

namespace GC
Expand Down
2 changes: 2 additions & 0 deletions Scripts/logs/--help-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Using SPDZ2k security parameter 64
libc++abi: terminating due to uncaught exception of type file_error: File Error : Missing 'Programs/Schedules/--help.sch'. Did you compile '--help'?
2 changes: 2 additions & 0 deletions Scripts/logs/--help-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Using SPDZ2k security parameter 64
libc++abi: terminating due to uncaught exception of type file_error: File Error : Missing 'Programs/Schedules/--help.sch'. Did you compile '--help'?
2 changes: 2 additions & 0 deletions Scripts/logs/-h-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Using SPDZ2k security parameter 64
libc++abi: terminating due to uncaught exception of type file_error: File Error : Missing 'Programs/Schedules/13784.sch'. Did you compile '13784'?
2 changes: 2 additions & 0 deletions Scripts/logs/-h-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Using SPDZ2k security parameter 64
libc++abi: terminating due to uncaught exception of type file_error: File Error : Missing 'Programs/Schedules/13784.sch'. Did you compile '13784'?
2 changes: 1 addition & 1 deletion deps/libOTe
5 changes: 5 additions & 0 deletions mpcstats/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Player-Data/
logs/
Programs/
!Programs/Circuits/
!Programs/Source/
37 changes: 37 additions & 0 deletions mpcstats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# MPCStats Library

## Installation
Clone the repo.

```bash
git clone https://github.com/ZKStats/MP-SPDZ
cd MP-SPDZ
```

Install dependencies.

```bash
make setup
```

Build the MPC vm for `semi` protocol

```bash
make -j8 semi-party.x
# Make sure `semi-party.x` exists
ls semi-party.x
```

If you're on macOS and see the following linker warning, you can safely ignore it:

```bash
ld: warning: search path '/usr/local/opt/openssl/lib' not found
```

## Run
```bash
python main.py
```

## Implementation
Statistics operations implementation is in [mpcstats_lib.py](./mpcstats_lib.py).
9 changes: 9 additions & 0 deletions mpcstats/benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Player-Data/
Programs/
logs/
!Programs/Circuits/
!Programs/Source/
computation_defs/*
!computation_defs/templates/
*.csv
HOSTS
9 changes: 9 additions & 0 deletions mpcstats/benchmark/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: clean

clean:
rm -rf Player-Data
rm -rf Programs
rm -rf Public-Input
rm -rf Schedules
rm -rf logs

103 changes: 103 additions & 0 deletions mpcstats/benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# MPCStats Benchmarking

## Preparation

### Protocols definitions
First specify which protocols to use for benchmarking in:
`./protocols.py`

For each protocol used, the associated `.x` file needs to be built. To do this, run `./gen_vms.py`

### Datasets for benchmarking
Next create the datasets to be used for benchmarking in `./datasets`.
The datasets should be in CSV format without a header line.
datasets whose names start with '_' are ignored.

#### Dataset generation script
You can use `./gen_dataset.py` to randomly generate datasets for benchmarking purposes.

### Computation defintions
Lastly, define the computations to be benchmarked in `./computation_defs/templates`.

By executing `./gen_comp_defs.py`, computaion definition instances for all dataset and template combinations will be created in the `./computations_defs` directory.

Computation definitions whose names start with '_' are ignored.

### Setting up ssl
On party 0 host, in `mpcstats/benchmark` directory, run:

```
../../Scripts/setup-ssl.sh 3
```

Then, copy `Player-Data/P{0,1,2}.{pem,key}` to the other party hosts as explained below.

```
The certificates should be the same on every host. Also make sure that it's still valid. Certificates generated with `Scripts/setup-ssl.sh` expire after a month.
```

```bash
scp pse-eu:'MP-SPDZ/mpcstats/benchmark/Player-Data/*.pem' .
scp pse-eu:'MP-SPDZ/mpcstats/benchmark/Player-Data/*.key' .
scp *.pem pse-us:MP-SPDZ/mpcstats/benchmark/Player-Data
scp *.key pse-us:MP-SPDZ/mpcstats/benchmark/Player-Data
scp *.pem pse-asia:MP-SPDZ/mpcstats/benchmark/Player-Data
scp *.key pse-asia:MP-SPDZ/mpcstats/benchmark/Player-Data
```

Fianlly, call `c_rehash` on the machines to which the pem/key files are copied

```
c_rehash MP-SPDZ/mpcstats/benchmark/Player-Data
```


## Running the benchmark
Execute the `./driver.py [scenario ID]` to run the benchmarks and output the results as a CSV to stdout.

To get the list of secnario IDs, run:

```
./driver.sh -h
```

### Setting up a remote machine
Assuming a Ubuntu 24.04, x86, 64-bit instance

- Install necessary libraries
```
sudo apt update
sudo apt-get install -y automake build-essential clang cmake git libboost-all-dev libgmp-dev libntl-dev libsodium-dev libssl-dev libtool python3
```

- Install MP-SPDZ
```
git clone https://github.com/exfinen/MP-SPDZ.git
cd MP-SPDZ
git checkout benchmarker
```

- Copy `*.so` files
Copy `MP-SPDZ/libFHE.so` amd `MPSPDZ/libSPDZ.so` to the new remote machine

- Copy `*.x` files
Copy `MP-SPDZ/*.x` to the new remote machine

- Add `*.so` files to the library search path
Add `export LD_LIBRARY_PATH=<MP-SPDZ directory>` to `.bashrc` or a similar configuration file

### Preparing HOSTS file
Create `MP-SPDZ/HOSTS` of the following contents:

```
<Party 0 IP>
<Party 1 IP>
<Party 2 IP>
...
```

Also make sure that you use correct party number on each party machine.

For example, if you use party number 1 on party-2 machine, MPC will not function. Each party has an assigned port number that is the base port number + party number.

In such a case, if the base port number is the default 5000, party 2 will try to connect to itself using port 5001, but the vm is listening to port 5002 on part-2 machine.
Loading