Zokrates/pycrypto

Babyjubjub "mult" and "add" issue

Closed this issue · 1 comments

Hi team.

I have tested the babyjubjub "mult" and "add" functions.
Theoretically, if a and b are two scalars in Zq, P is an elliptic-curve point (EP), then we have: aP + bP = (a+b mod q)P. Two functions, "mult" and "add," hold this formula only when: a+b < q. If a + b (mod q) < a or b, then: aP + bP != (a+b)P.

Here is my testing code.
`from zokrates_pycrypto.babyjubjub import Point as point
from zokrates_pycrypto.field import FQ

if name == "main":
G = point.generator()
x = G.mult(FQ(-1)).add(G.mult(FQ(-2)))
y = G.mult(FQ(-3)
print(x, y)
`
And here is the result:

x: 6288144309807660494708612010072665855384763336440408062845015283261463235807, y:5833143998328063000799900366900730621930632427668186328136623412278304360029
x: 5093979637901837086256078931723439281276930928534462039212613196541450648116, y:21180654745315572932244776449243111479569795809880863515380923008329868036993

As you can see, aP + bP != (a+b)P

Thank you.

Figured out the issue, a and b should be integers, not finite numbers.