From 076f7b5129a90485fa524b25fa2d2760f0620ce3 Mon Sep 17 00:00:00 2001 From: Georg Wiese Date: Wed, 14 Feb 2024 12:45:40 +0100 Subject: [PATCH] Improve error message in std::math::ff:inverse --- std/math/ff.asm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/std/math/ff.asm b/std/math/ff.asm index fcd9684f1..423ac53d2 100644 --- a/std/math/ff.asm +++ b/std/math/ff.asm @@ -2,7 +2,11 @@ /// Assumes that `modulus` is prime, but does not check it. let inverse = |x, modulus| if x <= 0 || x >= modulus { - std::check::panic("Tried to compute the inverse of zero, of a negative number or a number outside the field.") + if x == 0 { + std::check::panic("Tried to compute the inverse of zero.") + } else { + std::check::panic("Tried to compute the inverse of a negative number or a number outside the field.") + } } else { reduce(extended_gcd(x, modulus)[0], modulus) };