Normalize result of ECC.pointNegate
This commit is contained in:
parent
4f7d742461
commit
b8b59be5a5
@ -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.
|
||||
|
||||
@ -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.
|
||||
--
|
||||
|
||||
Loading…
Reference in New Issue
Block a user