Commit 83abb32247

Frank Denis <github@pureftpd.org>
2020-11-23 18:59:05
std/crypto - edwards25519 precomp: prefer doublings over adds
Doublings are a little bit faster than additions, so use them half the time during precomputations.
1 parent 58c2bec
Changed files (1)
lib
std
crypto
lib/std/crypto/25519/edwards25519.zig
@@ -221,7 +221,7 @@ pub const Edwards25519 = struct {
         pc[1] = p;
         var i: usize = 2;
         while (i <= count) : (i += 1) {
-            pc[i] = pc[i - 1].add(p);
+            pc[i] = if (i % 2 == 0) pc[i / 2].dbl() else pc[i - 1].add(p);
         }
         return pc;
     }