-- CryptonNewtypes.hs: OpenPGP (RFC4880) newtype wrappers for some crypton types
-- Copyright © 2012-2026  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}

module Codec.Encryption.OpenPGP.Types.Internal.CryptonNewtypes where

import Control.Monad (mzero)
import qualified Crypto.PubKey.DSA as DSA
import qualified Crypto.PubKey.ECC.ECDSA as ECDSA
import qualified Crypto.PubKey.ECC.Types as ECCT
import qualified Crypto.PubKey.RSA as RSA
import qualified Data.Aeson as A
import Data.Data (Data)
import Data.Hashable (Hashable (..))
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Prettyprinter (Pretty (..), tupled, (<+>))

newtype DSA_PublicKey
    = DSA_PublicKey
    { DSA_PublicKey -> PublicKey
unDSA_PublicKey :: DSA.PublicKey
    }
    deriving (Typeable DSA_PublicKey
Typeable DSA_PublicKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DSA_PublicKey -> c DSA_PublicKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DSA_PublicKey)
-> (DSA_PublicKey -> Constr)
-> (DSA_PublicKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DSA_PublicKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DSA_PublicKey))
-> ((forall b. Data b => b -> b) -> DSA_PublicKey -> DSA_PublicKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r)
-> (forall u. (forall d. Data d => d -> u) -> DSA_PublicKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DSA_PublicKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey)
-> Data DSA_PublicKey
DSA_PublicKey -> Constr
DSA_PublicKey -> DataType
(forall b. Data b => b -> b) -> DSA_PublicKey -> DSA_PublicKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DSA_PublicKey -> u
forall u. (forall d. Data d => d -> u) -> DSA_PublicKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PublicKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PublicKey -> c DSA_PublicKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PublicKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PublicKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PublicKey -> c DSA_PublicKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PublicKey -> c DSA_PublicKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PublicKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PublicKey
$ctoConstr :: DSA_PublicKey -> Constr
toConstr :: DSA_PublicKey -> Constr
$cdataTypeOf :: DSA_PublicKey -> DataType
dataTypeOf :: DSA_PublicKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PublicKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PublicKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PublicKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PublicKey)
$cgmapT :: (forall b. Data b => b -> b) -> DSA_PublicKey -> DSA_PublicKey
gmapT :: (forall b. Data b => b -> b) -> DSA_PublicKey -> DSA_PublicKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PublicKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_PublicKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_PublicKey -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DSA_PublicKey -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DSA_PublicKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_PublicKey -> m DSA_PublicKey
Data, DSA_PublicKey -> DSA_PublicKey -> Bool
(DSA_PublicKey -> DSA_PublicKey -> Bool)
-> (DSA_PublicKey -> DSA_PublicKey -> Bool) -> Eq DSA_PublicKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DSA_PublicKey -> DSA_PublicKey -> Bool
== :: DSA_PublicKey -> DSA_PublicKey -> Bool
$c/= :: DSA_PublicKey -> DSA_PublicKey -> Bool
/= :: DSA_PublicKey -> DSA_PublicKey -> Bool
Eq, (forall x. DSA_PublicKey -> Rep DSA_PublicKey x)
-> (forall x. Rep DSA_PublicKey x -> DSA_PublicKey)
-> Generic DSA_PublicKey
forall x. Rep DSA_PublicKey x -> DSA_PublicKey
forall x. DSA_PublicKey -> Rep DSA_PublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DSA_PublicKey -> Rep DSA_PublicKey x
from :: forall x. DSA_PublicKey -> Rep DSA_PublicKey x
$cto :: forall x. Rep DSA_PublicKey x -> DSA_PublicKey
to :: forall x. Rep DSA_PublicKey x -> DSA_PublicKey
Generic, Int -> DSA_PublicKey -> ShowS
[DSA_PublicKey] -> ShowS
DSA_PublicKey -> String
(Int -> DSA_PublicKey -> ShowS)
-> (DSA_PublicKey -> String)
-> ([DSA_PublicKey] -> ShowS)
-> Show DSA_PublicKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DSA_PublicKey -> ShowS
showsPrec :: Int -> DSA_PublicKey -> ShowS
$cshow :: DSA_PublicKey -> String
show :: DSA_PublicKey -> String
$cshowList :: [DSA_PublicKey] -> ShowS
showList :: [DSA_PublicKey] -> ShowS
Show, Typeable)

instance Ord DSA_PublicKey where
    compare :: DSA_PublicKey -> DSA_PublicKey -> Ordering
compare (DSA_PublicKey (DSA.PublicKey Params
p1 Integer
y1)) (DSA_PublicKey (DSA.PublicKey Params
p2 Integer
y2)) =
        DSA_Params -> DSA_Params -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Params -> DSA_Params
DSA_Params Params
p1) (Params -> DSA_Params
DSA_Params Params
p2) Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
y1 Integer
y2

instance A.ToJSON DSA_PublicKey where
    toJSON :: DSA_PublicKey -> Value
toJSON (DSA_PublicKey (DSA.PublicKey Params
p Integer
y)) = (DSA_Params, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Params -> DSA_Params
DSA_Params Params
p, Integer
y)

instance Pretty DSA_PublicKey where
    pretty :: forall ann. DSA_PublicKey -> Doc ann
pretty (DSA_PublicKey (DSA.PublicKey Params
p Integer
y)) =
        DSA_Params -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. DSA_Params -> Doc ann
pretty (Params -> DSA_Params
DSA_Params Params
p) Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
y

