Skip to content

Commit

Permalink
update mp-spdz version
Browse files Browse the repository at this point in the history
  • Loading branch information
xiezy0 committed Mar 13, 2023
1 parent 2be2002 commit a4e52b0
Show file tree
Hide file tree
Showing 1,802 changed files with 17,479 additions and 5,197 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/server
/server/*

/opt
/opt
/local
/cmake-3.24.1
/bin
/deps
/doc
/logs
/venv
/Programs
Empty file modified BMR/AndJob.cpp
100755 → 100644
Empty file.
Empty file modified BMR/AndJob.h
100755 → 100644
Empty file.
Empty file modified BMR/BooleanCircuit.h
100755 → 100644
Empty file.
Empty file modified BMR/CommonParty.cpp
100755 → 100644
Empty file.
Empty file modified BMR/CommonParty.h
100755 → 100644
Empty file.
Empty file modified BMR/CommonParty.hpp
100755 → 100644
Empty file.
Empty file modified BMR/GarbledGate.cpp
100755 → 100644
Empty file.
Empty file modified BMR/GarbledGate.h
100755 → 100644
Empty file.
Empty file modified BMR/Gate.h
100755 → 100644
Empty file.
Empty file modified BMR/Key.cpp
100755 → 100644
Empty file.
Empty file modified BMR/Key.h
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions BMR/Party.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ FakeProgramParty::FakeProgramParty(int argc, const char** argv) :
}
cout << "Compiler: " << prev << endl;
P = new PlainPlayer(N, 0);
Share<gf2n_long>::MAC_Check::setup(*P);
if (argc > 4)
threshold = atoi(argv[4]);
cout << "Threshold for multi-threaded evaluation: " << threshold << endl;
Expand Down Expand Up @@ -280,6 +281,7 @@ FakeProgramParty::~FakeProgramParty()
cerr << "Dynamic storage: " << 1e-9 * dynamic_memory.capacity_in_bytes()
<< " GB" << endl;
#endif
Share<gf2n_long>::MAC_Check::teardown();
}

void FakeProgramParty::_compute_prfs_outputs(Key* keys)
Expand Down
Empty file modified BMR/Party.h
100755 → 100644
Empty file.
Empty file modified BMR/ProgramParty.hpp
100755 → 100644
Empty file.
2 changes: 0 additions & 2 deletions BMR/RealGarbleWire.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class RealGarbleWire : public PRFRegister
static void inputbvec(GC::Processor<GC::Secret<RealGarbleWire>>& processor,
ProcessorBase& input_processor, const vector<int>& args);

RealGarbleWire(const Register& reg) : PRFRegister(reg) {}

void garble(PRFOutputs& prf_output, const RealGarbleWire<T>& left,
const RealGarbleWire<T>& right);

Expand Down
2 changes: 1 addition & 1 deletion BMR/RealGarbleWire.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void RealGarbleWire<T>::inputbvec(
{
GarbleInputter<T> inputter;
processor.inputbvec(inputter, input_processor, args,
inputter.party.P->my_num());
*inputter.party.P);
}

template<class T>
Expand Down
Empty file modified BMR/RealProgramParty.h
100755 → 100644
Empty file.
8 changes: 4 additions & 4 deletions BMR/RealProgramParty.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
online_opts = {opt, argc, argv, 1000};
else
online_opts = {opt, argc, argv};
assert(not online_opts.interactive);

online_opts.finalize(opt, argc, argv);
this->load(online_opts.progname);
Expand Down Expand Up @@ -97,8 +96,6 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
if (online_opts.live_prep)
{
mac_key.randomize(prng);
if (T::needs_ot)
BaseMachine::s().ot_setups.push_back({*P, true});
prep = new typename T::LivePrep(0, usage);
}
else
Expand All @@ -107,10 +104,12 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
prep = new Sub_Data_Files<T>(N, prep_dir, usage);
}

T::MAC_Check::setup(*P);
MC = new typename T::MAC_Check(mac_key);

garble_processor.reset(program);
this->processor.open_input_file(N.my_num(), 0);
this->processor.open_input_file(N.my_num(), 0, online_opts.cmd_private_input_file);
this->processor.setup_redirection(P->my_num(), 0, online_opts, this->processor.out);

shared_proc = new SubProcessor<T>(dummy_proc, *MC, *prep, *P);

Expand Down Expand Up @@ -218,6 +217,7 @@ RealProgramParty<T>::~RealProgramParty()
delete garble_inputter;
delete garble_protocol;
cout << "Data sent = " << data_sent * 1e-6 << " MB" << endl;
T::MAC_Check::teardown();
}

template<class T>
Expand Down
Empty file modified BMR/Register.cpp
100755 → 100644
Empty file.
25 changes: 4 additions & 21 deletions BMR/Register.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Register {
* for pipelining matters.
*/

