    -- |
    -- Module      : Crypto.ECC
    -- License     : BSD-style
    -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
    -- Stability   : experimental
    -- Portability : unknown
    --
    -- Elliptic Curve Cryptography
    --
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE TypeFamilies #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    module Crypto.ECC
        ( Curve_P256R1(..)
        , Curve_P384R1(..)
        , Curve_P521R1(..)
        , Curve_X25519(..)
        , Curve_X448(..)
        , Curve_Edwards25519(..)
        , EllipticCurve(..)
        , EllipticCurveDH(..)
        , EllipticCurveArith(..)
        , KeyPair(..)
        , SharedSecret(..)
        ) where

    import qualified Crypto.PubKey.ECC.P256 as P256
    import qualified Crypto.ECC.Edwards25519 as Edwards25519
    import qualified Crypto.ECC.Simple.Types as Simple
    import qualified Crypto.ECC.Simple.Prim as Simple
    import           Crypto.Random
    import           Crypto.Error
    import           Crypto.Internal.Imports
    import           Crypto.Internal.ByteArray (ByteArray, ByteArrayAccess, ScrubbedBytes)
    import qualified Crypto.Internal.ByteArray as B
    import           Crypto.Number.Serialize (i2ospOf_, os2ip)
    import qualified Crypto.PubKey.Curve25519 as X25519
    import qualified Crypto.PubKey.Curve448 as X448
    import           Data.ByteArray (convert)
    import           Data.Data (Data())
    import           Data.Kind (Type)
    import           Data.Proxy

    -- | An elliptic curve key pair composed of the private part (a scalar), and
    -- the associated point.
    data KeyPair curve = KeyPair
        { KeyPair curve -> Point curve
    keypairGetPublic  :: !(Point curve)
        , KeyPair curve -> Scalar curve
    keypairGetPrivate :: !(Scalar curve)
        }

    newtype SharedSecret = SharedSecret ScrubbedBytes
        deriving (SharedSecret -> SharedSecret -> Bool
    (SharedSecret -> SharedSecret -> Bool)
    -> (SharedSecret -> SharedSecret -> Bool) -> Eq SharedSecret
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SharedSecret -> SharedSecret -> Bool
    $c/= :: SharedSecret -> SharedSecret -> Bool
    == :: SharedSecret -> SharedSecret -> Bool
    $c== :: SharedSecret -> SharedSecret -> Bool
    Eq, SharedSecret -> Int
    SharedSecret -> Ptr p -> IO ()
    SharedSecret -> (Ptr p -> IO a) -> IO a
    (SharedSecret -> Int)
    -> (forall p a. SharedSecret -> (Ptr p -> IO a) -> IO a)
    -> (forall p. SharedSecret -> Ptr p -> IO ())
    -> ByteArrayAccess SharedSecret
    forall p. SharedSecret -> Ptr p -> IO ()
    forall ba.
    (ba -> Int)
    -> (forall p a. ba -> (Ptr p -> IO a) -> IO a)
    -> (forall p. ba -> Ptr p -> IO ())
    -> ByteArrayAccess ba
    forall p a. SharedSecret -> (Ptr p -> IO a) -> IO a
    copyByteArrayToPtr :: SharedSecret -> Ptr p -> IO ()
    $ccopyByteArrayToPtr :: forall p. SharedSecret -> Ptr p -> IO ()
    withByteArray :: SharedSecret -> (Ptr p -> IO a) -> IO a
    $cwithByteArray :: forall p a. SharedSecret -> (Ptr p -> IO a) -> IO a
    length :: SharedSecret -> Int
    $clength :: SharedSecret -> Int
    ByteArrayAccess, SharedSecret -> ()
    (SharedSecret -> ()) -> NFData SharedSecret
    forall a. (a -> ()) -> NFData a
    rnf :: SharedSecret -> ()
    $crnf :: SharedSecret -> ()
    NFData)

    class EllipticCurve curve where
        -- | Point on an Elliptic Curve
        type Point curve  :: Type

        -- | Scalar in the Elliptic Curve domain
        type Scalar curve :: Type

        -- | Generate a new random scalar on the curve.
        -- The scalar will represent a number between 1 and the order of the curve non included
        curveGenerateScalar :: MonadRandom randomly => proxy curve -> randomly (Scalar curve)

        -- | Generate a new random keypair
        curveGenerateKeyPair :: MonadRandom randomly => proxy curve -> randomly (KeyPair curve)

        -- | Get the curve size in bits
        curveSizeBits :: proxy curve -> Int

        -- | Encode a elliptic curve point into binary form
        encodePoint :: ByteArray bs => proxy curve -> Point curve -> bs

        -- | Try to decode the binary form of an elliptic curve point
        decodePoint :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Point curve)

    class EllipticCurve curve => EllipticCurveDH curve where
        -- | Generate a Diffie hellman secret value.
        --
        -- This is generally just the .x coordinate of the resulting point, that
        -- is not hashed.
        --
        -- use `pointSmul` to keep the result in Point format.
        --
        -- /WARNING:/ Curve implementations may return a special value or an
        -- exception when the public point lies in a subgroup of small order.
        -- This function is adequate when the scalar is in expected range and
        -- contributory behaviour is not needed.  Otherwise use 'ecdh'.
        ecdhRaw :: proxy curve -> Scalar curve -> Point curve -> SharedSecret
        ecdhRaw prx :: proxy curve
    prx s :: Scalar curve
    s = CryptoFailable SharedSecret -> SharedSecret
    forall a. CryptoFailable a -> a
    throwCryptoError (CryptoFailable SharedSecret -> SharedSecret)
    -> (Point curve -> CryptoFailable SharedSecret)
    -> Point curve
    -> SharedSecret
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . proxy curve
    -> Scalar curve -> Point curve -> CryptoFailable SharedSecret
    forall curve (proxy :: * -> *).
    EllipticCurveDH curve =>
    proxy curve
    -> Scalar curve -> Point curve -> CryptoFailable SharedSecret
    ecdh proxy curve
    prx Scalar curve
    s

        -- | Generate a Diffie hellman secret value and verify that the result
        -- is not the point at infinity.
        --
        -- This additional test avoids risks existing with function 'ecdhRaw'.
        -- Implementations always return a 'CryptoError' instead of a special
        -- value or an exception.
        ecdh :: proxy curve -> Scalar curve -> Point curve -> CryptoFailable SharedSecret

    class EllipticCurve curve => EllipticCurveArith curve where
        -- | Add points on a curve
        pointAdd :: proxy curve -> Point curve -> Point curve -> Point curve

        -- | Negate a curve point
        pointNegate :: proxy curve -> Point curve -> Point curve

        -- | Scalar Multiplication on a curve
        pointSmul :: proxy curve -> Scalar curve -> Point curve -> Point curve

    --   -- | Scalar Inverse
    --   scalarInverse :: Scalar curve -> Scalar curve

    -- | P256 Curve
    --
    -- also known as P256
    data Curve_P256R1 = Curve_P256R1
        deriving (Int -> Curve_P256R1 -> ShowS
    [Curve_P256R1] -> ShowS
    Curve_P256R1 -> String
    (Int -> Curve_P256R1 -> ShowS)
    -> (Curve_P256R1 -> String)
    -> ([Curve_P256R1] -> ShowS)
    -> Show Curve_P256R1
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_P256R1] -> ShowS
    $cshowList :: [Curve_P256R1] -> ShowS
    show :: Curve_P256R1 -> String
    $cshow :: Curve_P256R1 -> String
    showsPrec :: Int -> Curve_P256R1 -> ShowS
    $cshowsPrec :: Int -> Curve_P256R1 -> ShowS
    Show,Typeable Curve_P256R1
    DataType
    Constr
    Typeable Curve_P256R1 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_P256R1)
    -> (Curve_P256R1 -> Constr)
    -> (Curve_P256R1 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_P256R1))
    -> ((forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Curve_P256R1 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1)
    -> Data Curve_P256R1
    Curve_P256R1 -> DataType
    Curve_P256R1 -> Constr
    (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P256R1
    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) -> Curve_P256R1 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_P256R1 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P256R1
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P256R1)
    $cCurve_P256R1 :: Constr
    $tCurve_P256R1 :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    gmapMp :: (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    gmapM :: (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_P256R1 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P256R1 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    gmapT :: (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P256R1)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P256R1)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1)
    dataTypeOf :: Curve_P256R1 -> DataType
    $cdataTypeOf :: Curve_P256R1 -> DataType
    toConstr :: Curve_P256R1 -> Constr
    $ctoConstr :: Curve_P256R1 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P256R1
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P256R1
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1
    $cp1Data :: Typeable Curve_P256R1
    Data)

    instance EllipticCurve Curve_P256R1 where
        type Point Curve_P256R1 = P256.Point
        type Scalar Curve_P256R1 = P256.Scalar
        curveSizeBits :: proxy Curve_P256R1 -> Int
    curveSizeBits _ = 256
        curveGenerateScalar :: proxy Curve_P256R1 -> randomly (Scalar Curve_P256R1)
    curveGenerateScalar _ = randomly (Scalar Curve_P256R1)
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    P256.scalarGenerate
        curveGenerateKeyPair :: proxy Curve_P256R1 -> randomly (KeyPair Curve_P256R1)
    curveGenerateKeyPair _ = Scalar -> KeyPair Curve_P256R1
    forall curve.
    (Point curve ~ Point, Scalar curve ~ Scalar) =>
    Scalar -> KeyPair curve
    toKeyPair (Scalar -> KeyPair Curve_P256R1)
    -> randomly Scalar -> randomly (KeyPair Curve_P256R1)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> randomly Scalar
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    P256.scalarGenerate
          where toKeyPair :: Scalar -> KeyPair curve
    toKeyPair scalar :: Scalar
    scalar = Point curve -> Scalar curve -> KeyPair curve
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (Scalar -> Point
    P256.toPoint Scalar
    scalar) Scalar
    Scalar curve
    scalar
        encodePoint :: proxy Curve_P256R1 -> Point Curve_P256R1 -> bs
    encodePoint _ p :: Point Curve_P256R1
    p = bs
    forall bs. ByteArray bs => bs
    mxy
          where
            mxy :: forall bs. ByteArray bs => bs
            mxy :: bs
    mxy = [bs] -> bs
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    [bin] -> bout
    B.concat [bs
    uncompressed, bs
    xy]
              where
                uncompressed, xy :: bs
                uncompressed :: bs
    uncompressed = Word8 -> bs
    forall a. ByteArray a => Word8 -> a
    B.singleton 4
                xy :: bs
    xy = Point -> bs
    forall ba. ByteArray ba => Point -> ba
    P256.pointToBinary Point
    Point Curve_P256R1
    p
        decodePoint :: proxy Curve_P256R1 -> bs -> CryptoFailable (Point Curve_P256R1)
    decodePoint _ mxy :: bs
    mxy = case bs -> Maybe (Word8, bs)
    forall a. ByteArray a => a -> Maybe (Word8, a)
    B.uncons bs
    mxy of
            Nothing -> CryptoError -> CryptoFailable (Point Curve_P256R1)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed (CryptoError -> CryptoFailable (Point Curve_P256R1))
    -> CryptoError -> CryptoFailable (Point Curve_P256R1)
    forall a b. (a -> b) -> a -> b
    $ CryptoError
    CryptoError_PointSizeInvalid
            Just (m :: Word8
    m,xy :: bs
    xy)
                -- uncompressed
                | Word8
    m Word8 -> Word8 -> Bool
    forall a. Eq a => a -> a -> Bool
    == 4 -> bs -> CryptoFailable Point
    forall ba. ByteArrayAccess ba => ba -> CryptoFailable Point
    P256.pointFromBinary bs
    xy
                | Bool
    otherwise -> CryptoError -> CryptoFailable (Point Curve_P256R1)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed (CryptoError -> CryptoFailable (Point Curve_P256R1))
    -> CryptoError -> CryptoFailable (Point Curve_P256R1)
    forall a b. (a -> b) -> a -> b
    $ CryptoError
    CryptoError_PointFormatInvalid

    instance EllipticCurveArith Curve_P256R1 where
        pointAdd :: proxy Curve_P256R1
    -> Point Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointAdd  _ a :: Point Curve_P256R1
    a b :: Point Curve_P256R1
    b = Point -> Point -> Point
    P256.pointAdd Point
    Point Curve_P256R1
    a Point
    Point Curve_P256R1
    b
        pointNegate :: proxy Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointNegate _ p :: Point Curve_P256R1
    p = Point -> Point
    P256.pointNegate Point
    Point Curve_P256R1
    p
        pointSmul :: proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointSmul _ s :: Scalar Curve_P256R1
    s p :: Point Curve_P256R1
    p = Scalar -> Point -> Point
    P256.pointMul Scalar
    Scalar Curve_P256R1
    s Point
    Point Curve_P256R1
    p

    instance EllipticCurveDH Curve_P256R1 where
        ecdhRaw :: proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> SharedSecret
    ecdhRaw _ s :: Scalar Curve_P256R1
    s p :: Point Curve_P256R1
    p = ScrubbedBytes -> SharedSecret
    SharedSecret (ScrubbedBytes -> SharedSecret) -> ScrubbedBytes -> SharedSecret
    forall a b. (a -> b) -> a -> b
    $ Scalar -> Point -> ScrubbedBytes
    forall binary. ByteArray binary => Scalar -> Point -> binary
    P256.pointDh Scalar
    Scalar Curve_P256R1
    s Point
    Point Curve_P256R1
    p
        ecdh :: proxy Curve_P256R1
    -> Scalar Curve_P256R1
    -> Point Curve_P256R1
    -> CryptoFailable SharedSecret
    ecdh  prx :: proxy Curve_P256R1
    prx s :: Scalar Curve_P256R1
    s p :: Point Curve_P256R1
    p = SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH (proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> SharedSecret
    forall curve (proxy :: * -> *).
    EllipticCurveDH curve =>
    proxy curve -> Scalar curve -> Point curve -> SharedSecret
    ecdhRaw proxy Curve_P256R1
    prx Scalar Curve_P256R1
    s Point Curve_P256R1
    p)

    data Curve_P384R1 = Curve_P384R1
        deriving (Int -> Curve_P384R1 -> ShowS
    [Curve_P384R1] -> ShowS
    Curve_P384R1 -> String
    (Int -> Curve_P384R1 -> ShowS)
    -> (Curve_P384R1 -> String)
    -> ([Curve_P384R1] -> ShowS)
    -> Show Curve_P384R1
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_P384R1] -> ShowS
    $cshowList :: [Curve_P384R1] -> ShowS
    show :: Curve_P384R1 -> String
    $cshow :: Curve_P384R1 -> String
    showsPrec :: Int -> Curve_P384R1 -> ShowS
    $cshowsPrec :: Int -> Curve_P384R1 -> ShowS
    Show,Typeable Curve_P384R1
    DataType
    Constr
    Typeable Curve_P384R1 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_P384R1)
    -> (Curve_P384R1 -> Constr)
    -> (Curve_P384R1 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_P384R1))
    -> ((forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Curve_P384R1 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1)
    -> Data Curve_P384R1
    Curve_P384R1 -> DataType
    Curve_P384R1 -> Constr
    (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P384R1
    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) -> Curve_P384R1 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_P384R1 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P384R1
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P384R1)
    $cCurve_P384R1 :: Constr
    $tCurve_P384R1 :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    gmapMp :: (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    gmapM :: (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_P384R1 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P384R1 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    gmapT :: (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P384R1)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P384R1)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1)
    dataTypeOf :: Curve_P384R1 -> DataType
    $cdataTypeOf :: Curve_P384R1 -> DataType
    toConstr :: Curve_P384R1 -> Constr
    $ctoConstr :: Curve_P384R1 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P384R1
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P384R1
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1
    $cp1Data :: Typeable Curve_P384R1
    Data)

    instance EllipticCurve Curve_P384R1 where
        type Point Curve_P384R1 = Simple.Point Simple.SEC_p384r1
        type Scalar Curve_P384R1 = Simple.Scalar Simple.SEC_p384r1
        curveSizeBits :: proxy Curve_P384R1 -> Int
    curveSizeBits _ = 384
        curveGenerateScalar :: proxy Curve_P384R1 -> randomly (Scalar Curve_P384R1)
    curveGenerateScalar _ = randomly (Scalar Curve_P384R1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
        curveGenerateKeyPair :: proxy Curve_P384R1 -> randomly (KeyPair Curve_P384R1)
    curveGenerateKeyPair _ = Scalar SEC_p384r1 -> KeyPair Curve_P384R1
    forall curve curve.
    (Curve curve, Point curve ~ Point curve,
     Scalar curve ~ Scalar curve) =>
    Scalar curve -> KeyPair curve
    toKeyPair (Scalar SEC_p384r1 -> KeyPair Curve_P384R1)
    -> randomly (Scalar SEC_p384r1) -> randomly (KeyPair Curve_P384R1)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> randomly (Scalar SEC_p384r1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
          where toKeyPair :: Scalar curve -> KeyPair curve
    toKeyPair scalar :: Scalar curve
    scalar = Point curve -> Scalar curve -> KeyPair curve
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (Scalar curve -> Point curve
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul Scalar curve
    scalar) Scalar curve
    Scalar curve
    scalar
        encodePoint :: proxy Curve_P384R1 -> Point Curve_P384R1 -> bs
    encodePoint _ point :: Point Curve_P384R1
    point = Point SEC_p384r1 -> bs
    forall curve bs. (Curve curve, ByteArray bs) => Point curve -> bs
    encodeECPoint Point SEC_p384r1
    Point Curve_P384R1
    point
        decodePoint :: proxy Curve_P384R1 -> bs -> CryptoFailable (Point Curve_P384R1)
    decodePoint _ bs :: bs
    bs = bs -> CryptoFailable (Point SEC_p384r1)
    forall curve bs.
    (Curve curve, ByteArray bs) =>
    bs -> CryptoFailable (Point curve)
    decodeECPoint bs
    bs

    instance EllipticCurveArith Curve_P384R1 where
        pointAdd :: proxy Curve_P384R1
    -> Point Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointAdd _ a :: Point Curve_P384R1
    a b :: Point Curve_P384R1
    b = Point SEC_p384r1 -> Point SEC_p384r1 -> Point SEC_p384r1
    forall curve.
    Curve curve =>
    Point curve -> Point curve -> Point curve
    Simple.pointAdd Point SEC_p384r1
    Point Curve_P384R1
    a Point SEC_p384r1
    Point Curve_P384R1
    b
        pointNegate :: proxy Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointNegate _ p :: Point Curve_P384R1
    p = Point SEC_p384r1 -> Point SEC_p384r1
    forall curve. Curve curve => Point curve -> Point curve
    Simple.pointNegate Point SEC_p384r1
    Point Curve_P384R1
    p
        pointSmul :: proxy Curve_P384R1
    -> Scalar Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointSmul _ s :: Scalar Curve_P384R1
    s p :: Point Curve_P384R1
    p = Scalar SEC_p384r1 -> Point SEC_p384r1 -> Point SEC_p384r1
    forall curve.
    Curve curve =>
    Scalar curve -> Point curve -> Point curve
    Simple.pointMul Scalar SEC_p384r1
    Scalar Curve_P384R1
    s Point SEC_p384r1
    Point Curve_P384R1
    p

    instance EllipticCurveDH Curve_P384R1 where
        ecdh :: proxy Curve_P384R1
    -> Scalar Curve_P384R1
    -> Point Curve_P384R1
    -> CryptoFailable SharedSecret
    ecdh _ s :: Scalar Curve_P384R1
    s p :: Point Curve_P384R1
    p = Proxy SEC_p384r1 -> Point SEC_p384r1 -> CryptoFailable SharedSecret
    forall curve.
    Curve curve =>
    Proxy curve -> Point curve -> CryptoFailable SharedSecret
    encodeECShared Proxy SEC_p384r1
    prx (Scalar SEC_p384r1 -> Point SEC_p384r1 -> Point SEC_p384r1
    forall curve.
    Curve curve =>
    Scalar curve -> Point curve -> Point curve
    Simple.pointMul Scalar SEC_p384r1
    Scalar Curve_P384R1
    s Point SEC_p384r1
    Point Curve_P384R1
    p)
          where
            prx :: Proxy SEC_p384r1
    prx = Proxy SEC_p384r1
    forall k (t :: k). Proxy t
    Proxy :: Proxy Simple.SEC_p384r1

    data Curve_P521R1 = Curve_P521R1
        deriving (Int -> Curve_P521R1 -> ShowS
    [Curve_P521R1] -> ShowS
    Curve_P521R1 -> String
    (Int -> Curve_P521R1 -> ShowS)
    -> (Curve_P521R1 -> String)
    -> ([Curve_P521R1] -> ShowS)
    -> Show Curve_P521R1
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_P521R1] -> ShowS
    $cshowList :: [Curve_P521R1] -> ShowS
    show :: Curve_P521R1 -> String
    $cshow :: Curve_P521R1 -> String
    showsPrec :: Int -> Curve_P521R1 -> ShowS
    $cshowsPrec :: Int -> Curve_P521R1 -> ShowS
    Show,Typeable Curve_P521R1
    DataType
    Constr
    Typeable Curve_P521R1 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_P521R1)
    -> (Curve_P521R1 -> Constr)
    -> (Curve_P521R1 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_P521R1))
    -> ((forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Curve_P521R1 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1)
    -> Data Curve_P521R1
    Curve_P521R1 -> DataType
    Curve_P521R1 -> Constr
    (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P521R1
    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) -> Curve_P521R1 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_P521R1 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P521R1
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P521R1)
    $cCurve_P521R1 :: Constr
    $tCurve_P521R1 :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    gmapMp :: (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    gmapM :: (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_P521R1 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P521R1 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    gmapT :: (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P521R1)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P521R1)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1)
    dataTypeOf :: Curve_P521R1 -> DataType
    $cdataTypeOf :: Curve_P521R1 -> DataType
    toConstr :: Curve_P521R1 -> Constr
    $ctoConstr :: Curve_P521R1 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P521R1
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P521R1
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1
    $cp1Data :: Typeable Curve_P521R1
    Data)

    instance EllipticCurve Curve_P521R1 where
        type Point Curve_P521R1 = Simple.Point Simple.SEC_p521r1
        type Scalar Curve_P521R1 = Simple.Scalar Simple.SEC_p521r1
        curveSizeBits :: proxy Curve_P521R1 -> Int
    curveSizeBits _ = 521
        curveGenerateScalar :: proxy Curve_P521R1 -> randomly (Scalar Curve_P521R1)
    curveGenerateScalar _ = randomly (Scalar Curve_P521R1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
        curveGenerateKeyPair :: proxy Curve_P521R1 -> randomly (KeyPair Curve_P521R1)
    curveGenerateKeyPair _ = Scalar SEC_p521r1 -> KeyPair Curve_P521R1
    forall curve curve.
    (Curve curve, Point curve ~ Point curve,
     Scalar curve ~ Scalar curve) =>
    Scalar curve -> KeyPair curve
    toKeyPair (Scalar SEC_p521r1 -> KeyPair Curve_P521R1)
    -> randomly (Scalar SEC_p521r1) -> randomly (KeyPair Curve_P521R1)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> randomly (Scalar SEC_p521r1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
          where toKeyPair :: Scalar curve -> KeyPair curve
    toKeyPair scalar :: Scalar curve
    scalar = Point curve -> Scalar curve -> KeyPair curve
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (Scalar curve -> Point curve
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul Scalar curve
    scalar) Scalar curve
    Scalar curve
    scalar
        encodePoint :: proxy Curve_P521R1 -> Point Curve_P521R1 -> bs
    encodePoint _ point :: Point Curve_P521R1
    point = Point SEC_p521r1 -> bs
    forall curve bs. (Curve curve, ByteArray bs) => Point curve -> bs
    encodeECPoint Point SEC_p521r1
    Point Curve_P521R1
    point
        decodePoint :: proxy Curve_P521R1 -> bs -> CryptoFailable (Point Curve_P521R1)
    decodePoint _ bs :: bs
    bs = bs -> CryptoFailable (Point SEC_p521r1)
    forall curve bs.
    (Curve curve, ByteArray bs) =>
    bs -> CryptoFailable (Point curve)
    decodeECPoint bs
    bs

    instance EllipticCurveArith Curve_P521R1 where
        pointAdd :: proxy Curve_P521R1
    -> Point Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointAdd _ a :: Point Curve_P521R1
    a b :: Point Curve_P521R1
    b = Point SEC_p521r1 -> Point SEC_p521r1 -> Point SEC_p521r1
    forall curve.
    Curve curve =>
    Point curve -> Point curve -> Point curve
    Simple.pointAdd Point SEC_p521r1
    Point Curve_P521R1
    a Point SEC_p521r1
    Point Curve_P521R1
    b
        pointNegate :: proxy Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointNegate _ p :: Point Curve_P521R1
    p = Point SEC_p521r1 -> Point SEC_p521r1
    forall curve. Curve curve => Point curve -> Point curve
    Simple.pointNegate Point SEC_p521r1
    Point Curve_P521R1
    p
        pointSmul :: proxy Curve_P521R1
    -> Scalar Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointSmul _ s :: Scalar Curve_P521R1
    s p :: Point Curve_P521R1
    p = Scalar SEC_p521r1 -> Point SEC_p521r1 -> Point SEC_p521r1
    forall curve.
    Curve curve =>
    Scalar curve -> Point curve -> Point curve
    Simple.pointMul Scalar SEC_p521r1
    Scalar Curve_P521R1
    s Point SEC_p521r1
    Point Curve_P521R1
    p

    instance EllipticCurveDH Curve_P521R1 where
        ecdh :: proxy Curve_P521R1
    -> Scalar Curve_P521R1
    -> Point Curve_P521R1
    -> CryptoFailable SharedSecret
    ecdh _ s :: Scalar Curve_P521R1
    s p :: Point Curve_P521R1
    p = Proxy SEC_p521r1 -> Point SEC_p521r1 -> CryptoFailable SharedSecret
    forall curve.
    Curve curve =>
    Proxy curve -> Point curve -> CryptoFailable SharedSecret
    encodeECShared Proxy SEC_p521r1
    prx (Scalar SEC_p521r1 -> Point SEC_p521r1 -> Point SEC_p521r1
    forall curve.
    Curve curve =>
    Scalar curve -> Point curve -> Point curve
    Simple.pointMul Scalar SEC_p521r1
    Scalar Curve_P521R1
    s Point SEC_p521r1
    Point Curve_P521R1
    p)
          where
            prx :: Proxy SEC_p521r1
    prx = Proxy SEC_p521r1
    forall k (t :: k). Proxy t
    Proxy :: Proxy Simple.SEC_p521r1

    data Curve_X25519 = Curve_X25519
        deriving (Int -> Curve_X25519 -> ShowS
    [Curve_X25519] -> ShowS
    Curve_X25519 -> String
    (Int -> Curve_X25519 -> ShowS)
    -> (Curve_X25519 -> String)
    -> ([Curve_X25519] -> ShowS)
    -> Show Curve_X25519
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_X25519] -> ShowS
    $cshowList :: [Curve_X25519] -> ShowS
    show :: Curve_X25519 -> String
    $cshow :: Curve_X25519 -> String
    showsPrec :: Int -> Curve_X25519 -> ShowS
    $cshowsPrec :: Int -> Curve_X25519 -> ShowS
    Show,Typeable Curve_X25519
    DataType
    Constr
    Typeable Curve_X25519 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_X25519)
    -> (Curve_X25519 -> Constr)
    -> (Curve_X25519 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_X25519))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_X25519))
    -> ((forall b. Data b => b -> b) -> Curve_X25519 -> Curve_X25519)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Curve_X25519 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_X25519 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519)
    -> Data Curve_X25519
    Curve_X25519 -> DataType
    Curve_X25519 -> Constr
    (forall b. Data b => b -> b) -> Curve_X25519 -> Curve_X25519
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X25519
    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) -> Curve_X25519 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_X25519 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X25519
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_X25519)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_X25519)
    $cCurve_X25519 :: Constr
    $tCurve_X25519 :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    gmapMp :: (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    gmapM :: (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_X25519 -> m Curve_X25519
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_X25519 -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_X25519 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_X25519 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_X25519 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X25519 -> r
    gmapT :: (forall b. Data b => b -> b) -> Curve_X25519 -> Curve_X25519
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_X25519 -> Curve_X25519
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_X25519)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_X25519)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_X25519)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_X25519)
    dataTypeOf :: Curve_X25519 -> DataType
    $cdataTypeOf :: Curve_X25519 -> DataType
    toConstr :: Curve_X25519 -> Constr
    $ctoConstr :: Curve_X25519 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X25519
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X25519
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X25519 -> c Curve_X25519
    $cp1Data :: Typeable Curve_X25519
    Data)

    instance EllipticCurve Curve_X25519 where
        type Point Curve_X25519 = X25519.PublicKey
        type Scalar Curve_X25519 = X25519.SecretKey
        curveSizeBits :: proxy Curve_X25519 -> Int
    curveSizeBits _ = 255
        curveGenerateScalar :: proxy Curve_X25519 -> randomly (Scalar Curve_X25519)
    curveGenerateScalar _ = randomly (Scalar Curve_X25519)
    forall (m :: * -> *). MonadRandom m => m SecretKey
    X25519.generateSecretKey
        curveGenerateKeyPair :: proxy Curve_X25519 -> randomly (KeyPair Curve_X25519)
    curveGenerateKeyPair _ = do
            SecretKey
    s <- randomly SecretKey
    forall (m :: * -> *). MonadRandom m => m SecretKey
    X25519.generateSecretKey
            KeyPair Curve_X25519 -> randomly (KeyPair Curve_X25519)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (KeyPair Curve_X25519 -> randomly (KeyPair Curve_X25519))
    -> KeyPair Curve_X25519 -> randomly (KeyPair Curve_X25519)
    forall a b. (a -> b) -> a -> b
    $ Point Curve_X25519 -> Scalar Curve_X25519 -> KeyPair Curve_X25519
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (SecretKey -> PublicKey
    X25519.toPublic SecretKey
    s) SecretKey
    Scalar Curve_X25519
    s
        encodePoint :: proxy Curve_X25519 -> Point Curve_X25519 -> bs
    encodePoint _ p :: Point Curve_X25519
    p = PublicKey -> bs
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    bin -> bout
    B.convert PublicKey
    Point Curve_X25519
    p
        decodePoint :: proxy Curve_X25519 -> bs -> CryptoFailable (Point Curve_X25519)
    decodePoint _ bs :: bs
    bs = bs -> CryptoFailable PublicKey
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable PublicKey
    X25519.publicKey bs
    bs

    instance EllipticCurveDH Curve_X25519 where
        ecdhRaw :: proxy Curve_X25519
    -> Scalar Curve_X25519 -> Point Curve_X25519 -> SharedSecret
    ecdhRaw _ s :: Scalar Curve_X25519
    s p :: Point Curve_X25519
    p = ScrubbedBytes -> SharedSecret
    SharedSecret (ScrubbedBytes -> SharedSecret) -> ScrubbedBytes -> SharedSecret
    forall a b. (a -> b) -> a -> b
    $ DhSecret -> ScrubbedBytes
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    bin -> bout
    convert DhSecret
    secret
          where secret :: DhSecret
    secret = PublicKey -> SecretKey -> DhSecret
    X25519.dh PublicKey
    Point Curve_X25519
    p SecretKey
    Scalar Curve_X25519
    s
        ecdh :: proxy Curve_X25519
    -> Scalar Curve_X25519
    -> Point Curve_X25519
    -> CryptoFailable SharedSecret
    ecdh prx :: proxy Curve_X25519
    prx s :: Scalar Curve_X25519
    s p :: Point Curve_X25519
    p = SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH (proxy Curve_X25519
    -> Scalar Curve_X25519 -> Point Curve_X25519 -> SharedSecret
    forall curve (proxy :: * -> *).
    EllipticCurveDH curve =>
    proxy curve -> Scalar curve -> Point curve -> SharedSecret
    ecdhRaw proxy Curve_X25519
    prx Scalar Curve_X25519
    s Point Curve_X25519
    p)

    data Curve_X448 = Curve_X448
        deriving (Int -> Curve_X448 -> ShowS
    [Curve_X448] -> ShowS
    Curve_X448 -> String
    (Int -> Curve_X448 -> ShowS)
    -> (Curve_X448 -> String)
    -> ([Curve_X448] -> ShowS)
    -> Show Curve_X448
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_X448] -> ShowS
    $cshowList :: [Curve_X448] -> ShowS
    show :: Curve_X448 -> String
    $cshow :: Curve_X448 -> String
    showsPrec :: Int -> Curve_X448 -> ShowS
    $cshowsPrec :: Int -> Curve_X448 -> ShowS
    Show,Typeable Curve_X448
    DataType
    Constr
    Typeable Curve_X448 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_X448)
    -> (Curve_X448 -> Constr)
    -> (Curve_X448 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_X448))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_X448))
    -> ((forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Curve_X448 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448)
    -> Data Curve_X448
    Curve_X448 -> DataType
    Curve_X448 -> Constr
    (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X448
    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) -> Curve_X448 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_X448 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X448
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_X448)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X448)
    $cCurve_X448 :: Constr
    $tCurve_X448 :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    gmapMp :: (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    gmapM :: (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_X448 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_X448 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    gmapT :: (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X448)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X448)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_X448)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_X448)
    dataTypeOf :: Curve_X448 -> DataType
    $cdataTypeOf :: Curve_X448 -> DataType
    toConstr :: Curve_X448 -> Constr
    $ctoConstr :: Curve_X448 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X448
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X448
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448
    $cp1Data :: Typeable Curve_X448
    Data)

    instance EllipticCurve Curve_X448 where
        type Point Curve_X448 = X448.PublicKey
        type Scalar Curve_X448 = X448.SecretKey
        curveSizeBits :: proxy Curve_X448 -> Int
    curveSizeBits _ = 448
        curveGenerateScalar :: proxy Curve_X448 -> randomly (Scalar Curve_X448)
    curveGenerateScalar _ = randomly (Scalar Curve_X448)
    forall (m :: * -> *). MonadRandom m => m SecretKey
    X448.generateSecretKey
        curveGenerateKeyPair :: proxy Curve_X448 -> randomly (KeyPair Curve_X448)
    curveGenerateKeyPair _ = do
            SecretKey
    s <- randomly SecretKey
    forall (m :: * -> *). MonadRandom m => m SecretKey
    X448.generateSecretKey
            KeyPair Curve_X448 -> randomly (KeyPair Curve_X448)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (KeyPair Curve_X448 -> randomly (KeyPair Curve_X448))
    -> KeyPair Curve_X448 -> randomly (KeyPair Curve_X448)
    forall a b. (a -> b) -> a -> b
    $ Point Curve_X448 -> Scalar Curve_X448 -> KeyPair Curve_X448
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (SecretKey -> PublicKey
    X448.toPublic SecretKey
    s) SecretKey
    Scalar Curve_X448
    s
        encodePoint :: proxy Curve_X448 -> Point Curve_X448 -> bs
    encodePoint _ p :: Point Curve_X448
    p = PublicKey -> bs
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    bin -> bout
    B.convert PublicKey
    Point Curve_X448
    p
        decodePoint :: proxy Curve_X448 -> bs -> CryptoFailable (Point Curve_X448)
    decodePoint _ bs :: bs
    bs = bs -> CryptoFailable PublicKey
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable PublicKey
    X448.publicKey bs
    bs

    instance EllipticCurveDH Curve_X448 where
        ecdhRaw :: proxy Curve_X448
    -> Scalar Curve_X448 -> Point Curve_X448 -> SharedSecret
    ecdhRaw _ s :: Scalar Curve_X448
    s p :: Point Curve_X448
    p = ScrubbedBytes -> SharedSecret
    SharedSecret (ScrubbedBytes -> SharedSecret) -> ScrubbedBytes -> SharedSecret
    forall a b. (a -> b) -> a -> b
    $ DhSecret -> ScrubbedBytes
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    bin -> bout
    convert DhSecret
    secret
          where secret :: DhSecret
    secret = PublicKey -> SecretKey -> DhSecret
    X448.dh PublicKey
    Point Curve_X448
    p SecretKey
    Scalar Curve_X448
    s
        ecdh :: proxy Curve_X448
    -> Scalar Curve_X448
    -> Point Curve_X448
    -> CryptoFailable SharedSecret
    ecdh prx :: proxy Curve_X448
    prx s :: Scalar Curve_X448
    s p :: Point Curve_X448
    p = SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH (proxy Curve_X448
    -> Scalar Curve_X448 -> Point Curve_X448 -> SharedSecret
    forall curve (proxy :: * -> *).
    EllipticCurveDH curve =>
    proxy curve -> Scalar curve -> Point curve -> SharedSecret
    ecdhRaw proxy Curve_X448
    prx Scalar Curve_X448
    s Point Curve_X448
    p)

    data Curve_Edwards25519 = Curve_Edwards25519
        deriving (Int -> Curve_Edwards25519 -> ShowS
    [Curve_Edwards25519] -> ShowS
    Curve_Edwards25519 -> String
    (Int -> Curve_Edwards25519 -> ShowS)
    -> (Curve_Edwards25519 -> String)
    -> ([Curve_Edwards25519] -> ShowS)
    -> Show Curve_Edwards25519
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Curve_Edwards25519] -> ShowS
    $cshowList :: [Curve_Edwards25519] -> ShowS
    show :: Curve_Edwards25519 -> String
    $cshow :: Curve_Edwards25519 -> String
    showsPrec :: Int -> Curve_Edwards25519 -> ShowS
    $cshowsPrec :: Int -> Curve_Edwards25519 -> ShowS
    Show,Typeable Curve_Edwards25519
    DataType
    Constr
    Typeable Curve_Edwards25519 =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g)
     -> Curve_Edwards25519
     -> c Curve_Edwards25519)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519)
    -> (Curve_Edwards25519 -> Constr)
    -> (Curve_Edwards25519 -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Curve_Edwards25519))
    -> ((forall b. Data b => b -> b)
        -> Curve_Edwards25519 -> Curve_Edwards25519)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> Curve_Edwards25519 -> m Curve_Edwards25519)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> Curve_Edwards25519 -> m Curve_Edwards25519)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> Curve_Edwards25519 -> m Curve_Edwards25519)
    -> Data Curve_Edwards25519
    Curve_Edwards25519 -> DataType
    Curve_Edwards25519 -> Constr
    (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> Curve_Edwards25519
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> c Curve_Edwards25519
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519
    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) -> Curve_Edwards25519 -> u
    forall u. (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> c Curve_Edwards25519
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_Edwards25519)
    $cCurve_Edwards25519 :: Constr
    $tCurve_Edwards25519 :: DataType
    gmapMo :: (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    gmapMp :: (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    gmapM :: (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    gmapQi :: Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u
    gmapQ :: (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    gmapT :: (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> Curve_Edwards25519
    $cgmapT :: (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> Curve_Edwards25519
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_Edwards25519)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_Edwards25519)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519)
    dataTypeOf :: Curve_Edwards25519 -> DataType
    $cdataTypeOf :: Curve_Edwards25519 -> DataType
    toConstr :: Curve_Edwards25519 -> Constr
    $ctoConstr :: Curve_Edwards25519 -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> c Curve_Edwards25519
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> c Curve_Edwards25519
    $cp1Data :: Typeable Curve_Edwards25519
    Data)

    instance EllipticCurve Curve_Edwards25519 where
        type Point Curve_Edwards25519 = Edwards25519.Point
        type Scalar Curve_Edwards25519 = Edwards25519.Scalar
        curveSizeBits :: proxy Curve_Edwards25519 -> Int
    curveSizeBits _ = 255
        curveGenerateScalar :: proxy Curve_Edwards25519 -> randomly (Scalar Curve_Edwards25519)
    curveGenerateScalar _ = randomly (Scalar Curve_Edwards25519)
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    Edwards25519.scalarGenerate
        curveGenerateKeyPair :: proxy Curve_Edwards25519 -> randomly (KeyPair Curve_Edwards25519)
    curveGenerateKeyPair _ = Scalar -> KeyPair Curve_Edwards25519
    forall curve.
    (Point curve ~ Point, Scalar curve ~ Scalar) =>
    Scalar -> KeyPair curve
    toKeyPair (Scalar -> KeyPair Curve_Edwards25519)
    -> randomly Scalar -> randomly (KeyPair Curve_Edwards25519)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> randomly Scalar
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    Edwards25519.scalarGenerate
          where toKeyPair :: Scalar -> KeyPair curve
    toKeyPair scalar :: Scalar
    scalar = Point curve -> Scalar curve -> KeyPair curve
    forall curve. Point curve -> Scalar curve -> KeyPair curve
    KeyPair (Scalar -> Point
    Edwards25519.toPoint Scalar
    scalar) Scalar
    Scalar curve
    scalar
        encodePoint :: proxy Curve_Edwards25519 -> Point Curve_Edwards25519 -> bs
    encodePoint _ point :: Point Curve_Edwards25519
    point = Point -> bs
    forall bs. ByteArray bs => Point -> bs
    Edwards25519.pointEncode Point
    Point Curve_Edwards25519
    point
        decodePoint :: proxy Curve_Edwards25519
    -> bs -> CryptoFailable (Point Curve_Edwards25519)
    decodePoint _ bs :: bs
    bs = bs -> CryptoFailable Point
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable Point
    Edwards25519.pointDecode bs
    bs

    instance EllipticCurveArith Curve_Edwards25519 where
        pointAdd :: proxy Curve_Edwards25519
    -> Point Curve_Edwards25519
    -> Point Curve_Edwards25519
    -> Point Curve_Edwards25519
    pointAdd _ a :: Point Curve_Edwards25519
    a b :: Point Curve_Edwards25519
    b = Point -> Point -> Point
    Edwards25519.pointAdd Point
    Point Curve_Edwards25519
    a Point
    Point Curve_Edwards25519
    b
        pointNegate :: proxy Curve_Edwards25519
    -> Point Curve_Edwards25519 -> Point Curve_Edwards25519
    pointNegate _ p :: Point Curve_Edwards25519
    p = Point -> Point
    Edwards25519.pointNegate Point
    Point Curve_Edwards25519
    p
        pointSmul :: proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Point Curve_Edwards25519
    -> Point Curve_Edwards25519
    pointSmul _ s :: Scalar Curve_Edwards25519
    s p :: Point Curve_Edwards25519
    p = Scalar -> Point -> Point
    Edwards25519.pointMul Scalar
    Scalar Curve_Edwards25519
    s Point
    Point Curve_Edwards25519
    p

    checkNonZeroDH :: SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH :: SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH s :: SharedSecret
    s@(SharedSecret b :: ScrubbedBytes
    b)
        | ScrubbedBytes -> Bool
    forall ba. ByteArrayAccess ba => ba -> Bool
    B.constAllZero ScrubbedBytes
    b = CryptoError -> CryptoFailable SharedSecret
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_ScalarMultiplicationInvalid
        | Bool
    otherwise        = SharedSecret -> CryptoFailable SharedSecret
    forall a. a -> CryptoFailable a
    CryptoPassed SharedSecret
    s

    encodeECShared :: Simple.Curve curve => Proxy curve -> Simple.Point curve -> CryptoFailable SharedSecret
    encodeECShared :: Proxy curve -> Point curve -> CryptoFailable SharedSecret
    encodeECShared _   Simple.PointO      = CryptoError -> CryptoFailable SharedSecret
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_ScalarMultiplicationInvalid
    encodeECShared prx :: Proxy curve
    prx (Simple.Point x :: Integer
    x _) = SharedSecret -> CryptoFailable SharedSecret
    forall a. a -> CryptoFailable a
    CryptoPassed (SharedSecret -> CryptoFailable SharedSecret)
    -> (ScrubbedBytes -> SharedSecret)
    -> ScrubbedBytes
    -> CryptoFailable SharedSecret
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ScrubbedBytes -> SharedSecret
    SharedSecret (ScrubbedBytes -> CryptoFailable SharedSecret)
    -> ScrubbedBytes -> CryptoFailable SharedSecret
    forall a b. (a -> b) -> a -> b
    $ Int -> Integer -> ScrubbedBytes
    forall ba. ByteArray ba => Int -> Integer -> ba
    i2ospOf_ (Proxy curve -> Int
    forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    Simple.curveSizeBytes Proxy curve
    prx) Integer
    x

    encodeECPoint :: forall curve bs . (Simple.Curve curve, ByteArray bs) => Simple.Point curve -> bs
    encodeECPoint :: Point curve -> bs
    encodeECPoint Simple.PointO      = String -> bs
    forall a. HasCallStack => String -> a
    error "encodeECPoint: cannot serialize point at infinity"
    encodeECPoint (Simple.Point x :: Integer
    x y :: Integer
    y) = [bs] -> bs
    forall bin bout.
    (ByteArrayAccess bin, ByteArray bout) =>
    [bin] -> bout
    B.concat [bs
    uncompressed,bs
    xb,bs
    yb]
      where
        size :: Int
    size = Proxy curve -> Int
    forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    Simple.curveSizeBytes (Proxy curve
    forall k (t :: k). Proxy t
    Proxy :: Proxy curve)
        uncompressed, xb, yb :: bs
        uncompressed :: bs
    uncompressed = Word8 -> bs
    forall a. ByteArray a => Word8 -> a
    B.singleton 4
        xb :: bs
    xb = Int -> Integer -> bs
    forall ba. ByteArray ba => Int -> Integer -> ba
    i2ospOf_ Int
    size Integer
    x
        yb :: bs
    yb = Int -> Integer -> bs
    forall ba. ByteArray ba => Int -> Integer -> ba
    i2ospOf_ Int
    size Integer
    y

    decodeECPoint :: (Simple.Curve curve, ByteArray bs) => bs -> CryptoFailable (Simple.Point curve)
    decodeECPoint :: bs -> CryptoFailable (Point curve)
    decodeECPoint mxy :: bs
    mxy = case bs -> Maybe (Word8, bs)
    forall a. ByteArray a => a -> Maybe (Word8, a)
    B.uncons bs
    mxy of
        Nothing     -> CryptoError -> CryptoFailable (Point curve)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed (CryptoError -> CryptoFailable (Point curve))
    -> CryptoError -> CryptoFailable (Point curve)
    forall a b. (a -> b) -> a -> b
    $ CryptoError
    CryptoError_PointSizeInvalid
        Just (m :: Word8
    m,xy :: bs
    xy)
            -- uncompressed
            | Word8
    m Word8 -> Word8 -> Bool
    forall a. Eq a => a -> a -> Bool
    == 4 ->
                let siz :: Int
    siz = bs -> Int
    forall ba. ByteArrayAccess ba => ba -> Int
    B.length bs
    xy Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` 2
                    (xb :: bs
    xb,yb :: bs
    yb) = Int -> bs -> (bs, bs)
    forall bs. ByteArray bs => Int -> bs -> (bs, bs)
    B.splitAt Int
    siz bs
    xy
                    x :: Integer
    x = bs -> Integer
    forall ba. ByteArrayAccess ba => ba -> Integer
    os2ip bs
    xb
                    y :: Integer
    y = bs -> Integer
    forall ba. ByteArrayAccess ba => ba -> Integer
    os2ip bs
    yb
                 in (Integer, Integer) -> CryptoFailable (Point curve)
    forall curve.
    Curve curve =>
    (Integer, Integer) -> CryptoFailable (Point curve)
    Simple.pointFromIntegers (Integer
    x,Integer
    y)
            | Bool
    otherwise -> CryptoError -> CryptoFailable (Point curve)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed (CryptoError -> CryptoFailable (Point curve))
    -> CryptoError -> CryptoFailable (Point curve)
    forall a b. (a -> b) -> a -> b
    $ CryptoError
    CryptoError_PointFormatInvalid