authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-10-06 10:49:39+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-10-06 10:49:39+02:00
logbff490a23889750de7096d9057c0a432efc929a8
treee37c3b92c6c16d7fe99a6723737ce63c7bad4093
parentbe1fa17dce895657ca17ace304f7034d94800a9e
parentd6debf0de7266649291c47bab3014c371d96a82c

Merge pull request 'crypto.ff: remove unnecessary @as()' (#37078) from jedisct1/zig:ff-fixes10 into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37078

1 files changed, 8 insertions(+), 8 deletions(-)

lib/std/crypto/ff.zig+8-8
...@@ -1130,7 +1130,7 @@ const ct_protected = struct {...@@ -1130,7 +1130,7 @@ const ct_protected = struct {
1130 fn eql(x: anytype, y: @TypeOf(x)) bool {1130 fn eql(x: anytype, y: @TypeOf(x)) bool {
1131 const c1 = @subWithOverflow(x, y)[1];1131 const c1 = @subWithOverflow(x, y)[1];
1132 const c2 = @subWithOverflow(y, x)[1];1132 const c2 = @subWithOverflow(y, x)[1];
1133 return @as(bool, @bitCast(1 - (c1 | c2)));1133 return @bitCast(1 - (c1 | c2));
1134 }1134 }
11351135
1136 // Compares two big integers in constant time, returning true if x < y.1136 // Compares two big integers in constant time, returning true if x < y.
...@@ -1151,14 +1151,14 @@ const ct_protected = struct {...@@ -1151,14 +1151,14 @@ const ct_protected = struct {
1151 fn mulWide(x: Limb, y: Limb) WideLimb {1151 fn mulWide(x: Limb, y: Limb) WideLimb {
1152 const half_bits = @typeInfo(Limb).int.bits / 2;1152 const half_bits = @typeInfo(Limb).int.bits / 2;
1153 const Half = @Int(.unsigned, half_bits);1153 const Half = @Int(.unsigned, half_bits);
1154 const x0 = @as(Half, @truncate(x));1154 const x0: Half = @truncate(x);
1155 const x1 = @as(Half, @truncate(x >> half_bits));1155 const x1: Half = @truncate(x >> half_bits);
1156 const y0 = @as(Half, @truncate(y));1156 const y0: Half = @truncate(y);
1157 const y1 = @as(Half, @truncate(y >> half_bits));1157 const y1: Half = @truncate(y >> half_bits);
1158 const w0 = math.mulWide(Half, x0, y0);1158 const w0 = math.mulWide(Half, x0, y0);
1159 const t = math.mulWide(Half, x1, y0) + (w0 >> half_bits);1159 const t = math.mulWide(Half, x1, y0) + (w0 >> half_bits);
1160 var w1: Limb = @as(Half, @truncate(t));1160 var w1: Limb = @as(Half, @truncate(t));
1161 const w2 = @as(Half, @truncate(t >> half_bits));1161 const w2: Half = @truncate(t >> half_bits);
1162 w1 += math.mulWide(Half, x0, y1);1162 w1 += math.mulWide(Half, x0, y1);
1163 const hi = math.mulWide(Half, x1, y1) + w2 + (w1 >> half_bits);1163 const hi = math.mulWide(Half, x1, y1) + w2 + (w1 >> half_bits);
1164 const lo = x *% y;1164 const lo = x *% y;
...@@ -1202,8 +1202,8 @@ const ct_unprotected = struct {...@@ -1202,8 +1202,8 @@ const ct_unprotected = struct {
1202 fn mulWide(x: Limb, y: Limb) WideLimb {1202 fn mulWide(x: Limb, y: Limb) WideLimb {
1203 const wide = math.mulWide(Limb, x, y);1203 const wide = math.mulWide(Limb, x, y);
1204 return .{1204 return .{
1205 .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)),1205 .hi = @truncate(wide >> @typeInfo(Limb).int.bits),
1206 .lo = @as(Limb, @truncate(wide)),1206 .lo = @truncate(wide),
1207 };1207 };
1208 }1208 }
1209};1209};