From e71d9b135c3099baaeba85023798d7310da3c9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Ch=C3=A9ron?= Date: Sat, 10 Jun 2017 09:22:27 +0200 Subject: [PATCH] Derive Show,Data,Typeable when defining curve singletons --- Crypto/ECC.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Crypto/ECC.hs b/Crypto/ECC.hs index 8e8e2f3..ea4d153 100644 --- a/Crypto/ECC.hs +++ b/Crypto/ECC.hs @@ -7,6 +7,7 @@ -- -- Elliptic Curve Cryptography -- +{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -37,6 +38,8 @@ import qualified Crypto.PubKey.Curve25519 as X25519 import qualified Crypto.PubKey.Curve448 as X448 import Data.Function (on) import Data.ByteArray (convert) +import Data.Data (Data()) +import Data.Typeable (Typeable()) -- | An elliptic curve key pair composed of the private part (a scalar), and -- the associated point. @@ -94,6 +97,7 @@ class EllipticCurve curve => EllipticCurveArith curve where -- -- also known as P256 data Curve_P256R1 = Curve_P256R1 + deriving (Show,Data,Typeable) instance EllipticCurve Curve_P256R1 where type Point Curve_P256R1 = P256.Point @@ -125,6 +129,7 @@ instance EllipticCurveDH Curve_P256R1 where ecdh _ s p = SharedSecret $ P256.pointDh s p data Curve_P384R1 = Curve_P384R1 + deriving (Show,Data,Typeable) instance EllipticCurve Curve_P384R1 where type Point Curve_P384R1 = Simple.Point Simple.SEC_p384r1 @@ -147,6 +152,7 @@ instance EllipticCurveDH Curve_P384R1 where Simple.Point x _ = pointSmul prx s p data Curve_P521R1 = Curve_P521R1 + deriving (Show,Data,Typeable) instance EllipticCurve Curve_P521R1 where type Point Curve_P521R1 = Simple.Point Simple.SEC_p521r1 @@ -169,6 +175,7 @@ instance EllipticCurveDH Curve_P521R1 where Simple.Point x _ = pointSmul prx s p data Curve_X25519 = Curve_X25519 + deriving (Show,Data,Typeable) instance EllipticCurve Curve_X25519 where type Point Curve_X25519 = X25519.PublicKey @@ -186,6 +193,7 @@ instance EllipticCurveDH Curve_X25519 where where secret = X25519.dh p s data Curve_X448 = Curve_X448 + deriving (Show,Data,Typeable) instance EllipticCurve Curve_X448 where type Point Curve_X448 = X448.PublicKey