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 {
11301130 fn eql(x: anytype, y: @TypeOf(x)) bool {
11311131 const c1 = @subWithOverflow(x, y)[1];
11321132 const c2 = @subWithOverflow(y, x)[1];
1133 return @as(bool, @bitCast(1 - (c1 | c2)));
1133 return @bitCast(1 - (c1 | c2));
11341134 }
11351135
11361136 // Compares two big integers in constant time, returning true if x < y.
......@@ -1151,14 +1151,14 @@ const ct_protected = struct {
11511151 fn mulWide(x: Limb, y: Limb) WideLimb {
11521152 const half_bits = @typeInfo(Limb).int.bits / 2;
11531153 const Half = @Int(.unsigned, half_bits);
1154 const x0 = @as(Half, @truncate(x));
1155 const x1 = @as(Half, @truncate(x >> half_bits));
1156 const y0 = @as(Half, @truncate(y));
1157 const y1 = @as(Half, @truncate(y >> half_bits));
1154 const x0: Half = @truncate(x);
1155 const x1: Half = @truncate(x >> half_bits);
1156 const y0: Half = @truncate(y);
1157 const y1: Half = @truncate(y >> half_bits);
11581158 const w0 = math.mulWide(Half, x0, y0);
11591159 const t = math.mulWide(Half, x1, y0) + (w0 >> half_bits);
11601160 var w1: Limb = @as(Half, @truncate(t));
1161 const w2 = @as(Half, @truncate(t >> half_bits));
1161 const w2: Half = @truncate(t >> half_bits);
11621162 w1 += math.mulWide(Half, x0, y1);
11631163 const hi = math.mulWide(Half, x1, y1) + w2 + (w1 >> half_bits);
11641164 const lo = x *% y;
......@@ -1202,8 +1202,8 @@ const ct_unprotected = struct {
12021202 fn mulWide(x: Limb, y: Limb) WideLimb {
12031203 const wide = math.mulWide(Limb, x, y);
12041204 return .{
1205 .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)),
1206 .lo = @as(Limb, @truncate(wide)),
1205 .hi = @truncate(wide >> @typeInfo(Limb).int.bits),
1206 .lo = @truncate(wide),
12071207 };
12081208 }
12091209};