Skip to content

Commit

Permalink
Maintenance.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Nov 4, 2021
1 parent 7b52ef9 commit 32950fe
Show file tree
Hide file tree
Showing 185 changed files with 1,818 additions and 654 deletions.
2 changes: 0 additions & 2 deletions BMR/RealProgramParty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
garble_processor.reset(program);
this->processor.open_input_file(N.my_num(), 0);

T::bit_type::mac_key_type::init_field();
GC::ShareThread<typename T::bit_type> share_thread(N, online_opts, *P, 0, usage);
shared_proc = new SubProcessor<T>(dummy_proc, *MC, *prep, *P);

auto& inputter = shared_proc->input;
Expand Down
3 changes: 3 additions & 0 deletions BMR/Register.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ class Phase
template <class T>
static T get_input(int from, GC::Processor<T>& processor, int n_bits)
{ return T::input(from, processor.get_input(n_bits), n_bits); }
template<class U>
static void reveal_inst(GC::Processor<U>& processor, const vector<int>& args)
{ processor.reveal(args); }

template<class T>
static void convcbit(Integer& dest, const GC::Clear& source, T&)
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
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.2.8 (Nov 4, 2021)

- Tested on Apple laptop with ARM chip
- Restore trusted client interface
- Directly accessible softmax function
- Signature in preprocessing files to reduce confusing errors
- Improved error messages for connection issues
- Documentation of low-level share types and protocol pairs

## 0.2.7 (Sep 17, 2021)

- Optimized matrix multiplication in Hemi
Expand Down
4 changes: 3 additions & 1 deletion CONFIG
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ CPPFLAGS = $(CFLAGS)
LD = $(CXX)

ifeq ($(OS), Darwin)
# for boost with OpenSSL 3
CFLAGS += -Wno-error=deprecated-declarations
ifeq ($(USE_NTL),1)
CFLAGS += -Wno-error=unused-parameter
CFLAGS += -Wno-error=unused-parameter -Wno-error=deprecated-copy
endif
endif
2 changes: 2 additions & 0 deletions Compiler/GC/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def __invert__(self):
res = type(self)()
inst.notcb(self.n, res, self)
return res
def __eq__(self, other):
raise CompilerError('equality not implemented')
def print_reg(self, desc=''):
inst.print_regb(self, desc)
def print_reg_plain(self):
Expand Down
2 changes: 2 additions & 0 deletions Compiler/allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def __init__(self):
self.by_address = {}

def by_size(self, size):
if size >= 2 ** 32:
raise CompilerError('size exceeds addressing capability')
return self.by_logsize[int(math.log(size, 2))][size]

def push(self, address, size):
Expand Down
2 changes: 2 additions & 0 deletions Compiler/floatingpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def BitDecRing(a, k, m):
return [types.sint.conv(bit) for bit in reversed(bits)][::-1]

def BitDecFieldRaw(a, k, m, kappa, bits_to_compute=None):
instructions_base.set_global_vector_size(a.size)
r_dprime = types.sint()
r_prime = types.sint()
c = types.cint()
Expand All @@ -298,6 +299,7 @@ def BitDecFieldRaw(a, k, m, kappa, bits_to_compute=None):
pow2 = two_power(k + kappa)
asm_open(c, pow2 + two_power(k) + a - two_power(m)*r_dprime - r_prime)
res = r[0].bit_adder(r, list(r[0].bit_decompose_clear(c,m)))
instructions_base.reset_global_vector_size()
return res

def BitDecField(a, k, m, kappa, bits_to_compute=None):
Expand Down
109 changes: 108 additions & 1 deletion Compiler/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,14 @@ class cond_print_plain(base.IOInstruction):
code = base.opcodes['CONDPRINTPLAIN']
arg_format = ['c', 'c', 'c']

def __init__(self, *args, **kwargs):
base.Instruction.__init__(self, *args, **kwargs)
self.size = args[1].size
args[2].set_size(self.size)

def get_code(self):
return base.Instruction.get_code(self, self.size)

