ECC point double: when z ordinate is 0 point is infinity

Recognize z == 0 as infinity in result of double.
This commit is contained in:
Sean Parkinson
2023-11-15 13:21:30 +10:00
parent 2213306386
commit 26a9435f5c

View File

@ -7801,6 +7801,13 @@ int ecc_projective_dbl_point_safe(ecc_point *P, ecc_point *R, mp_int* a,
} }
else { else {
err = _ecc_projective_dbl_point(P, R, a, modulus, mp); err = _ecc_projective_dbl_point(P, R, a, modulus, mp);
if ((err == MP_OKAY) && mp_iszero(R->z)) {
err = mp_set(R->x, 0);
if (err == MP_OKAY)
err = mp_set(R->y, 0);
if (err == MP_OKAY)
err = mp_set(R->z, 1);
}
} }
return err; return err;