| ... | @@ -424,6 +424,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { | ... | @@ -424,6 +424,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { |
| 424 | return self.limbs_count() * t_bits - self.leading; | 424 | return self.limbs_count() * t_bits - self.leading; |
| 425 | } | 425 | } |
| 426 | | 426 | |
| | 427 | pub fn encodedLen(self: Self) usize { |
| | 428 | return @divCeil(self.bits(), 8); |
| | 429 | } |
| | 430 | |
| 427 | /// Returns the element `1`. | 431 | /// Returns the element `1`. |
| 428 | pub fn one(self: Self) Fe { | 432 | pub fn one(self: Self) Fe { |
| 429 | var fe = self.zero; | 433 | var fe = self.zero; |
| ... | @@ -487,6 +491,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { | ... | @@ -487,6 +491,10 @@ pub fn Modulus(comptime max_bits: comptime_int) type { |
| 487 | return self.v.toBytes(bytes, endian); | 491 | return self.v.toBytes(bytes, endian); |
| 488 | } | 492 | } |
| 489 | | 493 | |
| | 494 | pub fn toUint(self: Self) FeUint { |
| | 495 | return self.v; |
| | 496 | } |
| | 497 | |
| 490 | /// Rejects field elements that are not in the canonical form. | 498 | /// Rejects field elements that are not in the canonical form. |
| 491 | pub fn rejectNonCanonical(self: Self, fe: Fe) error{NonCanonical}!void { | 499 | pub fn rejectNonCanonical(self: Self, fe: Fe) error{NonCanonical}!void { |
| 492 | if (fe.limbs_count() != self.limbs_count() or ct.limbsCmpGeq(fe.v, self.v)) { | 500 | if (fe.limbs_count() != self.limbs_count() or ct.limbsCmpGeq(fe.v, self.v)) { |