Skip to content

Commit 6a42453

Browse files
committed
SoftSpokenOT.
1 parent e08a6ad commit 6a42453

File tree

171 files changed

+2179
-1023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+2179
-1023
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,7 @@ _build/
119119

120120
# environment
121121
.env
122+
123+
# temp doc files
124+
doc/readme.md
125+
doc/xml

.gitmodules

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
[submodule "SimpleOT"]
2-
path = SimpleOT
2+
path = deps/SimpleOT
33
url = https://github.com/mkskeller/SimpleOT
44
[submodule "mpir"]
5-
path = mpir
5+
path = deps/mpir
66
url = https://github.com/wbhart/mpir
77
[submodule "Programs/Circuits"]
88
path = Programs/Circuits
99
url = https://github.com/mkskeller/bristol-fashion
1010
[submodule "simde"]
11-
path = simde
11+
path = deps/simde
1212
url = https://github.com/simd-everywhere/simde
13+
[submodule "deps/libOTe"]
14+
path = deps/libOTe
15+
url = https://github.com/mkskeller/softspoken-implementation
16+
[submodule "deps/SimplestOT_C"]
17+
path = deps/SimplestOT_C
18+
url = https://github.com/mkskeller/SimplestOT_C

BMR/Party.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ FakeProgramParty::FakeProgramParty(int argc, const char** argv) :
249249
}
250250
cout << "Compiler: " << prev << endl;
251251
P = new PlainPlayer(N, 0);
252+
Share<gf2n_long>::MAC_Check::setup(*P);
252253
if (argc > 4)
253254
threshold = atoi(argv[4]);
254255
cout << "Threshold for multi-threaded evaluation: " << threshold << endl;
@@ -280,6 +281,7 @@ FakeProgramParty::~FakeProgramParty()
280281
cerr << "Dynamic storage: " << 1e-9 * dynamic_memory.capacity_in_bytes()
281282
<< " GB" << endl;
282283
#endif
284+
Share<gf2n_long>::MAC_Check::teardown();
283285
}
284286

285287
void FakeProgramParty::_compute_prfs_outputs(Key* keys)

BMR/RealGarbleWire.h

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class RealGarbleWire : public PRFRegister
4848
static void inputbvec(GC::Processor<GC::Secret<RealGarbleWire>>& processor,
4949
ProcessorBase& input_processor, const vector<int>& args);
5050

51-
RealGarbleWire(const Register& reg) : PRFRegister(reg) {}
52-
5351
void garble(PRFOutputs& prf_output, const RealGarbleWire<T>& left,
5452
const RealGarbleWire<T>& right);
5553

BMR/RealGarbleWire.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void RealGarbleWire<T>::inputbvec(
110110
{
111111
GarbleInputter<T> inputter;
112112
processor.inputbvec(inputter, input_processor, args,
113-
inputter.party.P->my_num());
113+
*inputter.party.P);
114114
}
115115

116116
template<class T>

BMR/RealProgramParty.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
9797
if (online_opts.live_prep)
9898
{
9999
mac_key.randomize(prng);
100-
if (T::needs_ot)
101-
BaseMachine::s().ot_setups.push_back({*P, true});
102100
prep = new typename T::LivePrep(0, usage);
103101
}
104102
else
@@ -107,6 +105,7 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
107105
prep = new Sub_Data_Files<T>(N, prep_dir, usage);
108106
}
109107

108+
T::MAC_Check::setup(*P);
110109
MC = new typename T::MAC_Check(mac_key);
111110

112111
garble_processor.reset(program);
@@ -219,6 +218,7 @@ RealProgramParty<T>::~RealProgramParty()
219218
delete garble_inputter;
220219
delete garble_protocol;
221220
cout << "Data sent = " << data_sent * 1e-6 << " MB" << endl;
221+
T::MAC_Check::teardown();
222222
}
223223

224224
template<class T>

BMR/Register.h

+1-21
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Register {
152152
* for pipelining matters.
153153
*/
154154

155-
Register(int n_parties);
155+
Register();
156156

157157
void init(int n_parties);
158158
void init(int rfd, int n_parties);
@@ -278,10 +278,6 @@ class ProgramRegister : public Phase, public Register
278278

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

281-
static Register new_reg();
282-
static Register tmp_reg() { return new_reg(); }
283-
static Register and_reg() { return new_reg(); }
284-
285281
template<class T>
286282
static void store(NoMemory& dest,
287283
const vector<GC::WriteAccess<T> >& accesses) { (void)dest; (void)accesses; }
@@ -306,8 +302,6 @@ class ProgramRegister : public Phase, public Register
306302
void other_input(Input&, int) {}
307303

308304
char get_output() { return 0; }
309-
310-
ProgramRegister(const Register& reg) : Register(reg) {}
311305
};
312306

