1

When implementing an algorithm like groth16, the verification step involves the addition of higher-order field elements (FQ12) resulting from pairings. How can this be achieved through Ethereum's py_ecc library, since simple arithmetic addition is invalid? enter image description here

1 Answer 1

1
+50

I think you need something like the following:

from py_ecc.fields import optimized_bn128_FQ12 as FQ12
first = pairing(B_2, neg(A_1))
second = pairing(beta_G2, alpha_G1)
third = pairing(G2, C_1)
print("first pairing == second pairing:", final_exponentiate(first * second * third) == FQ12.one())

Source: https://github.com/zigtur/Groth16/blob/main/Groth16.ipynb

1
  • 1
    Thank you! This works. Heads up for future readers of this answer: The pairing and FQ12 must belong to the same curve (the standard bn128 or the optimised one) to prevent type conflicts in Python. Jan 4 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.