Skip to content

Commit

Permalink
Secure shuffling.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed May 27, 2022
1 parent 2dad77b commit 5ab8c70
Show file tree
Hide file tree
Showing 108 changed files with 2,228 additions and 543 deletions.
1 change: 0 additions & 1 deletion BMR/Party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ ProgramParty::~ProgramParty()
reset();
if (P)
{
cerr << "Data sent: " << 1e-6 * P->total_comm().total_data() << " MB" << endl;
delete P;
}
delete[] eval_threads;
Expand Down
5 changes: 4 additions & 1 deletion BMR/RealProgramParty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RealProgramParty<T>* RealProgramParty<T>::singleton = 0;

template<class T>
RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
garble_processor(garble_machine), dummy_proc({{}, 0})
garble_processor(garble_machine), dummy_proc({}, 0)
{
assert(singleton == 0);
singleton = this;
Expand Down Expand Up @@ -157,6 +157,9 @@ RealProgramParty<T>::RealProgramParty(int argc, const char** argv) :
MC->Check(*P);
data_sent = P->total_comm().sent;

if (online_opts.verbose)
P->total_comm().print();

this->machine.write_memory(this->N.my_num());
}

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.3.2 (Mai 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

## 0.3.1 (Apr 19, 2022)

- Protocol in dealer model
Expand Down
5 changes: 4 additions & 1 deletion Compiler/GC/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ class sbits(bits):
reg_type = 'sb'
is_clear = False
clear_type = cbits
default_type = cbits
load_inst = (inst.ldmsbi, inst.ldmsb)
store_inst = (inst.stmsbi, inst.stmsb)
bitdec = inst.bitdecs
Expand All @@ -404,6 +403,9 @@ def new(value=None, n=None):
else:
return sbits.get_type(n)(value)
@staticmethod
def _new(value):
return value
@staticmethod
def get_random_bit():
res = sbit()
inst.bitb(res)
Expand Down Expand Up @@ -909,6 +911,7 @@ class cbit(bit, cbits):
sbits.bit_type = sbit
cbits.bit_type = cbit
sbit.clear_type = cbit
sbits.default_type = sbits

class bitsBlock(oram.Block):
value_type = sbits
Expand Down
65 changes: 65 additions & 0 deletions Compiler/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import itertools
import operator
import math
from . import tools
from random import randint
from functools import reduce
Expand Down Expand Up @@ -2406,6 +2407,70 @@ class trunc_pr(base.VarArgsInstruction):
code = base.opcodes['TRUNC_PR']
arg_format = tools.cycle(['sw','s','int','int'])

@base.gf2n
class secshuffle(base.VectorInstruction, base.DataInstruction):
""" Secure shuffling.
:param: destination (sint)
:param: source (sint)
"""
__slots__ = []
code = base.opcodes['SECSHUFFLE']
arg_format = ['sw','s','int']

def __init__(self, *args, **kwargs):
super(secshuffle_class, self).__init__(*args, **kwargs)
assert len(args[0]) == len(args[1])
assert len(args[0]) > args[2]

def add_usage(self, req_node):
req_node.increment((self.field_type, 'input', 0), float('inf'))

class gensecshuffle(base.DataInstruction):
""" Generate secure shuffle to bit used several times.
:param: destination (regint)
:param: size (int)
"""
__slots__ = []
code = base.opcodes['GENSECSHUFFLE']
arg_format = ['ciw','int']

def add_usage(self, req_node):
req_node.increment((self.field_type, 'input', 0), float('inf'))

class applyshuffle(base.VectorInstruction, base.DataInstruction):
""" Generate secure shuffle to bit used several times.
:param: destination (sint)
:param: source (sint)
:param: number of elements to be treated as one (int)
:param: handle (regint)
:param: reverse (0/1)
"""
__slots__ = []
code = base.opcodes['APPLYSHUFFLE']
arg_format = ['sw','s','int','ci','int']

def __init__(self, *args, **kwargs):
super(applyshuffle, self).__init__(*args, **kwargs)
assert len(args[0]) == len(args[1])
assert len(args[0]) > args[2]

def add_usage(self, req_node):
req_node.increment((self.field_type, 'triple', 0), float('inf'))

class delshuffle(base.Instruction):
""" Delete secure shuffle.
:param: handle (regint)
"""
code = base.opcodes['DELSHUFFLE']
arg_format = ['ci']

class check(base.Instruction):
"""
Force MAC check in current thread and all idle thread if current
Expand Down
5 changes: 5 additions & 0 deletions Compiler/instructions_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
CONV2DS = 0xAC,
CHECK = 0xAF,
PRIVATEOUTPUT = 0xAD,
# Shuffling
SECSHUFFLE = 0xFA,
GENSECSHUFFLE = 0xFB,
APPLYSHUFFLE = 0xFC,
DELSHUFFLE = 0xFD,
# Data access
TRIPLE = 0x50,
BIT = 0x51,
Expand Down
Loading

0 comments on commit 5ab8c70

Please sign in to comment.