Skip to content

Commit

Permalink
Fix issue "mpc.to_bits doesn't seem to work. lschoe#17"
Browse files Browse the repository at this point in the history
Extend mpc.to_bits() support for secure prime field type by removing a limitation on field order (was limited to 32 bits).
  • Loading branch information
lschoe committed Sep 10, 2020
1 parent 9106cc1 commit 1671a7f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mpyc/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,10 @@ async def to_bits(self, a, l=None):
c = int(c.value)
return [r_bits[i] + ((c >> i) & 1) for i in range(l)]

a = self.convert(a, self.SecInt())
if field.ext_deg > 1:
raise TypeError('Binary field or prime field required.')

a = self.convert(a, self.SecInt(l=1+stype.field.order.bit_length()))
a_bits = self.to_bits(a)
return self.convert(a_bits, stype)

Expand Down

0 comments on commit 1671a7f

Please sign in to comment.