Skip to content

Commit

Permalink
Fix bugs in binary circuit compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Jan 23, 2024
1 parent 9e61011 commit 5935cfb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Compiler/GC/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from Compiler.types import MemValue, read_mem_value, regint, Array, cint
from Compiler.types import _bitint, _number, _fix, _structure, _bit, _vec, sint, sintbit
from Compiler.types import vectorized_classmethod
from Compiler.program import Tape, Program
from Compiler.exceptions import *
from Compiler import util, oram, floatingpoint, library
Expand Down Expand Up @@ -766,8 +767,9 @@ def __init__(self, other=None, size=None):
self.v = sbits.get_type(n)(other).bit_decompose()
assert len(self.v) == n
assert size is None or size == self.v[0].n
@classmethod
def load_mem(cls, address, size=None):
@vectorized_classmethod
def load_mem(cls, address):
size = instructions_base.get_global_vector_size()
if size not in (None, 1):
assert isinstance(address, int) or len(address) == 1
sb = sbits.get_type(size)
Expand Down Expand Up @@ -1342,7 +1344,10 @@ def __mul__(self, other):
return other * self.v[0]
elif isinstance(other, sbitfixvec):
return NotImplemented
my_bits, other_bits = self.expand(other, False)
try:
my_bits, other_bits = self.expand(other, False)
except:
return NotImplemented
m = float('inf')
uniform = True
for x in itertools.chain(my_bits, other_bits):
Expand Down Expand Up @@ -1406,6 +1411,8 @@ class cbitfix(object):
conv = staticmethod(lambda x: x)
load_mem = classmethod(lambda cls, *args: cls._new(cbits.load_mem(*args)))
store_in_mem = lambda self, *args: self.v.store_in_mem(*args)
mem_size = staticmethod(lambda *args: 1)
size = 1
@classmethod
def _new(cls, value):
if isinstance(value, list):
Expand Down

0 comments on commit 5935cfb

Please sign in to comment.