commit 4fe0004a83fc61c3223ed39e1b6c523be3a1f68b
parent aae76295f8d86754de5a4560e4d6c7f2213ac5e6
Author: Jared Tobin <jared@jtobin.io>
Date: Tue, 17 Jun 2025 14:51:35 +0400
lib: better internal error messages
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/Crypto/Curve/Secp256k1.hs b/lib/Crypto/Curve/Secp256k1.hs
@@ -120,7 +120,7 @@ fi = fromIntegral
modexp :: Integer -> Natural -> Natural -> Integer
modexp b (fi -> e) m = case I.integerPowMod# b e m of
(# fi -> n | #) -> n
- (# | _ #) -> error "negative power impossible"
+ (# | _ #) -> error "ppad-secp256k1 (modexp): internal error"
{-# INLINE modexp #-}
-- generic modular inverse
@@ -239,7 +239,7 @@ affine p@(Projective x y z)
| p == _CURVE_ZERO = Affine 0 0
| z == 1 = Affine x y
| otherwise = case modinv z (fi _CURVE_P) of
- Nothing -> error "ppad-secp256k1 (affine): impossible point"
+ Nothing -> error "ppad-secp256k1 (affine): internal error"
Just iz -> Affine (modP (x * iz)) (modP (y * iz))
-- Convert to projective coordinates.
@@ -460,7 +460,7 @@ add_proj (Projective x1 y1 z1) (Projective x2 y2 z2) = runST $ do
-- algo 8, renes et al, 2015
add_mixed :: Projective -> Projective -> Projective
add_mixed (Projective x1 y1 z1) (Projective x2 y2 z2)
- | z2 /= 1 = error "ppad-secp256k1: internal error"
+ | z2 /= 1 = error "ppad-secp256k1 (add_mixed): internal error"
| otherwise = runST $ do
x3 <- newSTRef 0
y3 <- newSTRef 0