diff --git a/Crypto/ECC/Simple/Prim.hs b/Crypto/ECC/Simple/Prim.hs index 4a36b05..fcb0a3c 100644 --- a/Crypto/ECC/Simple/Prim.hs +++ b/Crypto/ECC/Simple/Prim.hs @@ -49,7 +49,7 @@ pointNegate :: Curve curve => Point curve -> Point curve pointNegate PointO = PointO pointNegate point@(Point x y) = case curveType point of - CurvePrime {} -> Point x (-y) + CurvePrime (CurvePrimeParam p) -> Point x (p - y) CurveBinary {} -> Point x (x `addF2m` y) -- | Elliptic Curve point addition. diff --git a/Crypto/PubKey/ECC/Prim.hs b/Crypto/PubKey/ECC/Prim.hs index a4c10b5..d87672b 100644 --- a/Crypto/PubKey/ECC/Prim.hs +++ b/Crypto/PubKey/ECC/Prim.hs @@ -31,9 +31,9 @@ scalarGenerate curve = generateBetween 1 (n - 1) -- | Elliptic Curve point negation: -- @pointNegate c p@ returns point @q@ such that @pointAdd c p q == PointO@. pointNegate :: Curve -> Point -> Point -pointNegate _ PointO = PointO -pointNegate CurveFP{} (Point x y) = Point x (-y) -pointNegate CurveF2m{} (Point x y) = Point x (x `addF2m` y) +pointNegate _ PointO = PointO +pointNegate (CurveFP c) (Point x y) = Point x (ecc_p c - y) +pointNegate CurveF2m{} (Point x y) = Point x (x `addF2m` y) -- | Elliptic Curve point addition. --