Skip to content

Commit cf51528

Browse files
committed
Missing operations in binary computation.
1 parent 175349e commit cf51528

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Compiler/GC/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
from functools import reduce
2323

2424
class _binary:
25+
def __or__(self, other):
26+
return self ^ other ^ (self & other)
2527
def reveal_to(self, *args, **kwargs):
2628
raise CompilerError(
2729
'%s does not support revealing to indivual players' % type(self))
2830

29-
class bits(Tape.Register, _structure, _bit):
31+
class bits(Tape.Register, _structure, _bit, _binary):
3032
n = 40
3133
unit = 64
3234
PreOp = staticmethod(floatingpoint.PreOpN)
@@ -631,6 +633,8 @@ def reveal(self, check=False):
631633
def equal(self, other, n=None):
632634
bits = (~(self + other)).bit_decompose()
633635
return reduce(operator.mul, bits)
636+
__eq__ = equal
637+
__ne__ = lambda self, other: (self == other).bit_not()
634638
def right_shift(self, m, k, security=None, signed=True):
635639
return self.TruncPr(k, m)
636640
def TruncPr(self, k, m, kappa=None):

0 commit comments

Comments
 (0)