Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pairing #201

Merged
merged 1 commit into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)