]> git.codecow.com Git - Monocypher.git/commitdiff
Small carry simplification
authorLoup Vaillant <loup@loup-vaillant.fr>
Thu, 13 Aug 2020 14:34:51 +0000 (16:34 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Thu, 13 Aug 2020 14:34:51 +0000 (16:34 +0200)
src/monocypher.c

index ef052fb5fedd9949a6d98bc14ddb46d209dce2a7..9f4715e2b5d40ff214e8953579498dc2957b6bec 100644 (file)
@@ -1143,8 +1143,7 @@ static void fe_tobytes(u8 s[32], const fe h)
         q += t[2*i  ]; q >>= 26;
         q += t[2*i+1]; q >>= 25;
     }
-    t[0] += 19 * q;
-    q = 0;
+    q *= 19;  // Shift carry back to the begining
     FOR (i, 0, 5) {
         t[i*2  ] += q;  q = t[i*2  ] >> 26;  t[i*2  ] -= q * ((i32)1 << 26);
         t[i*2+1] += q;  q = t[i*2+1] >> 25;  t[i*2+1] -= q * ((i32)1 << 25);