From: Niels Möller Date: Sun, 15 Dec 2019 18:01:45 +0000 (+0100) Subject: Eliminate one unneeded ecc_modp_add in ecc_dup_eh. X-Git-Tag: nettle_3.6rc1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a8fb3bbf006119a3409891fcba27434d1f236fc;p=thirdparty%2Fnettle.git Eliminate one unneeded ecc_modp_add in ecc_dup_eh. --- diff --git a/ChangeLog b/ChangeLog index 0516a040..0f0e2173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-12-15 Niels Möller + + * ecc-dup-eh.c (ecc_dup_eh): Eliminate one unneeded ecc_modp_add. + 2019-12-14 Niels Möller * ecc-mul-m.c (ecc_mul_m): New file and function. Implements diff --git a/ecc-dup-eh.c b/ecc-dup-eh.c index a850346c..6b678a40 100644 --- a/ecc-dup-eh.c +++ b/ecc-dup-eh.c @@ -67,12 +67,13 @@ ecc_dup_eh (const struct ecc_curve *ecc, F = -C+D B, C, D, F H = Z1^2 sqr B, C, D, F, H J = 2*H - F B, C, D, F, J - X3 = (B-C-D)*J mul C, D, F, J + X3 = (B-C-D)*J mul C, F, J (Replace C <-- C+D) Y3 = F*(C+D) mul F, J Z3 = F*J mul 3M+4S */ + /* FIXME: Could reduce scratch need by reusing D storage. */ #define B scratch #define C (scratch + ecc->p.size) #define D (scratch + 2*ecc->p.size) @@ -92,8 +93,8 @@ ecc_dup_eh (const struct ecc_curve *ecc, /* F, */ ecc_modp_sub (ecc, F, D, C); /* B - C - D */ + ecc_modp_add (ecc, C, C, D); ecc_modp_sub (ecc, B, B, C); - ecc_modp_sub (ecc, B, B, D); /* J */ ecc_modp_add (ecc, r, r, r); ecc_modp_sub (ecc, J, r, F); @@ -101,7 +102,6 @@ ecc_dup_eh (const struct ecc_curve *ecc, /* x' */ ecc_modp_mul (ecc, r, B, J); /* y' */ - ecc_modp_add (ecc, C, C, D); /* Redundant */ ecc_modp_mul (ecc, r + ecc->p.size, F, C); /* z' */ ecc_modp_mul (ecc, B, F, J);