newtype RSA_PublicKey
    = RSA_PublicKey
    { RSA_PublicKey -> PublicKey
unRSA_PublicKey :: RSA.PublicKey
    }
    deriving (Typeable RSA_PublicKey
Typeable RSA_PublicKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RSA_PublicKey -> c RSA_PublicKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RSA_PublicKey)
-> (RSA_PublicKey -> Constr)
-> (RSA_PublicKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RSA_PublicKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c RSA_PublicKey))
-> ((forall b. Data b => b -> b) -> RSA_PublicKey -> RSA_PublicKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r)
-> (forall u. (forall d. Data d => d -> u) -> RSA_PublicKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RSA_PublicKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey)
-> Data RSA_PublicKey
RSA_PublicKey -> Constr
RSA_PublicKey -> DataType
(forall b. Data b => b -> b) -> RSA_PublicKey -> RSA_PublicKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> RSA_PublicKey -> u
forall u. (forall d. Data d => d -> u) -> RSA_PublicKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PublicKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PublicKey -> c RSA_PublicKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PublicKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PublicKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PublicKey -> c RSA_PublicKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PublicKey -> c RSA_PublicKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PublicKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PublicKey
$ctoConstr :: RSA_PublicKey -> Constr
toConstr :: RSA_PublicKey -> Constr
$cdataTypeOf :: RSA_PublicKey -> DataType
dataTypeOf :: RSA_PublicKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PublicKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PublicKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PublicKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PublicKey)
$cgmapT :: (forall b. Data b => b -> b) -> RSA_PublicKey -> RSA_PublicKey
gmapT :: (forall b. Data b => b -> b) -> RSA_PublicKey -> RSA_PublicKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PublicKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RSA_PublicKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RSA_PublicKey -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RSA_PublicKey -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> RSA_PublicKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> RSA_PublicKey -> m RSA_PublicKey
Data, RSA_PublicKey -> RSA_PublicKey -> Bool
(RSA_PublicKey -> RSA_PublicKey -> Bool)
-> (RSA_PublicKey -> RSA_PublicKey -> Bool) -> Eq RSA_PublicKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RSA_PublicKey -> RSA_PublicKey -> Bool
== :: RSA_PublicKey -> RSA_PublicKey -> Bool
$c/= :: RSA_PublicKey -> RSA_PublicKey -> Bool
/= :: RSA_PublicKey -> RSA_PublicKey -> Bool
Eq, (forall x. RSA_PublicKey -> Rep RSA_PublicKey x)
-> (forall x. Rep RSA_PublicKey x -> RSA_PublicKey)
-> Generic RSA_PublicKey
forall x. Rep RSA_PublicKey x -> RSA_PublicKey
forall x. RSA_PublicKey -> Rep RSA_PublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RSA_PublicKey -> Rep RSA_PublicKey x
from :: forall x. RSA_PublicKey -> Rep RSA_PublicKey x
$cto :: forall x. Rep RSA_PublicKey x -> RSA_PublicKey
to :: forall x. Rep RSA_PublicKey x -> RSA_PublicKey
Generic, Int -> RSA_PublicKey -> ShowS
[RSA_PublicKey] -> ShowS
RSA_PublicKey -> String
(Int -> RSA_PublicKey -> ShowS)
-> (RSA_PublicKey -> String)
-> ([RSA_PublicKey] -> ShowS)
-> Show RSA_PublicKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RSA_PublicKey -> ShowS
showsPrec :: Int -> RSA_PublicKey -> ShowS
$cshow :: RSA_PublicKey -> String
show :: RSA_PublicKey -> String
$cshowList :: [RSA_PublicKey] -> ShowS
showList :: [RSA_PublicKey] -> ShowS
Show, Typeable)

instance Ord RSA_PublicKey where
    compare :: RSA_PublicKey -> RSA_PublicKey -> Ordering
compare (RSA_PublicKey (RSA.PublicKey Int
size1 Integer
n1 Integer
e1)) (RSA_PublicKey (RSA.PublicKey Int
size2 Integer
n2 Integer
e2)) =
        Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Int
size1 Int
size2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
n1 Integer
n2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
e1 Integer
e2

instance A.ToJSON RSA_PublicKey where
    toJSON :: RSA_PublicKey -> Value
toJSON (RSA_PublicKey (RSA.PublicKey Int
size Integer
n Integer
e)) = (Int, Integer, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Int
size, Integer
n, Integer
e)

instance Pretty RSA_PublicKey where
    pretty :: forall ann. RSA_PublicKey -> Doc ann
pretty (RSA_PublicKey (RSA.PublicKey Int
size Integer
n Integer
e)) =
        Int -> Doc ann
forall ann. Int -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Int
size Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
n Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
e

newtype ECDSA_PublicKey
    = ECDSA_PublicKey
    { ECDSA_PublicKey -> PublicKey
unECDSA_PublicKey :: ECDSA.PublicKey
    }
    deriving (Typeable ECDSA_PublicKey
Typeable ECDSA_PublicKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ECDSA_PublicKey -> c ECDSA_PublicKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ECDSA_PublicKey)
-> (ECDSA_PublicKey -> Constr)
-> (ECDSA_PublicKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ECDSA_PublicKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ECDSA_PublicKey))
-> ((forall b. Data b => b -> b)
    -> ECDSA_PublicKey -> ECDSA_PublicKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ECDSA_PublicKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ECDSA_PublicKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PublicKey -> m ECDSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PublicKey -> m ECDSA_PublicKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PublicKey -> m ECDSA_PublicKey)
