Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ABY #63

Merged
merged 8 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions aby/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
FROM ubuntu:16.04
FROM ubuntu:22.04
WORKDIR /root
RUN apt-get update && apt-get install -y \
git \
lzip \
m4 \
make \
cmake \
g++ \
libgmp-dev \
libglib2.0-dev \
libssl-dev \
libboost-all-dev \
software-properties-common \
vim \
wget

ADD source/ /root/source
ADD README.md .

ADD install_dependencies.sh .
RUN ["bash", "install_dependencies.sh"]

ADD install.sh .
RUN ["bash", "install.sh"]

ADD test_readme.sh .

CMD ["/bin/bash"]

10 changes: 5 additions & 5 deletions aby/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ABY

[ABY](https://github.com/encryptogroup/ABY) is a mixed-protocol two-party computation framework implemented as a C++ library. It aims to give developers fine-grained control over computation efficiency bby providing a mechanism for mixing protocols.
ABY switches between three protocols: a GMW-based __A__rithmetic protocol that uses an additive sharing scheme with multiplicative triplets; a __B__oolean-circuit based implementation fo the original GMW protocol using an XOR-baseds ecret sharing scheme; and an optimized version of __Y__ao's garbled circuit protocol, also over a Boolean circuit.
ABY switches between three protocols: a GMW-based _A_rithmetic protocol that uses an additive sharing scheme with multiplicative triplets; a _B_oolean-circuit based implementation fo the original GMW protocol using an XOR-baseds ecret sharing scheme; and an optimized version of _Y_ao's garbled circuit protocol, also over a Boolean circuit.

ABY was developed by Daniel Demmler, Thomas Schneider and Michael Zohner in the [ENCRYPTO group](https://www.encrypto.informatik.tu-darmstadt.de/encrypto/) at TU Darmstadt.

Expand All @@ -23,7 +23,7 @@ Please note that any changes you make in the container are not persistent.

ABY is roughly architected as a C++ library. It defines several classes that
implement the MPC protocol. It is written in an object-oriented style.
Secure data is limited to unsigned C integer types (no arbitrary-length integers or an explicit Boolen type, though it does support 1-bit integers). Support for floating (fixed?)-point operations are under active development. ABY can tore secure data in a C struct and supports both C++ arrays and SIMD constructiosn for efficient parallelization, though retrieving individual elements out of a SIMD share is not well-supported.
Secure data is limited to unsigned C integer types (no arbitrary-length integers or an explicit Boolen type, though it does support 1-bit integers). Support for floating (fixed?)-point operations are under active development. ABY can store secure data in a C struct and supports both C++ arrays and SIMD constructions for efficient parallelization, though retrieving individual elements out of a SIMD share is not well-supported.

Most examples have a similar format:
- `<ex>_test.cpp` file reads input and sets parameters
Expand All @@ -35,10 +35,10 @@ manipulated by `gate` operations in a `Circuit`.

## Running examples
To run our examples, you'll need to generate input. We've written input
generation scripts for `mult3`. It will tell you what the expected result is.
Data is stored in the `ABY/src/examples/<ex>/data` directory.
generation scripts for `mult3` and `innerprod`. It will tell you what the expected result is.
Data are stored in the `ABY/src/examples/<ex>/data` directory.
```
$ python ~/ABY/src/examples/geninput.py -e <ex>
$ python3 ~/ABY/src/examples/geninput.py -e <ex>
Expected result: 621
```

Expand Down
3 changes: 2 additions & 1 deletion aby/install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/sh

# get ABY
git clone --recursive https://github.com/encryptogroup/ABY.git
cd ABY
git checkout -b MPCSOK 08baa853de76a9070cb8ed8d41e96569776e4773
git checkout -b MPCSOK d8e69414d091cafc007e65a03ef30768ebaf723d

# copy our working examples
for EX in mult3 crosstabs innerprod
Expand Down
29 changes: 0 additions & 29 deletions aby/install_dependencies.sh

This file was deleted.

4 changes: 2 additions & 2 deletions aby/source/crosstabs/common/crosstabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ int32_t test_crosstabs_circuit(e_role role, char* address, uint16_t port, seclvl

for(int i=0; i<BINS; i++) {
output = s_out[i]->get_clear_value<uint32_t>();
cout << "Bin " << i << ":\t" << output << endl;
cout << "Expect:\t" << expected_results[i] << endl;
cout << "Bin " << i << ":\t" << output;
cout << ", expect:\t" << expected_results[i] << endl;
}

delete party;
Expand Down
14 changes: 8 additions & 6 deletions aby/source/geninput.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# this file should live in the examples directory

import random, argparse, os, math
HOME='/root/ABY/src/examples/'
import random, argparse, os, math, errno
HOME = '/root/ABY/src/examples/'

def create_dirs(program):
dirname = HOME + program + "/data"
Expand All @@ -13,13 +13,15 @@ def create_dirs(program):

def gen_mult3_input():
# 5 bit inputs for a max of 16 bit result
BITS = 5;
BITS = 5
f0 = open(HOME+"mult3/data/mult3.0.dat",'w+')
f1 = open(HOME+"mult3/data/mult3.1.dat",'w+')

product = 1
for _ in range(3):
x = random.getrandbits(BITS)
x = 0
while x == 0:
x = random.getrandbits(BITS)
left = random.randrange(x)

f0.write("%d\n"%(x-left))
Expand All @@ -33,7 +35,7 @@ def gen_mult3_input():
print("Expected result: %d"%product)

def gen_innerprod_input(l):
BITS = (16 - int(math.log(10,2))) / 2
BITS = (16 - int(math.log(10,2))) // 2

xs = [random.getrandbits(BITS) for _ in range(l)]
ys = [random.getrandbits(BITS) for _ in range(l)]
Expand Down Expand Up @@ -73,5 +75,5 @@ def gen_innerprod_input(l):
gen_innerprod_input(args.l)

elif args.e == "xtabs":
print "xtabs not yet implemented"
print("xtabs not yet implemented")

31 changes: 31 additions & 0 deletions aby/test_readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

set -ex

# Test mult3 and innerprod, for which geninput.py can generate inputs
for ex in mult3 innerprod; do
EXPECTED=$(python3 ABY/src/examples/geninput.py -e "$ex" | grep -Eo "[0-9]+")
cd ABY/build
./bin/"$ex"_test -r 0 &
ACTUAL=$(./bin/"$ex"_test -r 1 | grep "Circuit Result:" | grep -Eo "[0-9]+")
if [ "$ACTUAL" -ne "$EXPECTED" ]; then
echo "$ex: Expected $EXPECTED but got $ACTUAL"
exit 1
fi
cd ../..
done

# Test crosstabs

cd ABY/build
./bin/crosstabs_test -r 0 &
./bin/crosstabs_test -r 1 | grep "expect:" | while read -r OUT_LINE ; do
BIN=$(echo "$OUT_LINE" | grep -Eo "[0-9]+" | sed '1q;d')
ACTUAL=$(echo "$OUT_LINE" | grep -Eo "[0-9]+" | sed '2q;d')
EXPECTED=$(echo "$OUT_LINE" | grep -Eo "[0-9]+" | sed '3q;d')
if [ "$ACTUAL" -ne "$EXPECTED" ]; then
echo "crosstabs: Bin $BIN: expected $EXPECTED but got $ACTUAL"
exit 1
fi
done
cd ../..