aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorFrank Denis <github@pureftpd.org>2020-11-23 18:59:05 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-11-25 15:37:43 -0800
commit83abb322478a148aeb6206e10f0f72e70d35c67d (patch)
treef259c28f2f56bad086960c676b4f65b3cf5b4bc1 /lib/std
parent58c2bec589d6d90db31744430407bc88695b5161 (diff)
downloadzig-83abb322478a148aeb6206e10f0f72e70d35c67d.tar.gz
zig-83abb322478a148aeb6206e10f0f72e70d35c67d.zip
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 (limited to 'lib/std')
-rw-r--r--lib/std/crypto/25519/edwards25519.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/std/crypto/25519/edwards25519.zig b/lib/std/crypto/25519/edwards25519.zig
index f58f2fe8cc..008a4535b3 100644
--- 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;
}