-> Data ECDSA_PublicKey
ECDSA_PublicKey -> Constr
ECDSA_PublicKey -> DataType
(forall b. Data b => b -> b) -> ECDSA_PublicKey -> ECDSA_PublicKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PublicKey -> u
forall u. (forall d. Data d => d -> u) -> ECDSA_PublicKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PublicKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PublicKey -> c ECDSA_PublicKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PublicKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PublicKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PublicKey -> c ECDSA_PublicKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PublicKey -> c ECDSA_PublicKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PublicKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PublicKey
$ctoConstr :: ECDSA_PublicKey -> Constr
toConstr :: ECDSA_PublicKey -> Constr
$cdataTypeOf :: ECDSA_PublicKey -> DataType
dataTypeOf :: ECDSA_PublicKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PublicKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PublicKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PublicKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PublicKey)
$cgmapT :: (forall b. Data b => b -> b) -> ECDSA_PublicKey -> ECDSA_PublicKey
gmapT :: (forall b. Data b => b -> b) -> ECDSA_PublicKey -> ECDSA_PublicKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PublicKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ECDSA_PublicKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ECDSA_PublicKey -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PublicKey -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PublicKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PublicKey -> m ECDSA_PublicKey
Data, ECDSA_PublicKey -> ECDSA_PublicKey -> Bool
(ECDSA_PublicKey -> ECDSA_PublicKey -> Bool)
-> (ECDSA_PublicKey -> ECDSA_PublicKey -> Bool)
-> Eq ECDSA_PublicKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ECDSA_PublicKey -> ECDSA_PublicKey -> Bool
== :: ECDSA_PublicKey -> ECDSA_PublicKey -> Bool
$c/= :: ECDSA_PublicKey -> ECDSA_PublicKey -> Bool
/= :: ECDSA_PublicKey -> ECDSA_PublicKey -> Bool
Eq, (forall x. ECDSA_PublicKey -> Rep ECDSA_PublicKey x)
-> (forall x. Rep ECDSA_PublicKey x -> ECDSA_PublicKey)
-> Generic ECDSA_PublicKey
forall x. Rep ECDSA_PublicKey x -> ECDSA_PublicKey
forall x. ECDSA_PublicKey -> Rep ECDSA_PublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ECDSA_PublicKey -> Rep ECDSA_PublicKey x
from :: forall x. ECDSA_PublicKey -> Rep ECDSA_PublicKey x
$cto :: forall x. Rep ECDSA_PublicKey x -> ECDSA_PublicKey
to :: forall x. Rep ECDSA_PublicKey x -> ECDSA_PublicKey
Generic, Int -> ECDSA_PublicKey -> ShowS
[ECDSA_PublicKey] -> ShowS
ECDSA_PublicKey -> String
(Int -> ECDSA_PublicKey -> ShowS)
-> (ECDSA_PublicKey -> String)
-> ([ECDSA_PublicKey] -> ShowS)
-> Show ECDSA_PublicKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ECDSA_PublicKey -> ShowS
showsPrec :: Int -> ECDSA_PublicKey -> ShowS
$cshow :: ECDSA_PublicKey -> String
show :: ECDSA_PublicKey -> String
$cshowList :: [ECDSA_PublicKey] -> ShowS
showList :: [ECDSA_PublicKey] -> ShowS
Show, Typeable)

instance Ord ECDSA_PublicKey where
    compare :: ECDSA_PublicKey -> ECDSA_PublicKey -> Ordering
compare (ECDSA_PublicKey (ECDSA.PublicKey Curve
curve1 PublicPoint
q1)) (ECDSA_PublicKey (ECDSA.PublicKey Curve
curve2 PublicPoint
q2)) =
        Curve -> Curve -> Ordering
compareCurve Curve
curve1 Curve
curve2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> PublicPoint -> PublicPoint -> Ordering
compareECPoint PublicPoint
q1 PublicPoint
q2

instance A.ToJSON ECDSA_PublicKey where
    toJSON :: ECDSA_PublicKey -> Value
toJSON (ECDSA_PublicKey (ECDSA.PublicKey Curve
curve PublicPoint
q)) =
        (String, String) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Curve -> String
forall a. Show a => a -> String
show Curve
curve, PublicPoint -> String
forall a. Show a => a -> String
show PublicPoint
q)

instance Pretty ECDSA_PublicKey where
    pretty :: forall ann. ECDSA_PublicKey -> Doc ann
pretty (ECDSA_PublicKey (ECDSA.PublicKey Curve
curve PublicPoint
q)) =
        (String, String) -> Doc ann
forall ann. (String, String) -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Curve -> String
forall a. Show a => a -> String
show Curve
curve, PublicPoint -> String
forall a. Show a => a -> String
show PublicPoint
q)

newtype DSA_PrivateKey
    = DSA_PrivateKey
    { DSA_PrivateKey -> PrivateKey
unDSA_PrivateKey :: DSA.PrivateKey
    }
    deriving (Typeable DSA_PrivateKey
Typeable DSA_PrivateKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DSA_PrivateKey -> c DSA_PrivateKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DSA_PrivateKey)
-> (DSA_PrivateKey -> Constr)
-> (DSA_PrivateKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DSA_PrivateKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DSA_PrivateKey))
-> ((forall b. Data b => b -> b)
    -> DSA_PrivateKey -> DSA_PrivateKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> DSA_PrivateKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DSA_PrivateKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> DSA_PrivateKey -> m DSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> DSA_PrivateKey -> m DSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> DSA_PrivateKey -> m DSA_PrivateKey)
-> Data DSA_PrivateKey
DSA_PrivateKey -> Constr
DSA_PrivateKey -> DataType
(forall b. Data b => b -> b) -> DSA_PrivateKey -> DSA_PrivateKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> DSA_PrivateKey -> u
forall u. (forall d. Data d => d -> u) -> DSA_PrivateKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PrivateKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PrivateKey -> c DSA_PrivateKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PrivateKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PrivateKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PrivateKey -> c DSA_PrivateKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_PrivateKey -> c DSA_PrivateKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PrivateKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_PrivateKey
$ctoConstr :: DSA_PrivateKey -> Constr
toConstr :: DSA_PrivateKey -> Constr
$cdataTypeOf :: DSA_PrivateKey -> DataType
dataTypeOf :: DSA_PrivateKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PrivateKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_PrivateKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PrivateKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c DSA_PrivateKey)
$cgmapT :: (forall b. Data b => b -> b) -> DSA_PrivateKey -> DSA_PrivateKey
gmapT :: (forall b. Data b => b -> b) -> DSA_PrivateKey -> DSA_PrivateKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_PrivateKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_PrivateKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_PrivateKey -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> DSA_PrivateKey -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> DSA_PrivateKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> DSA_PrivateKey -> m DSA_PrivateKey
Data, DSA_PrivateKey -> DSA_PrivateKey -> Bool
(DSA_PrivateKey -> DSA_PrivateKey -> Bool)
-> (DSA_PrivateKey -> DSA_PrivateKey -> Bool) -> Eq DSA_PrivateKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DSA_PrivateKey -> DSA_PrivateKey -> Bool
== :: DSA_PrivateKey -> DSA_PrivateKey -> Bool
$c/= :: DSA_PrivateKey -> DSA_PrivateKey -> Bool
/= :: DSA_PrivateKey -> DSA_PrivateKey -> Bool
Eq, (forall x. DSA_PrivateKey -> Rep DSA_PrivateKey x)
-> (forall x. Rep DSA_PrivateKey x -> DSA_PrivateKey)
-> Generic DSA_PrivateKey
forall x. Rep DSA_PrivateKey x -> DSA_PrivateKey
forall x. DSA_PrivateKey -> Rep DSA_PrivateKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DSA_PrivateKey -> Rep DSA_PrivateKey x
from :: forall x. DSA_PrivateKey -> Rep DSA_PrivateKey x
$cto :: forall x. Rep DSA_PrivateKey x -> DSA_PrivateKey
to :: forall x. Rep DSA_PrivateKey x -> DSA_PrivateKey
Generic, Int -> DSA_PrivateKey -> ShowS
[DSA_PrivateKey] -> ShowS
DSA_PrivateKey -> String
(Int -> DSA_PrivateKey -> ShowS)
-> (DSA_PrivateKey -> String)
-> ([DSA_PrivateKey] -> ShowS)
-> Show DSA_PrivateKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DSA_PrivateKey -> ShowS
showsPrec :: Int -> DSA_PrivateKey -> ShowS
$cshow :: DSA_PrivateKey -> String
show :: DSA_PrivateKey -> String
$cshowList :: [DSA_PrivateKey] -> ShowS
showList :: [DSA_PrivateKey] -> ShowS
Show, Typeable)

