Skip to content

Commit

Permalink
Make test_hbavss actually fail on exceptions
Browse files Browse the repository at this point in the history
Fix G1.one()
  • Loading branch information
amiller committed Mar 2, 2019
1 parent c993aa8 commit c409c60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions honeybadgermpc/betterpairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __imul__(self, other):
if type(other) is G1:
self.pyg1.add_assign(other.pyg1)
return self
raise TypeError(
'Invalid multiplication param. Expected G1. Got '
+ str(type(other)))

def __truediv__(self, other):
if type(other) is G1:
Expand All @@ -87,6 +90,9 @@ def __idiv__(self, other):
if type(other) is G1:
self.pyg1.sub_assign(other.pyg1)
return self
raise TypeError(
'Invalid division param. Expected G1. Got '
+ str(type(other)))

def __pow__(self, other):
if type(other) is int:
Expand Down Expand Up @@ -115,7 +121,7 @@ def __ipow__(self, other):
return self
if other < 0:
self.invert()
other = other * -1
other *= -1
self.pyg1.mul_assign(ZR(other).val)
return self
elif type(other) is ZR:
Expand Down Expand Up @@ -172,7 +178,9 @@ def pair_with(self, other):

@staticmethod
def one():
return G1(PyG1().zero())
one = G1()
one.pyg1.zero()
return one

@staticmethod
def rand(seed=None):
Expand Down Expand Up @@ -277,7 +285,7 @@ def __ipow__(self, other):
return self
if other < 0:
self.invert()
other = other * -1
other *= -1
self.pyg2.mul_assign(ZR(other).val)
return self
elif type(other) is ZR:
Expand Down Expand Up @@ -329,7 +337,9 @@ def projective(self):

@staticmethod
def one():
return G2(PyG2().zero())
one = G2()
one.pyg2.zero()
return one

@staticmethod
def rand(seed=None):
Expand Down Expand Up @@ -377,7 +387,7 @@ def __mul__(self, other):
return out
if other < 0:
out.pyfq12.negate()
other = -1 * other
other *= -1
prodend = GT(other)
out.pyfq12.mul_assign(prodend.pyfq12)
return out
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hbavss.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ async def test_hbavss(test_router):
for r in recipients:
threads.append(r.run())
threads.append(dealer.run())
await asyncio.wait(threads)
await asyncio.gather(*threads)

0 comments on commit c409c60

Please sign in to comment.