1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-20 21:38:26 +00:00

Simplified test for doubling in point_jacobian_add

This commit is contained in:
Jochen Hoenicke 2015-08-07 11:26:00 +02:00
parent 11d14a3946
commit 774ac9cb22

View File

@ -290,7 +290,11 @@ void point_jacobian_add(const curve_point *p1, jacobian_curve_point *p2, const e
bn_add(&xz, &p2->x); bn_add(&xz, &p2->x);
// xz = x1' + x2 // xz = x1' + x2
is_doubling = bn_is_zero(&h) | bn_is_equal(&h, prime); // check for h == 0 % prime. Note that h never normalizes to
// zero, since h = x1' + 2*prime - x2 > 0 and a positive
// multiple of prime is always normalized to prime by
// bn_fast_mod.
is_doubling = bn_is_equal(&h, prime);
bn_multiply(&p1->y, &yz, prime); // yz = y1' = y1*z2^3; bn_multiply(&p1->y, &yz, prime); // yz = y1' = y1*z2^3;
bn_subtractmod(&yz, &p2->y, &r, prime); bn_subtractmod(&yz, &p2->y, &r, prime);