instance Ord DSA_PrivateKey where
    compare :: DSA_PrivateKey -> DSA_PrivateKey -> Ordering
compare (DSA_PrivateKey (DSA.PrivateKey Params
p1 Integer
x1)) (DSA_PrivateKey (DSA.PrivateKey Params
p2 Integer
x2)) =
        DSA_Params -> DSA_Params -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Params -> DSA_Params
DSA_Params Params
p1) (Params -> DSA_Params
DSA_Params Params
p2) Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
x1 Integer
x2

instance A.ToJSON DSA_PrivateKey where
    toJSON :: DSA_PrivateKey -> Value
toJSON (DSA_PrivateKey (DSA.PrivateKey Params
p Integer
x)) = (DSA_Params, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Params -> DSA_Params
DSA_Params Params
p, Integer
x)

instance Pretty DSA_PrivateKey where
    pretty :: forall ann. DSA_PrivateKey -> Doc ann
pretty (DSA_PrivateKey (DSA.PrivateKey Params
p Integer
x)) = (DSA_Params, Integer) -> Doc ann
forall ann. (DSA_Params, Integer) -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Params -> DSA_Params
DSA_Params Params
p, Integer
x)

newtype RSA_PrivateKey
    = RSA_PrivateKey
    { RSA_PrivateKey -> PrivateKey
unRSA_PrivateKey :: RSA.PrivateKey
    }
    deriving (Typeable RSA_PrivateKey
Typeable RSA_PrivateKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> RSA_PrivateKey -> c RSA_PrivateKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c RSA_PrivateKey)
-> (RSA_PrivateKey -> Constr)
-> (RSA_PrivateKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c RSA_PrivateKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c RSA_PrivateKey))
-> ((forall b. Data b => b -> b)
    -> RSA_PrivateKey -> RSA_PrivateKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> RSA_PrivateKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> RSA_PrivateKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> RSA_PrivateKey -> m RSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> RSA_PrivateKey -> m RSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> RSA_PrivateKey -> m RSA_PrivateKey)
-> Data RSA_PrivateKey
RSA_PrivateKey -> Constr
RSA_PrivateKey -> DataType
(forall b. Data b => b -> b) -> RSA_PrivateKey -> RSA_PrivateKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> RSA_PrivateKey -> u
forall u. (forall d. Data d => d -> u) -> RSA_PrivateKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PrivateKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PrivateKey -> c RSA_PrivateKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PrivateKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PrivateKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PrivateKey -> c RSA_PrivateKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> RSA_PrivateKey -> c RSA_PrivateKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PrivateKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c RSA_PrivateKey
$ctoConstr :: RSA_PrivateKey -> Constr
toConstr :: RSA_PrivateKey -> Constr
$cdataTypeOf :: RSA_PrivateKey -> DataType
dataTypeOf :: RSA_PrivateKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PrivateKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c RSA_PrivateKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PrivateKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c RSA_PrivateKey)
$cgmapT :: (forall b. Data b => b -> b) -> RSA_PrivateKey -> RSA_PrivateKey
gmapT :: (forall b. Data b => b -> b) -> RSA_PrivateKey -> RSA_PrivateKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> RSA_PrivateKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> RSA_PrivateKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> RSA_PrivateKey -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> RSA_PrivateKey -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> RSA_PrivateKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> RSA_PrivateKey -> m RSA_PrivateKey
Data, RSA_PrivateKey -> RSA_PrivateKey -> Bool
(RSA_PrivateKey -> RSA_PrivateKey -> Bool)
-> (RSA_PrivateKey -> RSA_PrivateKey -> Bool) -> Eq RSA_PrivateKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RSA_PrivateKey -> RSA_PrivateKey -> Bool
== :: RSA_PrivateKey -> RSA_PrivateKey -> Bool
$c/= :: RSA_PrivateKey -> RSA_PrivateKey -> Bool
/= :: RSA_PrivateKey -> RSA_PrivateKey -> Bool
Eq, (forall x. RSA_PrivateKey -> Rep RSA_PrivateKey x)
-> (forall x. Rep RSA_PrivateKey x -> RSA_PrivateKey)
-> Generic RSA_PrivateKey
forall x. Rep RSA_PrivateKey x -> RSA_PrivateKey
forall x. RSA_PrivateKey -> Rep RSA_PrivateKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RSA_PrivateKey -> Rep RSA_PrivateKey x
from :: forall x. RSA_PrivateKey -> Rep RSA_PrivateKey x
$cto :: forall x. Rep RSA_PrivateKey x -> RSA_PrivateKey
to :: forall x. Rep RSA_PrivateKey x -> RSA_PrivateKey
Generic, Int -> RSA_PrivateKey -> ShowS
[RSA_PrivateKey] -> ShowS
RSA_PrivateKey -> String
(Int -> RSA_PrivateKey -> ShowS)
-> (RSA_PrivateKey -> String)
-> ([RSA_PrivateKey] -> ShowS)
-> Show RSA_PrivateKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RSA_PrivateKey -> ShowS
showsPrec :: Int -> RSA_PrivateKey -> ShowS
$cshow :: RSA_PrivateKey -> String
show :: RSA_PrivateKey -> String
$cshowList :: [RSA_PrivateKey] -> ShowS
showList :: [RSA_PrivateKey] -> ShowS
Show, Typeable)

