diff options
| author | Frank Denis <github@pureftpd.org> | 2020-08-15 11:11:33 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-08-16 22:35:27 -0700 |
| commit | d86cde575239d4e38631d562fba8b4001d436ebd (patch) | |
| tree | 32c6c9e4a2875fc274c54deb5d55fb40a66ebe7f /lib/std | |
| parent | bcef123d902b9d1d8a27b0414932b1b92f6f1a7e (diff) | |
| download | zig-d86cde575239d4e38631d562fba8b4001d436ebd.tar.gz zig-d86cde575239d4e38631d562fba8b4001d436ebd.zip | |
Add comment, use @truncate
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/crypto/25519/curve25519.zig | 2 | ||||
| -rw-r--r-- | lib/std/crypto/25519/edwards25519.zig | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/crypto/25519/curve25519.zig b/lib/std/crypto/25519/curve25519.zig index 9980c152eb..3a4871a1f3 100644 --- a/lib/std/crypto/25519/curve25519.zig +++ b/lib/std/crypto/25519/curve25519.zig @@ -43,7 +43,7 @@ pub const Curve25519 = struct { var swap: u8 = 0; var pos: usize = bits - 1; while (true) : (pos -= 1) { - const b = (s[pos / 8] >> @intCast(u3, pos & 7)) & 1; + const b = (s[pos >> 3] >> @truncate(u3, pos)) & 1; swap ^= b; Fe.cSwap2(&x2, &x3, &z2, &z3, swap); swap = b; diff --git a/lib/std/crypto/25519/edwards25519.zig b/lib/std/crypto/25519/edwards25519.zig index a65e1dfc11..93b1a69d17 100644 --- a/lib/std/crypto/25519/edwards25519.zig +++ b/lib/std/crypto/25519/edwards25519.zig @@ -28,7 +28,7 @@ pub const Edwards25519 = struct { const vxx = x.sq().mul(v); const has_m_root = vxx.sub(u).isZero(); const has_p_root = vxx.add(u).isZero(); - if ((@boolToInt(has_m_root) | @boolToInt(has_p_root)) == 0) { + if ((@boolToInt(has_m_root) | @boolToInt(has_p_root)) == 0) { // best-effort to avoid two conditional branches return error.InvalidEncoding; } x.cMov(x.mul(Fe.sqrtm1), 1 - @boolToInt(has_m_root)); @@ -130,7 +130,7 @@ pub const Edwards25519 = struct { var pos: usize = 252; while (true) : (pos -= 4) { q = q.dbl().dbl().dbl().dbl(); - const b = (s[pos / 8] >> @intCast(u3, pos & 7)) & 0xf; + const b = (s[pos >> 3] >> @truncate(u3, pos)) & 0xf; q = q.add(pcSelect(pc, b)); if (pos == 0) break; } |