class print_int(base.IOInstruction):
""" Output clear integer register.
Expand Down Expand Up @@ -1591,7 +1599,16 @@ def has_var_args(self):
return True

class readsockets(base.IOInstruction):
"""Read a variable number of secret shares + MACs from socket for a client id and store in registers"""
""" Read a variable number of secret shares (potentially with MAC)
from a socket for a client id and store them in registers. If the
protocol uses MACs, the client should be different for every party.
:param: client id (regint)
:param: vector size (int)
:param: source (sint)
:param: (repeat source)...
"""
__slots__ = []
code = base.opcodes['READSOCKETS']
arg_format = tools.chain(['ci','int'], itertools.repeat('sw'))
Expand Down Expand Up @@ -1628,6 +1645,25 @@ class writesocketc(base.IOInstruction):
def has_var_args(self):
return True

class writesockets(base.IOInstruction):
""" Write a variable number of secret shares (potentially with MAC)
from registers into a socket for a specified client id. If the
protocol uses MACs, the client should be different for every party.
:param: client id (regint)
:param: message type (must be 0)
:param: vector size (int)
:param: source (sint)
:param: (repeat source)...
"""
__slots__ = []
code = base.opcodes['WRITESOCKETS']
arg_format = tools.chain(['ci', 'int', 'int'], itertools.repeat('s'))

def has_var_args(self):
return True

class writesocketshare(base.IOInstruction):
""" Write a variable number of shares (without MACs) from secret
registers into socket for a specified client id.
Expand Down Expand Up @@ -2384,5 +2420,76 @@ def expand(self):
subs(a, self.args[1], self.args[2])
comparison.LTZ(self.args[0], a, self.args[3], self.args[4])

# placeholder for documentation
class cisc:
""" Meta instruction for emulation. This instruction is only generated
when using ``-K`` with ``compile.py``. The header looks as follows:
:param: number of arguments after name plus one
:param: name (16 bytes, zero-padded)
Currently, the following names are supported:
LTZ
Less than zero.
:param: number of arguments in this unit (must be 6)
:param: vector size
:param: result (sint)
:param: input (sint)
:param: bit length
:param: (ignored)
:param: (repeat)...
Trunc
Truncation.
:param: number of arguments in this unit (must be 8)
:param: vector size
:param: result (sint)
:param: input (sint)
:param: bit length
:param: number of bits to truncate
:param: (ignored)
:param: 0 for unsigned or 1 for signed
:param: (repeat)...
FPDiv
Fixed-point division. Division by zero results in zero without error.
:param: number of arguments in this unit (must be at least 7)
:param: vector size
:param: result (sint)
:param: dividend (sint)
:param: divisor (sint)
:param: (ignored)
:param: fixed-point precision
:param: (repeat)...
exp2_fx
Fixed-point power of two.
:param: number of arguments in this unit (must be at least 6)
:param: vector size
:param: result (sint)
:param: exponent (sint)
:param: (ignored)
:param: fixed-point precision
:param: (repeat)...
log2_fx
Fixed-point logarithm with base 2.
:param: number of arguments in this unit (must be at least 6)
:param: vector size
:param: result (sint)
:param: input (sint)
:param: (ignored)
:param: fixed-point precision
:param: (repeat)...
"""
code = base.opcodes['CISC']

# hack for circular dependency
from Compiler import comparison
12 changes: 11 additions & 1 deletion Compiler/instructions_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,16 @@ def new_instructions(self, size, regs):

def expand_merged(self, skip):
if function.__name__ in skip:
return [self], 0
good = True
for call in self.calls:
if not good:
break
for arg in call[0]:
if isinstance(arg, program.curr_tape.Register) and \
not issubclass(type(self.calls[0][0][0]), type(arg)):
good = False
if good:
return [self], 0
tape = program.curr_tape
block = tape.BasicBlock(tape, None, None)
tape.active_basicblock = block
Expand Down Expand Up @@ -520,6 +529,7 @@ def get_bytes(self):
String.check(name)
res += String.encode(name)
for call in self.calls:
call[1].pop('nearest', None)
assert not call[1]
res += int_to_bytes(len(call[0]) + 2)
res += int_to_bytes(call[0][0].size)
Expand Down
Loading

0 comments on commit 32950fe

Please sign in to comment.