authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-09-24 20:06:04+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-09-24 20:06:04+02:00
logc34e2a6b884cb30ac4466efbe961584b62730c8f
tree7de178905d6e2c64746400e69a05d94f774cd07b
parent392b17125475fd955ae591107ae92458c4bc1c4f
parent4c93bfe390719b8f42295bb9130213c8ad730809

Merge pull request 'crypto.ff: compare full Uint buffers and add a isOne() function' (#36925) from jedisct1/zig:ff-fixes2 into master

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

1 files changed, 7 insertions(+), 2 deletions(-)

lib/std/crypto/ff.zig+7-2
......@@ -207,8 +207,8 @@ pub fn Uint(comptime max_bits: comptime_int) type {
207207 pub fn compare(x: Self, y: Self) math.Order {
208208 return crypto.timing_safe.compare(
209209 Limb,
210 x.limbsConst(),
211 y.limbsConst(),
210 &x.limbs_buffer,
211 &y.limbs_buffer,
212212 .little,
213213 );
214214 }
......@@ -223,6 +223,11 @@ pub fn Uint(comptime max_bits: comptime_int) type {
223223 return @as(u1, @truncate(x.limbsConst()[0])) != 0;
224224 }
225225
226 pub fn isOne(x: Self) bool {
227 const x_limbs = x.limbsConst();
228 return ct.eql((x_limbs[0] ^ 1) | orLimbs(x_limbs[1..]), 0);
229 }
230
226231 /// Adds `y` to `x`, and returns `true` if the operation overflowed.
227232 pub fn addWithOverflow(x: *Self, y: Self) u1 {
228233 return x.conditionalAddWithOverflow(true, y);