mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 20:38:10 +00:00
Simplified test for doubling in point_jacobian_add
This commit is contained in:
parent
11d14a3946
commit
774ac9cb22
6
ecdsa.c
6
ecdsa.c
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user