ethereum / ethereum/py_ecc

Pairing product function which matches Ethereum opcode (EIP-212)

Open
#9 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
231
Forks
88
PR merge metrics
No merged PRs in 30d

Description

```python
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.