crypton 1.1.2 → 1.1.3
raw patch · 5 files changed
+64/−5 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- Crypto/PubKey/ECC/P256.hs +6/−3
- crypton.cabal +1/−1
- tests/KAT_EdDSA.hs +1/−0
- tests/KAT_PubKey/P256.hs +51/−1
CHANGELOG.md view
@@ -1,5 +1,10 @@ # CHANGELOG for crypton +## 1.1.3++* Ensure that `pointAdd` in `PubKey.ECC.P256` treats the point at infinity as the additive identity.+ [#73](https://github.com/kazu-yamamoto/crypton/pull/73)+ ## 1.1.2 * Preparing `ram` v0.22.
Crypto/PubKey/ECC/P256.hs view
@@ -110,9 +110,12 @@ -- | Add a point to another point pointAdd :: Point -> Point -> Point-pointAdd a b = withNewPoint $ \dx dy ->- withPoint a $ \ax ay -> withPoint b $ \bx by ->- ccrypton_p256e_point_add ax ay bx by dx dy+pointAdd a b+ | pointIsAtInfinity a = b+ | pointIsAtInfinity b = a+ | otherwise = withNewPoint $ \dx dy ->+ withPoint a $ \ax ay -> withPoint b $ \bx by ->+ ccrypton_p256e_point_add ax ay bx by dx dy -- | Negate a point pointNegate :: Point -> Point
crypton.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: crypton-version: 1.1.2+version: 1.1.3 license: BSD3 license-file: LICENSE copyright: Vincent Hanquez <vincent@snarc.org>
tests/KAT_EdDSA.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeOperators #-} module KAT_EdDSA (tests) where
tests/KAT_PubKey/P256.hs view
@@ -40,7 +40,9 @@ curveGen = ECC.ecc_g . ECC.common_curve $ curve pointP256ToECC :: P256.Point -> ECC.Point-pointP256ToECC = uncurry ECC.Point . P256.pointToIntegers+pointP256ToECC p+ | P256.pointIsAtInfinity p = ECC.PointO+ | otherwise = uncurry ECC.Point (P256.pointToIntegers p) i2ospScalar :: Integer -> Bytes i2ospScalar i =@@ -145,8 +147,11 @@ t = P256.pointFromIntegers (xT, yT) r = P256.pointFromIntegers (xR, yR) in r @=? P256.pointAdd s t+ , testProperty "point-add-infinity" casePointAddInfinity , testProperty "lift-to-curve" propertyLiftToCurve , testProperty "point-add" propertyPointAdd+ , testProperty "point-add-infinity-identity" propertyPointAddInfinityIdentity+ , testProperty "point-add-inverse" propertyPointAddInverse , testProperty "point-negate" propertyPointNegate , testProperty "point-mul" propertyPointMul , testProperty "infinity" $@@ -198,4 +203,49 @@ in propertyHold [ eqTest "p256" pR (P256.pointMul (unP256Scalar s) p) , eqTest "ecc" peR (pointP256ToECC pR)+ ]++ pointInfinity :: P256.Point+ pointInfinity = P256.pointFromIntegers (0, 0)++ casePointAddInfinity =+ propertyHold+ [ eqTest+ "infinity + base"+ P256.pointBase+ (P256.pointAdd pointInfinity P256.pointBase)+ , eqTest+ "base + infinity"+ P256.pointBase+ (P256.pointAdd P256.pointBase pointInfinity)+ , eqTest+ "infinity + infinity"+ pointInfinity+ (P256.pointAdd pointInfinity pointInfinity)+ ]++ propertyPointAddInfinityIdentity r =+ let p = P256.toPoint (unP256Scalar r)+ in propertyHold+ [ eqTest+ "infinity + p"+ p+ (P256.pointAdd pointInfinity p)+ , eqTest+ "p + infinity"+ p+ (P256.pointAdd p pointInfinity)+ ]++ propertyPointAddInverse r =+ let p = P256.toPoint (unP256Scalar r)+ in propertyHold+ [ eqTest+ "p + negate p"+ True+ (P256.pointIsAtInfinity (P256.pointAdd p (P256.pointNegate p)))+ , eqTest+ "negate p + p"+ True+ (P256.pointIsAtInfinity (P256.pointAdd (P256.pointNegate p) p)) ]