From 5e52a7ffa2bfc1ca7fb5b17e9e74c7864eecd7e2 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Fri, 2 Dec 2016 15:28:36 +0000 Subject: [PATCH] use binary serializer for P256 instead of going through the simple point layer --- Crypto/ECC.hs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Crypto/ECC.hs b/Crypto/ECC.hs index adecae8..bccd946 100644 --- a/Crypto/ECC.hs +++ b/Crypto/ECC.hs @@ -100,13 +100,8 @@ instance EllipticCurve Curve_P256R1 where curveGenerateScalar _ = P256.scalarGenerate curveGenerateKeyPair _ = toKeyPair <$> P256.scalarGenerate where toKeyPair scalar = KeyPair (P256.toPoint scalar) scalar - encodePoint _ p = encodeECPoint (Simple.Point x y :: Simple.Point Simple.SEC_p256r1) - where - (x,y) = P256.pointToIntegers p - decodePoint _ bs = fromSimplePoint <$> decodeECPoint bs - where fromSimplePoint :: Simple.Point Simple.SEC_p256r1 -> P256.Point - fromSimplePoint (Simple.Point x y) = P256.pointFromIntegers (x,y) - fromSimplePoint Simple.PointO = error "impossible happened: fromPoint is infinite" + encodePoint _ p = P256.pointToBinary p + decodePoint _ bs = P256.pointFromBinary bs instance EllipticCurveArith Curve_P256R1 where pointAdd _ a b = P256.pointAdd a b