instance Ord RSA_PrivateKey where
    compare :: RSA_PrivateKey -> RSA_PrivateKey -> Ordering
compare
        (RSA_PrivateKey (RSA.PrivateKey PublicKey
pub1 Integer
d1 Integer
p1 Integer
q1 Integer
dP1 Integer
dQ1 Integer
qinv1))
        (RSA_PrivateKey (RSA.PrivateKey PublicKey
pub2 Integer
d2 Integer
p2 Integer
q2 Integer
dP2 Integer
dQ2 Integer
qinv2)) =
            RSA_PublicKey -> RSA_PublicKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (PublicKey -> RSA_PublicKey
RSA_PublicKey PublicKey
pub1) (PublicKey -> RSA_PublicKey
RSA_PublicKey PublicKey
pub2)
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
d1 Integer
d2
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
p1 Integer
p2
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
q1 Integer
q2
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
dP1 Integer
dP2
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
dQ1 Integer
dQ2
                Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
qinv1 Integer
qinv2

instance A.ToJSON RSA_PrivateKey where
    toJSON :: RSA_PrivateKey -> Value
toJSON (RSA_PrivateKey (RSA.PrivateKey PublicKey
pub Integer
d Integer
p Integer
q Integer
dP Integer
dQ Integer
qinv)) =
        (RSA_PublicKey, Integer, Integer, Integer, Integer, Integer,
 Integer)
-> Value
forall a. ToJSON a => a -> Value
A.toJSON (PublicKey -> RSA_PublicKey
RSA_PublicKey PublicKey
pub, Integer
d, Integer
p, Integer
q, Integer
dP, Integer
dQ, Integer
qinv)

instance Pretty RSA_PrivateKey where
    pretty :: forall ann. RSA_PrivateKey -> Doc ann
pretty (RSA_PrivateKey (RSA.PrivateKey PublicKey
pub Integer
d Integer
p Integer
q Integer
dP Integer
dQ Integer
qinv)) =
        RSA_PublicKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. RSA_PublicKey -> Doc ann
pretty (PublicKey -> RSA_PublicKey
RSA_PublicKey PublicKey
pub)
            Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
tupled ((Integer -> Doc ann) -> [Integer] -> [Doc ann]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty [Integer
d, Integer
p, Integer
q, Integer
dP, Integer
dQ, Integer
qinv])

newtype ECDSA_PrivateKey
    = ECDSA_PrivateKey
    { ECDSA_PrivateKey -> PrivateKey
unECDSA_PrivateKey :: ECDSA.PrivateKey
    }
    deriving (Typeable ECDSA_PrivateKey
Typeable ECDSA_PrivateKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ECDSA_PrivateKey -> c ECDSA_PrivateKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ECDSA_PrivateKey)
-> (ECDSA_PrivateKey -> Constr)
-> (ECDSA_PrivateKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ECDSA_PrivateKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ECDSA_PrivateKey))
-> ((forall b. Data b => b -> b)
    -> ECDSA_PrivateKey -> ECDSA_PrivateKey)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PrivateKey -> m ECDSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PrivateKey -> m ECDSA_PrivateKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ECDSA_PrivateKey -> m ECDSA_PrivateKey)
-> Data ECDSA_PrivateKey
ECDSA_PrivateKey -> Constr
ECDSA_PrivateKey -> DataType
(forall b. Data b => b -> b)
-> ECDSA_PrivateKey -> ECDSA_PrivateKey
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> u
forall u. (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PrivateKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PrivateKey -> c ECDSA_PrivateKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PrivateKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PrivateKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PrivateKey -> c ECDSA_PrivateKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECDSA_PrivateKey -> c ECDSA_PrivateKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PrivateKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECDSA_PrivateKey
$ctoConstr :: ECDSA_PrivateKey -> Constr
toConstr :: ECDSA_PrivateKey -> Constr
$cdataTypeOf :: ECDSA_PrivateKey -> DataType
dataTypeOf :: ECDSA_PrivateKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PrivateKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECDSA_PrivateKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PrivateKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECDSA_PrivateKey)
$cgmapT :: (forall b. Data b => b -> b)
-> ECDSA_PrivateKey -> ECDSA_PrivateKey
gmapT :: (forall b. Data b => b -> b)
-> ECDSA_PrivateKey -> ECDSA_PrivateKey
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECDSA_PrivateKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ECDSA_PrivateKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ECDSA_PrivateKey -> m ECDSA_PrivateKey
Data, ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool
(ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool)
-> (ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool)
-> Eq ECDSA_PrivateKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool
== :: ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool
$c/= :: ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool
/= :: ECDSA_PrivateKey -> ECDSA_PrivateKey -> Bool
Eq, (forall x. ECDSA_PrivateKey -> Rep ECDSA_PrivateKey x)
-> (forall x. Rep ECDSA_PrivateKey x -> ECDSA_PrivateKey)
-> Generic ECDSA_PrivateKey
forall x. Rep ECDSA_PrivateKey x -> ECDSA_PrivateKey
forall x. ECDSA_PrivateKey -> Rep ECDSA_PrivateKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ECDSA_PrivateKey -> Rep ECDSA_PrivateKey x
from :: forall x. ECDSA_PrivateKey -> Rep ECDSA_PrivateKey x
$cto :: forall x. Rep ECDSA_PrivateKey x -> ECDSA_PrivateKey
to :: forall x. Rep ECDSA_PrivateKey x -> ECDSA_PrivateKey
Generic, Int -> ECDSA_PrivateKey -> ShowS
[ECDSA_PrivateKey] -> ShowS
ECDSA_PrivateKey -> String
(Int -> ECDSA_PrivateKey -> ShowS)
-> (ECDSA_PrivateKey -> String)
-> ([ECDSA_PrivateKey] -> ShowS)
-> Show ECDSA_PrivateKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ECDSA_PrivateKey -> ShowS
showsPrec :: Int -> ECDSA_PrivateKey -> ShowS
$cshow :: ECDSA_PrivateKey -> String
show :: ECDSA_PrivateKey -> String
$cshowList :: [ECDSA_PrivateKey] -> ShowS
showList :: [ECDSA_PrivateKey] -> ShowS
Show, Typeable)

