commit 83abb322478a148aeb6206e10f0f72e70d35c67d (tree)
parent 58c2bec589d6d90db31744430407bc88695b5161
Author: Frank Denis <github@pureftpd.org>
Date: Mon, 23 Nov 2020 18:59:05 +0100
std/crypto - edwards25519 precomp: prefer doublings over adds
Doublings are a little bit faster than additions, so use them half
the time during precomputations.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/std/crypto/25519/edwards25519.zig b/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;
}