| ... | @@ -197,7 +197,7 @@ pub fn Field(comptime params: FieldParams) type { | ... | @@ -197,7 +197,7 @@ pub fn Field(comptime params: FieldParams) type { |
| 197 | /// Return the inverse of a field element, or 0 if a=0. | 197 | /// Return the inverse of a field element, or 0 if a=0. |
| 198 | // Field inversion from https://eprint.iacr.org/2021/549.pdf | 198 | // Field inversion from https://eprint.iacr.org/2021/549.pdf |
| 199 | pub fn invert(a: Fe) Fe { | 199 | pub fn invert(a: Fe) Fe { |
| 200 | const iterations = (49 * field_bits + 57) / 17; | 200 | const iterations = (49 * field_bits + if (field_bits < 46) 80 else 57) / 17; |
| 201 | const Limbs = @TypeOf(a.limbs); | 201 | const Limbs = @TypeOf(a.limbs); |
| 202 | const Word = @TypeOf(a.limbs[0]); | 202 | const Word = @TypeOf(a.limbs[0]); |
| 203 | const XLimbs = [a.limbs.len + 1]Word; | 203 | const XLimbs = [a.limbs.len + 1]Word; |