instance Ord ECDSA_PrivateKey where
    compare :: ECDSA_PrivateKey -> ECDSA_PrivateKey -> Ordering
compare (ECDSA_PrivateKey (ECDSA.PrivateKey Curve
curve1 Integer
d1)) (ECDSA_PrivateKey (ECDSA.PrivateKey Curve
curve2 Integer
d2)) =
        Curve -> Curve -> Ordering
compareCurve Curve
curve1 Curve
curve2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
d1 Integer
d2

instance A.ToJSON ECDSA_PrivateKey where
    toJSON :: ECDSA_PrivateKey -> Value
toJSON (ECDSA_PrivateKey (ECDSA.PrivateKey Curve
curve Integer
d)) =
        (String, String) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Curve -> String
forall a. Show a => a -> String
show Curve
curve, Integer -> String
forall a. Show a => a -> String
show Integer
d)

instance Pretty ECDSA_PrivateKey where
    pretty :: forall ann. ECDSA_PrivateKey -> Doc ann
pretty (ECDSA_PrivateKey (ECDSA.PrivateKey Curve
curve Integer
d)) =
        (String, String) -> Doc ann
forall ann. (String, String) -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Curve -> String
forall a. Show a => a -> String
show Curve
curve, Integer -> String
forall a. Show a => a -> String
show Integer
d)

newtype DSA_Params
    = DSA_Params
    { DSA_Params -> Params
unDSA_Params :: DSA.Params
    }
    deriving (Typeable DSA_Params
Typeable DSA_Params =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DSA_Params -> c DSA_Params)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DSA_Params)
-> (DSA_Params -> Constr)
-> (DSA_Params -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DSA_Params))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DSA_Params))
-> ((forall b. Data b => b -> b) -> DSA_Params -> DSA_Params)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_Params -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DSA_Params -> r)
-> (forall u. (forall d. Data d => d -> u) -> DSA_Params -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DSA_Params -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params)
-> Data DSA_Params
DSA_Params -> Constr
DSA_Params -> DataType
(forall b. Data b => b -> b) -> DSA_Params -> DSA_Params
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DSA_Params -> u
forall u. (forall d. Data d => d -> u) -> DSA_Params -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_Params
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_Params -> c DSA_Params
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_Params)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DSA_Params)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_Params -> c DSA_Params
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DSA_Params -> c DSA_Params
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_Params
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DSA_Params
$ctoConstr :: DSA_Params -> Constr
toConstr :: DSA_Params -> Constr
$cdataTypeOf :: DSA_Params -> DataType
dataTypeOf :: DSA_Params -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_Params)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DSA_Params)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DSA_Params)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DSA_Params)
$cgmapT :: (forall b. Data b => b -> b) -> DSA_Params -> DSA_Params
gmapT :: (forall b. Data b => b -> b) -> DSA_Params -> DSA_Params
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DSA_Params -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_Params -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DSA_Params -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DSA_Params -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DSA_Params -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DSA_Params -> m DSA_Params
Data, DSA_Params -> DSA_Params -> Bool
(DSA_Params -> DSA_Params -> Bool)
-> (DSA_Params -> DSA_Params -> Bool) -> Eq DSA_Params
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DSA_Params -> DSA_Params -> Bool
== :: DSA_Params -> DSA_Params -> Bool
$c/= :: DSA_Params -> DSA_Params -> Bool
/= :: DSA_Params -> DSA_Params -> Bool
Eq, (forall x. DSA_Params -> Rep DSA_Params x)
-> (forall x. Rep DSA_Params x -> DSA_Params) -> Generic DSA_Params
forall x. Rep DSA_Params x -> DSA_Params
forall x. DSA_Params -> Rep DSA_Params x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DSA_Params -> Rep DSA_Params x
from :: forall x. DSA_Params -> Rep DSA_Params x
$cto :: forall x. Rep DSA_Params x -> DSA_Params
to :: forall x. Rep DSA_Params x -> DSA_Params
Generic, Int -> DSA_Params -> ShowS
[DSA_Params] -> ShowS
DSA_Params -> String
(Int -> DSA_Params -> ShowS)
-> (DSA_Params -> String)
-> ([DSA_Params] -> ShowS)
-> Show DSA_Params
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DSA_Params -> ShowS
showsPrec :: Int -> DSA_Params -> ShowS
$cshow :: DSA_Params -> String
show :: DSA_Params -> String
$cshowList :: [DSA_Params] -> ShowS
showList :: [DSA_Params] -> ShowS
Show, Typeable)

instance Ord DSA_Params where
    compare :: DSA_Params -> DSA_Params -> Ordering
compare (DSA_Params (DSA.Params Integer
p1 Integer
g1 Integer
q1)) (DSA_Params (DSA.Params Integer
p2 Integer
g2 Integer
q2)) =
        Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
p1 Integer
p2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
g1 Integer
g2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
q1 Integer
q2

instance A.ToJSON DSA_Params where
    toJSON :: DSA_Params -> Value
toJSON (DSA_Params (DSA.Params Integer
p Integer
g Integer
q)) = (Integer, Integer, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Integer
p, Integer
g, Integer
q)

instance Pretty DSA_Params where
    pretty :: forall ann. DSA_Params -> Doc ann
pretty (DSA_Params (DSA.Params Integer
p Integer
g Integer
q)) = (Integer, Integer, Integer) -> Doc ann
forall ann. (Integer, Integer, Integer) -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Integer
p, Integer
g, Integer
q)

