bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.19k stars 988 forks source link

EC validate function false negatives #363

Open Martsim opened 6 years ago

Martsim commented 6 years ago

Importing a point, which is on the curve, gets response 'point not on the curve'.

Recreate:

Cheking that the point is on the curve:

Test was done using SageMath, code style is python The formula used was the short Weierstrass form y^2 = x^3 + ax + b (both sides mod p)

def check(x, y): a = 0 b = 7 p = 115792089237316195423570985008687907853269984665640564039457584007908834671663 lhs = y^2 % p rhs = (x^3 + a*x + b) % p return (lhs == rhs)

Example point: x = 51952333075931137634431345031057061251069927459575851264636375825275663549671 y = 97921457466172249608756834905205459171589345232980521325078732920624563225243

check function returns true By removing the mod p, the function returns false.

Main question

Is the validate function calculating with big numbers in the field Z_p? It was not clear from the code.

Additionally, it would be helpful if sources for parameters were referenced.