313307
class PRFRegister : public ProgramRegister
@@ -319,8 +313,6 @@ class PRFRegister : public ProgramRegister
319313
static void load(vector<GC::ReadAccess<T> >& accesses,
320314
const NoMemory& source);
321315

322-
PRFRegister(const Register& reg) : ProgramRegister(reg) {}
323-
324316
void op(const PRFRegister& left, const PRFRegister& right, Function func);
325317
void XOR(const Register& left, const Register& right);
326318
void input(party_id_t from, char input = -1);
@@ -396,8 +388,6 @@ class EvalRegister : public ProgramRegister
396388
static void convcbit(Integer& dest, const GC::Clear& source,
397389
GC::Processor<GC::Secret<EvalRegister>>& proc);
398390

399-
EvalRegister(const Register& reg) : ProgramRegister(reg) {}
400-
401391
void op(const ProgramRegister& left, const ProgramRegister& right, Function func);
402392
void XOR(const Register& left, const Register& right);
403393

@@ -427,8 +417,6 @@ class GarbleRegister : public ProgramRegister
427417
static void load(vector<GC::ReadAccess<T> >& accesses,
428418
const NoMemory& source);
429419

430-
GarbleRegister(const Register& reg) : ProgramRegister(reg) {}
431-
432420
void op(const Register& left, const Register& right, Function func);
433421
void XOR(const Register& left, const Register& right);
434422
void input(party_id_t from, char value = -1);
@@ -452,8 +440,6 @@ class RandomRegister : public ProgramRegister
452440
static void load(vector<GC::ReadAccess<T> >& accesses,
453441
const NoMemory& source);
454442

455-
RandomRegister(const Register& reg) : ProgramRegister(reg) {}
456-
457443
void randomize();
458444

459445
void op(const Register& left, const Register& right, Function func);
@@ -469,12 +455,6 @@ class RandomRegister : public ProgramRegister
469455
};
470456

471457