instance Hashable DSA_Params where
    hashWithSalt :: Int -> DSA_Params -> Int
hashWithSalt Int
s (DSA_Params (DSA.Params Integer
p Integer
g Integer
q)) =
        Int
s Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
p Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
g Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
q

instance Hashable DSA_PublicKey where
    hashWithSalt :: Int -> DSA_PublicKey -> Int
hashWithSalt Int
s (DSA_PublicKey (DSA.PublicKey Params
p Integer
y)) =
        Int
s Int -> DSA_Params -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Params -> DSA_Params
DSA_Params Params
p Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
y

instance Hashable DSA_PrivateKey where
    hashWithSalt :: Int -> DSA_PrivateKey -> Int
hashWithSalt Int
s (DSA_PrivateKey (DSA.PrivateKey Params
p Integer
x)) =
        Int
s Int -> DSA_Params -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Params -> DSA_Params
DSA_Params Params
p Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
x

instance Hashable RSA_PublicKey where
    hashWithSalt :: Int -> RSA_PublicKey -> Int
hashWithSalt Int
s (RSA_PublicKey (RSA.PublicKey Int
size Integer
n Integer
e)) =
        Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Int
size Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
n Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
e

instance Hashable RSA_PrivateKey where
    hashWithSalt :: Int -> RSA_PrivateKey -> Int
hashWithSalt Int
s (RSA_PrivateKey (RSA.PrivateKey PublicKey
pub Integer
d Integer
p Integer
q Integer
dP Integer
dQ Integer
qinv)) =
        Int
s
            Int -> RSA_PublicKey -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` PublicKey -> RSA_PublicKey
RSA_PublicKey PublicKey
pub
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
d
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
p
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
q
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
dP
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
dQ
            Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
qinv

instance Hashable ECDSA_PublicKey where
    hashWithSalt :: Int -> ECDSA_PublicKey -> Int
hashWithSalt Int
s (ECDSA_PublicKey (ECDSA.PublicKey Curve
curve PublicPoint
q)) =
        Int -> Curve -> Int
hashWithCurve Int
s Curve
curve Int -> PublicPoint -> Int
`hashWithECPoint` PublicPoint
q

instance Hashable ECDSA_PrivateKey where
    hashWithSalt :: Int -> ECDSA_PrivateKey -> Int
hashWithSalt Int
s (ECDSA_PrivateKey (ECDSA.PrivateKey Curve
curve Integer
d)) =
        Int -> Curve -> Int
hashWithCurve Int
s Curve
curve Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
d

-- Structural helpers for ECCT types that lack Hashable/Ord instances.

hashWithECPoint :: Int -> ECCT.Point -> Int
hashWithECPoint :: Int -> PublicPoint -> Int
hashWithECPoint Int
s PublicPoint
ECCT.PointO = Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
0 :: Int)
hashWithECPoint Int
s (ECCT.Point Integer
x Integer
y) =
    Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
1 :: Int) Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
x Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
y

hashWithCurveCommon :: Int -> ECCT.CurveCommon -> Int
hashWithCurveCommon :: Int -> CurveCommon -> Int
hashWithCurveCommon Int
s CurveCommon
cc =
    Int -> PublicPoint -> Int
hashWithECPoint
        (Int
s Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` CurveCommon -> Integer
ECCT.ecc_a CurveCommon
cc Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` CurveCommon -> Integer
ECCT.ecc_b CurveCommon
cc)
        (CurveCommon -> PublicPoint
ECCT.ecc_g CurveCommon
cc)
        Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` CurveCommon -> Integer
ECCT.ecc_n CurveCommon
cc
        Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` CurveCommon -> Integer
ECCT.ecc_h CurveCommon
cc

hashWithCurve :: Int -> ECCT.Curve -> Int
hashWithCurve :: Int -> Curve -> Int
hashWithCurve Int
s (ECCT.CurveFP (ECCT.CurvePrime Integer
p CurveCommon
cc)) =
    Int -> CurveCommon -> Int
hashWithCurveCommon
        (Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
0 :: Int) Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
p)
        CurveCommon
cc
hashWithCurve Int
s (ECCT.CurveF2m (ECCT.CurveBinary Integer
poly CurveCommon
cc)) =
    Int -> CurveCommon -> Int
hashWithCurveCommon
        (Int
s Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` (Int
1 :: Int) Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
`hashWithSalt` Integer
poly)
        CurveCommon
cc

compareECPoint :: ECCT.Point -> ECCT.Point -> Ordering
compareECPoint :: PublicPoint -> PublicPoint -> Ordering
compareECPoint PublicPoint
ECCT.PointO PublicPoint
ECCT.PointO = Ordering
EQ
compareECPoint PublicPoint
ECCT.PointO PublicPoint
_ = Ordering
LT
compareECPoint PublicPoint
_ PublicPoint
ECCT.PointO = Ordering
GT
compareECPoint (ECCT.Point Integer
x1 Integer
y1) (ECCT.Point Integer
x2 Integer
y2) =
    Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
x1 Integer
x2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
y1 Integer
y2

compareCurveCommon
    :: ECCT.CurveCommon -> ECCT.CurveCommon -> Ordering
compareCurveCommon :: CurveCommon -> CurveCommon -> Ordering
compareCurveCommon CurveCommon
cc1 CurveCommon
cc2 =
    Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (CurveCommon -> Integer
ECCT.ecc_a CurveCommon
cc1) (CurveCommon -> Integer
ECCT.ecc_a CurveCommon
cc2)
        Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (CurveCommon -> Integer
ECCT.ecc_b CurveCommon
cc1) (CurveCommon -> Integer
ECCT.ecc_b CurveCommon
cc2)
        Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> PublicPoint -> PublicPoint -> Ordering
compareECPoint (CurveCommon -> PublicPoint
ECCT.ecc_g CurveCommon
cc1) (CurveCommon -> PublicPoint
ECCT.ecc_g CurveCommon
cc2)
        Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (CurveCommon -> Integer
ECCT.ecc_n CurveCommon
cc1) (CurveCommon -> Integer
ECCT.ecc_n CurveCommon
cc2)
        Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (CurveCommon -> Integer
ECCT.ecc_h CurveCommon
cc1) (CurveCommon -> Integer
ECCT.ecc_h CurveCommon
cc2)

