sjcl
sjcl copied to clipboard
EC validate function false negatives
Importing a point, which is on the curve, gets response 'point not on the curve'.
Recreate:
- Generate secp256k1 key in Java + BouncyCastle
- Validate that the point is actually on the curve (equation given)
- Import the point in sjcl (there is a high probability that the library will decline the point)
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.