Register(int n_parties);
Register();

void init(int n_parties);
void init(int rfd, int n_parties);
Expand Down Expand Up @@ -235,6 +235,9 @@ class Phase
template <class T>
static void ands(T& processor, const vector<int>& args) { processor.ands(args); }
template <class T>
static void andrsvec(T& processor, const vector<int>& args)
{ processor.andrsvec(args); }
template <class T>
static void xors(T& processor, const vector<int>& args) { processor.xors(args); }
template <class T>
static void inputb(T& processor, const vector<int>& args) { processor.input(args); }
Expand Down Expand Up @@ -278,10 +281,6 @@ class ProgramRegister : public Phase, public Register

static int threshold(int) { throw not_implemented(); }

static Register new_reg();
static Register tmp_reg() { return new_reg(); }
static Register and_reg() { return new_reg(); }

template<class T>
static void store(NoMemory& dest,
const vector<GC::WriteAccess<T> >& accesses) { (void)dest; (void)accesses; }
Expand All @@ -306,8 +305,6 @@ class ProgramRegister : public Phase, public Register
void other_input(Input&, int) {}

char get_output() { return 0; }

ProgramRegister(const Register& reg) : Register(reg) {}
};

class PRFRegister : public ProgramRegister
Expand All @@ -319,8 +316,6 @@ class PRFRegister : public ProgramRegister
static void load(vector<GC::ReadAccess<T> >& accesses,
const NoMemory& source);

PRFRegister(const Register& reg) : ProgramRegister(reg) {}

void op(const PRFRegister& left, const PRFRegister& right, Function func);
void XOR(const Register& left, const Register& right);
void input(party_id_t from, char input = -1);
Expand Down Expand Up @@ -396,8 +391,6 @@ class EvalRegister : public ProgramRegister
static void convcbit(Integer& dest, const GC::Clear& source,
GC::Processor<GC::Secret<EvalRegister>>& proc);

EvalRegister(const Register& reg) : ProgramRegister(reg) {}

void op(const ProgramRegister& left, const ProgramRegister& right, Function func);
void XOR(const Register& left, const Register& right);

Expand Down Expand Up @@ -427,8 +420,6 @@ class GarbleRegister : public ProgramRegister
static void load(vector<GC::ReadAccess<T> >& accesses,
const NoMemory& source);

GarbleRegister(const Register& reg) : ProgramRegister(reg) {}

void op(const Register& left, const Register& right, Function func);
void XOR(const Register& left, const Register& right);
void input(party_id_t from, char value = -1);
Expand All @@ -452,8 +443,6 @@ class RandomRegister : public ProgramRegister
static void load(vector<GC::ReadAccess<T> >& accesses,
const NoMemory& source);

RandomRegister(const Register& reg) : ProgramRegister(reg) {}

void randomize();

void op(const Register& left, const Register& right, Function func);
Expand All @@ -469,12 +458,6 @@ class RandomRegister : public ProgramRegister
};


inline Register::Register(int n_parties) :
garbled_entry(n_parties), external(NO_SIGNAL),
mask(NO_SIGNAL), keys(n_parties)
{
}

