ethereum / py_ecc

Python implementation of ECC pairing and bn_128 and bls12_381 curve operations
MIT License
183 stars 82 forks source link

Pairings can't be added #132

Open FilipLaurentiu opened 7 months ago

FilipLaurentiu commented 7 months ago

What happened?

The library can't be used to add pairings result together. This can be helpful for off-chain testing

Code that produced the error

from py_ecc.bn128 import G1, G2, multiply, pairing, add

p1 = pairing(G2, multiply(G1, 4))
p2 = pairing(multiply(G2, 4), G1)
p3 = pairing(G2, multiply(G1, 8))

assert p1 == p2, "Fail 1"
assert add(p1, p2) == p3, "Fail 2"

Full error output

python3.9/site-packages/py_ecc/bn128/bn128_curve.py", line 87, in add
    x1, y1 = p1
TypeError: cannot unpack non-iterable bn128_FQ12 object

Fill this section in if you know how this could or should be fixed

No response

py-ecc Version

6.0.0

Python Version

3.9

Operating System

linux

Output from pip freeze

No response