diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig index 2432acbe53643176c86cbc2199647a8caf569209..9192dc2179d4d7a14c30c892c331df248038517c 100644 --- a/lib/std/crypto/ff.zig +++ b/lib/std/crypto/ff.zig @@ -424,6 +424,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { return self.limbs_count() * t_bits - self.leading; } + pub fn encodedLen(self: Self) usize { + return @divCeil(self.bits(), 8); + } + /// Returns the element `1`. pub fn one(self: Self) Fe { var fe = self.zero; @@ -487,6 +491,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { return self.v.toBytes(bytes, endian); } + pub fn toUint(self: Self) FeUint { + return self.v; + } + /// Rejects field elements that are not in the canonical form. pub fn rejectNonCanonical(self: Self, fe: Fe) error{NonCanonical}!void { if (fe.limbs_count() != self.limbs_count() or ct.limbsCmpGeq(fe.v, self.v)) {