py_ecc
py_ecc copied to clipboard
Pairing product function which matches Ethereum opcode (EIP-212)
def pairingProd(*inputs):
"""
The Ethereum pairing opcode works like:
e(p1[0],p2[0]) * ... * e(p1[n],p2[n]) == 1
See: EIP 212
>>> assert True == pairingProd((G1, G2), (G1, neg(G2)))
"""
product = FQ12.one()
for p1, p2 in inputs:
product *= pairing(p2, p1)
return product == FQ12.one()
The G1 and G2 argument orders are swapped compared to the Pairing.sol
file, whereas py_ecc
uses e(G2, G1)
.
It would be useful to have this included in the library, and to verify this is a correct implementation.
cc @vbuterin as this is beyond the scope of my expertise to evaluate.
@HarryR is right. I got the wrong impression that what I was trying to do was possible using the precompiled pairing (aka BBS signature). This is misleading.
Would someone like to open a pull request as I think that would be the easiest way to figure out how to proceed here.