472-
inline Register::Register(int n_parties) :
473-
garbled_entry(n_parties), external(NO_SIGNAL),
474-
mask(NO_SIGNAL), keys(n_parties)
475-
{
476-
}
477-
478458
inline void KeyVector::operator=(const KeyVector& other)
479459
{
480460
resize(other.size());

BMR/Register.hpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@ void ProgramRegister::inputbvec(T& processor, ProcessorBase& input_processor,
1414
const vector<int>& args)
1515
{
1616
NoOpInputter inputter;
17-
int my_num = -1;
18-
try
19-
{
20-
my_num = ProgramParty::s().P->my_num();
21-
}
22-
catch (exception&)
23-
{
24-
}
25-
processor.inputbvec(inputter, input_processor, args, my_num);
17+
processor.inputbvec(inputter, input_processor, args, *ProgramParty::s().P);
2618
}
2719

2820
template<class T>
@@ -31,7 +23,7 @@ void EvalRegister::inputbvec(T& processor, ProcessorBase& input_processor,
3123
{
3224
EvalInputter inputter;
3325
processor.inputbvec(inputter, input_processor, args,
34-
ProgramParty::s().P->my_num());
26+
*ProgramParty::s().P);
3527
}
3628

3729
template <class T>

BMR/Register_inline.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "CommonParty.h"
1010
#include "Party.h"
1111

12-
13-
inline Register ProgramRegister::new_reg()
12+
inline Register::Register() :
13+
garbled_entry(CommonParty::s().get_n_parties()), external(NO_SIGNAL),
14+
mask(NO_SIGNAL), keys(CommonParty::s().get_n_parties())
1415
{
15-
return Register(CommonParty::s().get_n_parties());
1616
}
1717

1818
#endif /* BMR_REGISTER_INLINE_H_ */

CHANGELOG.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
The changelog explains changes pulled through from the private development repository. Bug fixes and small enhancements are committed between releases and not documented here.
22

3+
## 0.3.3 (Aug 25, 2022)
4+
5+
- Use SoftSpokenOT to avoid unclear security of KOS OT extension candidate
6+
- Fix security bug in MAC check when using multithreading
7+
- Fix security bug to prevent selective failure attack by checking earlier
8+
- Fix security bug in Mama: insufficient sacrifice.
9+
- Inverse permutation (@Quitlox)
10+
- Easier direct compilation (@eriktaubeneck)
11+
- Generally allow element-vector operations
12+
- Increase maximum register size to 2^54
13+
- Client example in Python
14+
- Uniform base OTs across platforms
15+
- Multithreaded base OT computation
16+
- Faster random bit generation in two-player Semi(2k)
17+
318
## 0.3.2 (May 27, 2022)
419

520
- Secure shuffling
621
- O(n log n) radix sorting
722
- Documented BGV encryption interface
823
- Optimized matrix multiplication in dealer protocol
924
- Fixed security bug in homomorphic encryption parameter generation
10-
- Fixed Security bug in Temi matrix multiplication
25+
- Fixed security bug in Temi matrix multiplication
1126

1227
## 0.3.1 (Apr 19, 2022)
1328

CONFIG

+11-7
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,21 @@ ARCH = -mtune=native -msse4.1 -msse4.2 -maes -mpclmul -mavx -mavx2 -mbmi2 -madx
3131
ARCH = -march=native
3232

3333
MACHINE := $(shell uname -m)
34+
ARM := $(shell uname -m | grep x86; echo $$?)
3435
OS := $(shell uname -s)
3536
ifeq ($(MACHINE), x86_64)
36-
# set this to 0 to avoid using AVX for OT
3737
ifeq ($(OS), Linux)
38-
CHECK_AVX := $(shell grep -q avx /proc/cpuinfo; echo $$?)
39-
ifeq ($(CHECK_AVX), 0)
4038
AVX_OT = 1
4139
else
4240
AVX_OT = 0
4341
endif
4442
else
45-
AVX_OT = 1
46-
endif
47-
else
4843
ARCH =
4944
AVX_OT = 0
5045
endif
5146

47+
USE_KOS = 0
48+
5249
# allow to set compiler in CONFIG.mine
5350
CXX = g++
5451

@@ -87,7 +84,7 @@ else
8784
BOOST = -lboost_thread $(MY_BOOST)
8885
endif
8986

90-
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
87+
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
9188
CPPFLAGS = $(CFLAGS)
9289
LD = $(CXX)
9390

@@ -98,3 +95,10 @@ ifeq ($(USE_NTL),1)
9895
CFLAGS += -Wno-error=unused-parameter -Wno-error=deprecated-copy
9996
endif
10097
endif
98+
99+
ifeq ($(USE_KOS),1)
100+
CFLAGS += -DUSE_KOS
101+
else
102+
CFLAGS += -std=c++17
103+
LDLIBS += -llibOTe -lcryptoTools
104+
endif

Compiler/GC/instructions.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ class stmcb(base.DirectMemoryWriteInstruction, base.VectorInstruction):
342342
code = opcodes['STMCB']
343343
arg_format = ['cb','long']
344344

345-
class ldmsbi(base.ReadMemoryInstruction, base.VectorInstruction):
345+
class ldmsbi(base.ReadMemoryInstruction, base.VectorInstruction,
346+
base.IndirectMemoryInstruction):
346347
""" Copy secret bit memory cell with run-time address to secret bit
347348
register.
348349
@@ -351,8 +352,10 @@ class ldmsbi(base.ReadMemoryInstruction, base.VectorInstruction):
351352
"""
352353
code = opcodes['LDMSBI']
353354
arg_format = ['sbw','ci']
355+
direct = staticmethod(ldmsb)
354356

355-
class stmsbi(base.WriteMemoryInstruction, base.VectorInstruction):
357+
class stmsbi(base.WriteMemoryInstruction, base.VectorInstruction,
358+
base.IndirectMemoryInstruction):
356359
""" Copy secret bit register to secret bit memory cell with run-time
357360
address.
358361
@@ -361,8 +364,10 @@ class stmsbi(base.WriteMemoryInstruction, base.VectorInstruction):
361364
"""
362365
code = opcodes['STMSBI']
363366
arg_format = ['sb','ci']
367+
direct = staticmethod(stmsb)
364368

365-
class ldmcbi(base.ReadMemoryInstruction, base.VectorInstruction):
369+
class ldmcbi(base.ReadMemoryInstruction, base.VectorInstruction,
370+
base.IndirectMemoryInstruction):
366371
""" Copy clear bit memory cell with run-time address to clear bit
367372
register.
368373
@@ -371,8 +376,10 @@ class ldmcbi(base.ReadMemoryInstruction, base.VectorInstruction):
371376
"""
372377
code = opcodes['LDMCBI']
373378
arg_format = ['cbw','ci']
379+
direct = staticmethod(ldmcb)
374380

375-
class stmcbi(base.WriteMemoryInstruction, base.VectorInstruction):
381+
class stmcbi(base.WriteMemoryInstruction, base.VectorInstruction,
382+
base.IndirectMemoryInstruction):
376383
""" Copy clear bit register to clear bit memory cell with run-time
377384
address.
378385
@@ -381,6 +388,7 @@ class stmcbi(base.WriteMemoryInstruction, base.VectorInstruction):
381388
"""
382389
code = opcodes['STMCBI']
383390
arg_format = ['cb','ci']
391+
direct = staticmethod(stmcb)
384392

385393
class ldmsdi(base.ReadMemoryInstruction):
386394
code = opcodes['LDMSDI']

0 commit comments

Comments
 (0)