compareCurve :: ECCT.Curve -> ECCT.Curve -> Ordering
compareCurve :: Curve -> Curve -> Ordering
compareCurve (ECCT.CurveFP (ECCT.CurvePrime Integer
p1 CurveCommon
cc1)) (ECCT.CurveFP (ECCT.CurvePrime Integer
p2 CurveCommon
cc2)) =
    Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
p1 Integer
p2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> CurveCommon -> CurveCommon -> Ordering
compareCurveCommon CurveCommon
cc1 CurveCommon
cc2
compareCurve (ECCT.CurveF2m (ECCT.CurveBinary Integer
poly1 CurveCommon
cc1)) (ECCT.CurveF2m (ECCT.CurveBinary Integer
poly2 CurveCommon
cc2)) =
    Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
poly1 Integer
poly2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> CurveCommon -> CurveCommon -> Ordering
compareCurveCommon CurveCommon
cc1 CurveCommon
cc2
compareCurve (ECCT.CurveFP CurvePrime
_) (ECCT.CurveF2m CurveBinary
_) = Ordering
LT
compareCurve (ECCT.CurveF2m CurveBinary
_) (ECCT.CurveFP CurvePrime
_) = Ordering
GT

newtype ECurvePoint
    = ECurvePoint
    { ECurvePoint -> PublicPoint
unECurvepoint :: ECCT.Point
    }
    deriving (Typeable ECurvePoint
Typeable ECurvePoint =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ECurvePoint -> c ECurvePoint)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ECurvePoint)
-> (ECurvePoint -> Constr)
-> (ECurvePoint -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ECurvePoint))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ECurvePoint))
-> ((forall b. Data b => b -> b) -> ECurvePoint -> ECurvePoint)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r)
-> (forall u. (forall d. Data d => d -> u) -> ECurvePoint -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ECurvePoint -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint)
-> Data ECurvePoint
ECurvePoint -> Constr
ECurvePoint -> DataType
(forall b. Data b => b -> b) -> ECurvePoint -> ECurvePoint
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ECurvePoint -> u
forall u. (forall d. Data d => d -> u) -> ECurvePoint -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECurvePoint
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECurvePoint -> c ECurvePoint
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECurvePoint)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECurvePoint)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECurvePoint -> c ECurvePoint
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ECurvePoint -> c ECurvePoint
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECurvePoint
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ECurvePoint
$ctoConstr :: ECurvePoint -> Constr
toConstr :: ECurvePoint -> Constr
$cdataTypeOf :: ECurvePoint -> DataType
dataTypeOf :: ECurvePoint -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECurvePoint)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ECurvePoint)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECurvePoint)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ECurvePoint)
$cgmapT :: (forall b. Data b => b -> b) -> ECurvePoint -> ECurvePoint
gmapT :: (forall b. Data b => b -> b) -> ECurvePoint -> ECurvePoint
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ECurvePoint -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ECurvePoint -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ECurvePoint -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ECurvePoint -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ECurvePoint -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ECurvePoint -> m ECurvePoint
Data, ECurvePoint -> ECurvePoint -> Bool
(ECurvePoint -> ECurvePoint -> Bool)
-> (ECurvePoint -> ECurvePoint -> Bool) -> Eq ECurvePoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ECurvePoint -> ECurvePoint -> Bool
== :: ECurvePoint -> ECurvePoint -> Bool
$c/= :: ECurvePoint -> ECurvePoint -> Bool
/= :: ECurvePoint -> ECurvePoint -> Bool
Eq, (forall x. ECurvePoint -> Rep ECurvePoint x)
-> (forall x. Rep ECurvePoint x -> ECurvePoint)
-> Generic ECurvePoint
forall x. Rep ECurvePoint x -> ECurvePoint
forall x. ECurvePoint -> Rep ECurvePoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ECurvePoint -> Rep ECurvePoint x
from :: forall x. ECurvePoint -> Rep ECurvePoint x
$cto :: forall x. Rep ECurvePoint x -> ECurvePoint
to :: forall x. Rep ECurvePoint x -> ECurvePoint
Generic, Int -> ECurvePoint -> ShowS
[ECurvePoint] -> ShowS
ECurvePoint -> String
(Int -> ECurvePoint -> ShowS)
-> (ECurvePoint -> String)
-> ([ECurvePoint] -> ShowS)
-> Show ECurvePoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ECurvePoint -> ShowS
showsPrec :: Int -> ECurvePoint -> ShowS
$cshow :: ECurvePoint -> String
show :: ECurvePoint -> String
$cshowList :: [ECurvePoint] -> ShowS
showList :: [ECurvePoint] -> ShowS
Show, Typeable)

instance A.ToJSON ECurvePoint where
    toJSON :: ECurvePoint -> Value
toJSON (ECurvePoint (ECCT.Point Integer
x Integer
y)) = (Integer, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Integer
x, Integer
y)
    toJSON (ECurvePoint PublicPoint
ECCT.PointO) = String -> Value
forall a. ToJSON a => a -> Value
A.toJSON String
"point at infinity"

instance A.FromJSON ECurvePoint where
    parseJSON :: Value -> Parser ECurvePoint
parseJSON Value
v =
        case Value -> Result (Integer, Integer)
forall a. FromJSON a => Value -> Result a
A.fromJSON Value
v :: A.Result (Integer, Integer) of
            A.Success (Integer
x, Integer
y) -> ECurvePoint -> Parser ECurvePoint
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PublicPoint -> ECurvePoint
ECurvePoint (Integer -> Integer -> PublicPoint
ECCT.Point Integer
x Integer
y))
            A.Error String
_ ->
                case Value -> Result String
forall a. FromJSON a => Value -> Result a
A.fromJSON Value
v :: A.Result String of
                    A.Success String
"point at infinity" -> ECurvePoint -> Parser ECurvePoint
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PublicPoint -> ECurvePoint
ECurvePoint PublicPoint
ECCT.PointO)
                    Result String
_ -> Parser ECurvePoint
forall a. Parser a
forall (m :: * -> *) a. MonadPlus m => m a
mzero