inline void KeyVector::operator=(const KeyVector& other)
{
resize(other.size());
Expand Down
12 changes: 2 additions & 10 deletions BMR/Register.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ void ProgramRegister::inputbvec(T& processor, ProcessorBase& input_processor,
const vector<int>& args)
{
NoOpInputter inputter;
int my_num = -1;
try
{
my_num = ProgramParty::s().P->my_num();
}
catch (exception&)
{
}
processor.inputbvec(inputter, input_processor, args, my_num);
processor.inputbvec(inputter, input_processor, args, *ProgramParty::s().P);
}

template<class T>
Expand All @@ -31,7 +23,7 @@ void EvalRegister::inputbvec(T& processor, ProcessorBase& input_processor,
{
EvalInputter inputter;
processor.inputbvec(inputter, input_processor, args,
ProgramParty::s().P->my_num());
*ProgramParty::s().P);
}

template <class T>
Expand Down
6 changes: 3 additions & 3 deletions BMR/Register_inline.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include "CommonParty.h"
#include "Party.h"


inline Register ProgramRegister::new_reg()
inline Register::Register() :
garbled_entry(CommonParty::s().get_n_parties()), external(NO_SIGNAL),
mask(NO_SIGNAL), keys(CommonParty::s().get_n_parties())
{
return Register(CommonParty::s().get_n_parties());
}

#endif /* BMR_REGISTER_INLINE_H_ */
Empty file modified BMR/SpdzWire.h
100755 → 100644
Empty file.
Empty file modified BMR/TrustedParty.cpp
100755 → 100644
Empty file.
Empty file modified BMR/TrustedParty.h
100755 → 100644
Empty file.
Empty file modified BMR/Wire.h
100755 → 100644
Empty file.
Empty file modified BMR/common.h
100755 → 100644
Empty file.
Empty file modified BMR/config.h
100755 → 100644
Empty file.
Empty file modified BMR/msg_types.cpp
100755 → 100644
Empty file.
Empty file modified BMR/msg_types.h
100755 → 100644
Empty file.
Empty file modified BMR/network/Client.cpp
100755 → 100644
Empty file.
Empty file modified BMR/network/Client.h
100755 → 100644
Empty file.
Empty file modified BMR/network/Node.cpp
100755 → 100644
Empty file.
Empty file modified BMR/network/Node.h
100755 → 100644
Empty file.
Empty file modified BMR/network/Server.cpp
100755 → 100644
Empty file.
Empty file modified BMR/network/Server.h
100755 → 100644
Empty file.
Empty file modified BMR/network/common.h
100755 → 100644
Empty file.
Empty file modified BMR/network/utils.cpp
100755 → 100644
Empty file.
Empty file modified BMR/network/utils.h
100755 → 100644
Empty file.
Empty file modified BMR/prf.h
100755 → 100644
Empty file.
Empty file modified BMR/proto_utils.cpp
100755 → 100644
Empty file.
Empty file modified BMR/proto_utils.h
100755 → 100644
Empty file.
30 changes: 28 additions & 2 deletions CHANGELOG.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
The changelog explains changes pulled through from the private development repository. Bug fixes and small enhancements are committed between releases and not documented here.

## 0.3.2 (Mai 27, 2022)
## 0.3.4 (Nov 9, 2022)

- Decision tree learning
- Optimized oblivious shuffle in Rep3
- Optimized daBit generation in Rep3 and semi-honest HE-based 2PC
- Optimized element-vector AND in SemiBin
- Optimized input protocol in Shamir-based protocols
- Square-root ORAM (@Quitlox)
- Improved ORAM in binary circuits
- UTF-8 outputs

## 0.3.3 (Aug 25, 2022)

- Use SoftSpokenOT to avoid unclear security of KOS OT extension candidate
- Fix security bug in MAC check when using multithreading
- Fix security bug to prevent selective failure attack by checking earlier
- Fix security bug in Mama: insufficient sacrifice.
- Inverse permutation (@Quitlox)
- Easier direct compilation (@eriktaubeneck)
- Generally allow element-vector operations
- Increase maximum register size to 2^54
- Client example in Python
- Uniform base OTs across platforms
- Multithreaded base OT computation
- Faster random bit generation in two-player Semi(2k)

## 0.3.2 (May 27, 2022)

- Secure shuffling
- O(n log n) radix sorting
- Documented BGV encryption interface
- Optimized matrix multiplication in dealer protocol
- Fixed security bug in homomorphic encryption parameter generation
- Fixed Security bug in Temi matrix multiplication
- Fixed security bug in Temi matrix multiplication

## 0.3.1 (Apr 19, 2022)

Expand Down
22 changes: 14 additions & 8 deletions CONFIG
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PREP_DIR = '-DPREP_DIR="Player-Data/"'
SSL_DIR = '-DSSL_DIR="Player-Data/"'

# set for SHE preprocessing (SPDZ and Overdrive)
USE_NTL = 0
USE_NTL = 1

# set for using GF(2^128)
# unset for GF(2^40)
Expand All @@ -31,24 +31,21 @@ ARCH = -mtune=native -msse4.1 -msse4.2 -maes -mpclmul -mavx -mavx2 -mbmi2 -madx
ARCH = -march=native

MACHINE := $(shell uname -m)
ARM := $(shell uname -m | grep x86; echo $$?)
OS := $(shell uname -s)
ifeq ($(MACHINE), x86_64)
# set this to 0 to avoid using AVX for OT
ifeq ($(OS), Linux)
CHECK_AVX := $(shell grep -q avx /proc/cpuinfo; echo $$?)
ifeq ($(CHECK_AVX), 0)
AVX_OT = 1
else
AVX_OT = 0
endif
else
AVX_OT = 1
endif
else
ARCH =
AVX_OT = 0
endif

USE_KOS = 0

# allow to set compiler in CONFIG.mine
CXX = g++

Expand All @@ -70,8 +67,11 @@ endif
# MOD = -DMAX_MOD_SZ=10 -DGFP_MOD_SZ=5

LDLIBS = -lmpirxx -lmpir -lsodium $(MY_LDLIBS)
LDLIBS += -Wl,-rpath -Wl,$(CURDIR)/local/lib -L$(CURDIR)/local/lib
LDLIBS += -lboost_system -lssl -lcrypto

CFLAGS += -I./local/include

ifeq ($(USE_NTL),1)
CFLAGS += -DUSE_NTL
LDLIBS := -lntl $(LDLIBS)
Expand All @@ -87,7 +87,7 @@ else
BOOST = -lboost_thread $(MY_BOOST)
endif

CFLAGS += $(ARCH) $(MY_CFLAGS) $(GDEBUG) -Wextra -Wall $(OPTIM) -I$(ROOT) -pthread $(PROF) $(DEBUG) $(MOD) $(GF2N_LONG) $(PREP_DIR) $(SSL_DIR) $(SECURE) -std=c++11 -Werror
CFLAGS += $(ARCH) $(MY_CFLAGS) $(GDEBUG) -Wextra -Wall $(OPTIM) -I$(ROOT) -I$(ROOT)/deps -pthread $(PROF) $(DEBUG) $(MOD) $(GF2N_LONG) $(PREP_DIR) $(SSL_DIR) $(SECURE) -std=c++11 -Werror
CPPFLAGS = $(CFLAGS)
LD = $(CXX)

Expand All @@ -98,3 +98,9 @@ ifeq ($(USE_NTL),1)
CFLAGS += -Wno-error=unused-parameter -Wno-error=deprecated-copy
endif
endif

ifeq ($(USE_KOS),1)
CFLAGS += -DUSE_KOS
else
CFLAGS += -std=c++17
endif
Empty file modified Compiler/GC/__init__.py
100755 → 100644
Empty file.
Loading

0 comments on commit a4e52b0

Please sign in to comment.