    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TypeFamilies #-}

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

    import qualified Crypto.ECC.Edwards25519 as Edwards25519
    import qualified Crypto.ECC.Simple.Prim as Simple
    import qualified Crypto.ECC.Simple.Types as Simple
    import Crypto.Error
    import Crypto.Internal.ByteArray (
        ByteArray,
        ByteArrayAccess,
        ScrubbedBytes,
     )
    import qualified Crypto.Internal.ByteArray as B
    import Crypto.Internal.Imports
    import Crypto.Number.Basic (numBits)
    import Crypto.Number.Serialize (i2ospOf_, os2ip)
    import qualified Crypto.Number.Serialize.LE as LE
    import qualified Crypto.PubKey.Curve25519 as X25519
    import qualified Crypto.PubKey.Curve448 as X448
    import qualified Crypto.PubKey.ECC.P256 as P256
    import Crypto.Random
    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
        { forall curve. KeyPair curve -> Point curve
    keypairGetPublic :: !(Point curve)
        , forall curve. KeyPair curve -> Scalar curve
    keypairGetPrivate :: !(Scalar curve)
        }

    -- | Secret shared via key exchange
    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
    $c== :: SharedSecret -> SharedSecret -> Bool
    == :: SharedSecret -> SharedSecret -> Bool
    $c/= :: SharedSecret -> SharedSecret -> Bool
    /= :: SharedSecret -> SharedSecret -> Bool
    Eq, SharedSecret -> Int
    (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
    $clength :: SharedSecret -> Int
    length :: SharedSecret -> Int
    $cwithByteArray :: forall p a. SharedSecret -> (Ptr p -> IO a) -> IO a
    withByteArray :: forall p a. SharedSecret -> (Ptr p -> IO a) -> IO a
    $ccopyByteArrayToPtr :: forall p. SharedSecret -> Ptr p -> IO ()
    copyByteArrayToPtr :: forall p. SharedSecret -> Ptr p -> IO ()
    ByteArrayAccess, SharedSecret -> ()
    (SharedSecret -> ()) -> NFData SharedSecret
    forall a. (a -> ()) -> NFData a
    $crnf :: SharedSecret -> ()
    rnf :: SharedSecret -> ()
    NFData)

    instance Semigroup SharedSecret where
        SharedSecret ScrubbedBytes
    x <> :: SharedSecret -> SharedSecret -> SharedSecret
    <> SharedSecret ScrubbedBytes
    y = ScrubbedBytes -> SharedSecret
    SharedSecret (ScrubbedBytes
    x ScrubbedBytes -> ScrubbedBytes -> ScrubbedBytes
    forall a. Semigroup a => a -> a -> a
    <> ScrubbedBytes
    y)

    instance Monoid SharedSecret where
        mempty :: SharedSecret
    mempty = ScrubbedBytes -> SharedSecret
    SharedSecret ScrubbedBytes
    forall a. Monoid a => a
    mempty

    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)

        -- | Encode an elliptic curve scalar into big-endian form
        encodeScalar :: ByteArray bs => proxy curve -> Scalar curve -> bs

        -- | Try to decode the big-endian form of an elliptic curve scalar
        decodeScalar
            :: ByteArray bs => proxy curve -> bs -> CryptoFailable (Scalar curve)

        scalarToPoint :: proxy curve -> Scalar curve -> 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 proxy curve
    prx 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
    forall (proxy :: * -> *).
    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, Eq (Point 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

    class
        (EllipticCurveArith curve, Eq (Scalar curve)) =>
        EllipticCurveBasepointArith curve
        where
        -- | Get the curve order size in bits
        curveOrderBits :: proxy curve -> Int

        -- | Multiply a scalar with the curve base point
        pointBaseSmul :: proxy curve -> Scalar curve -> Point curve

        -- | Multiply the point @p@ with @s2@ and add a lifted to curve value @s1@
        pointsSmulVarTime
            :: proxy curve -> Scalar curve -> Scalar curve -> Point curve -> Point curve
        pointsSmulVarTime proxy curve
    prx Scalar curve
    s1 Scalar curve
    s2 Point curve
    p = proxy curve -> Point curve -> Point curve -> Point curve
    forall curve (proxy :: * -> *).
    EllipticCurveArith curve =>
    proxy curve -> Point curve -> Point curve -> Point curve
    forall (proxy :: * -> *).
    proxy curve -> Point curve -> Point curve -> Point curve
    pointAdd proxy curve
    prx (proxy curve -> Scalar curve -> Point curve
    forall curve (proxy :: * -> *).
    EllipticCurveBasepointArith curve =>
    proxy curve -> Scalar curve -> Point curve
    forall (proxy :: * -> *).
    proxy curve -> Scalar curve -> Point curve
    pointBaseSmul proxy curve
    prx Scalar curve
    s1) (proxy curve -> Scalar curve -> Point curve -> Point curve
    forall curve (proxy :: * -> *).
    EllipticCurveArith curve =>
    proxy curve -> Scalar curve -> Point curve -> Point curve
    forall (proxy :: * -> *).
    proxy curve -> Scalar curve -> Point curve -> Point curve
    pointSmul proxy curve
    prx Scalar curve
    s2 Point curve
    p)

        -- | Convert an elliptic curve scalar to an integer
        scalarToInteger :: proxy curve -> Scalar curve -> Integer

        -- | Try to create an elliptic curve scalar from an integer
        scalarFromInteger :: proxy curve -> Integer -> CryptoFailable (Scalar curve)

        -- | Add two scalars and reduce modulo the curve order
        scalarAdd :: proxy curve -> Scalar curve -> Scalar curve -> Scalar curve

        -- | Multiply two scalars and reduce modulo the curve order
        scalarMul :: proxy curve -> Scalar curve -> 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
    $cshowsPrec :: Int -> Curve_P256R1 -> ShowS
    showsPrec :: Int -> Curve_P256R1 -> ShowS
    $cshow :: Curve_P256R1 -> String
    show :: Curve_P256R1 -> String
    $cshowList :: [Curve_P256R1] -> ShowS
    showList :: [Curve_P256R1] -> ShowS
    Show, Typeable Curve_P256R1
    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 -> Constr
    Curve_P256R1 -> DataType
    (forall b. Data b => b -> b) -> Curve_P256R1 -> 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)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> c Curve_P256R1
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P256R1 -> 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
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P256R1
    $ctoConstr :: Curve_P256R1 -> Constr
    toConstr :: Curve_P256R1 -> Constr
    $cdataTypeOf :: Curve_P256R1 -> DataType
    dataTypeOf :: Curve_P256R1 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P256R1)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> 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)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P256R1)
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1
    gmapT :: (forall b. Data b => b -> b) -> Curve_P256R1 -> Curve_P256R1
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    gmapQl :: forall r r'.
    (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
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P256R1 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P256R1 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P256R1 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P256R1 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (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
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (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
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P256R1 -> m Curve_P256R1
    Data)

    instance EllipticCurve Curve_P256R1 where
        type Point Curve_P256R1 = P256.Point
        type Scalar Curve_P256R1 = P256.Scalar
        curveSizeBits :: forall (proxy :: * -> *). proxy Curve_P256R1 -> Int
    curveSizeBits proxy Curve_P256R1
    _ = Int
    256
        curveGenerateScalar :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P256R1 -> randomly (Scalar Curve_P256R1)
    curveGenerateScalar proxy Curve_P256R1
    _ = randomly Scalar
    randomly (Scalar Curve_P256R1)
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    P256.scalarGenerate
        curveGenerateKeyPair :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P256R1 -> randomly (KeyPair Curve_P256R1)
    curveGenerateKeyPair proxy Curve_P256R1
    _ = 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 = 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P256R1 -> Point Curve_P256R1 -> bs
    encodePoint proxy Curve_P256R1
    _ Point Curve_P256R1
    p = bs
    forall bs. ByteArray bs => bs
    mxy
          where
            mxy :: forall bs. ByteArray bs => bs
            mxy :: forall bs. ByteArray bs => 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 Word8
    4
                xy :: bs
    xy = Point -> bs
    forall ba. ByteArray ba => Point -> ba
    P256.pointToBinary Point
    Point Curve_P256R1
    p
        decodePoint :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P256R1 -> bs -> CryptoFailable (Point Curve_P256R1)
    decodePoint proxy Curve_P256R1
    _ bs
    mxy = case bs -> Maybe (Word8, bs)
    forall a. ByteArray a => a -> Maybe (Word8, a)
    B.uncons bs
    mxy of
            Maybe (Word8, bs)
    Nothing -> CryptoError -> CryptoFailable Point
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_PointSizeInvalid
            Just (Word8
    m, bs
    xy)
                -- uncompressed
                | Word8
    m Word8 -> Word8 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word8
    4 -> bs -> CryptoFailable Point
    forall ba. ByteArrayAccess ba => ba -> CryptoFailable Point
    P256.pointFromBinary bs
    xy
                | Bool
    otherwise -> CryptoError -> CryptoFailable Point
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_PointFormatInvalid
        encodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P256R1 -> Scalar Curve_P256R1 -> bs
    encodeScalar proxy Curve_P256R1
    _ = Scalar -> bs
    Scalar Curve_P256R1 -> bs
    forall ba. ByteArray ba => Scalar -> ba
    P256.scalarToBinary
        decodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P256R1 -> bs -> CryptoFailable (Scalar Curve_P256R1)
    decodeScalar proxy Curve_P256R1
    _ = bs -> CryptoFailable Scalar
    bs -> CryptoFailable (Scalar Curve_P256R1)
    forall ba. ByteArrayAccess ba => ba -> CryptoFailable Scalar
    P256.scalarFromBinary
        scalarToPoint :: forall (proxy :: * -> *).
    proxy Curve_P256R1 -> Scalar Curve_P256R1 -> Point Curve_P256R1
    scalarToPoint proxy Curve_P256R1
    _ = Scalar -> Point
    Scalar Curve_P256R1 -> Point Curve_P256R1
    P256.toPoint

    instance EllipticCurveArith Curve_P256R1 where
        pointAdd :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Point Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointAdd proxy Curve_P256R1
    _ Point Curve_P256R1
    a Point Curve_P256R1
    b = Point -> Point -> Point
    P256.pointAdd Point
    Point Curve_P256R1
    a Point
    Point Curve_P256R1
    b
        pointNegate :: forall (proxy :: * -> *).
    proxy Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointNegate proxy Curve_P256R1
    _ Point Curve_P256R1
    p = Point -> Point
    P256.pointNegate Point
    Point Curve_P256R1
    p
        pointSmul :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    pointSmul proxy Curve_P256R1
    _ Scalar Curve_P256R1
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> SharedSecret
    ecdhRaw proxy Curve_P256R1
    _ Scalar Curve_P256R1
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1
    -> Point Curve_P256R1
    -> CryptoFailable SharedSecret
    ecdh proxy Curve_P256R1
    prx Scalar Curve_P256R1
    s 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
    forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> SharedSecret
    ecdhRaw proxy Curve_P256R1
    prx Scalar Curve_P256R1
    s Point Curve_P256R1
    p)

    instance EllipticCurveBasepointArith Curve_P256R1 where
        curveOrderBits :: forall (proxy :: * -> *). proxy Curve_P256R1 -> Int
    curveOrderBits proxy Curve_P256R1
    _ = Int
    256
        pointBaseSmul :: forall (proxy :: * -> *).
    proxy Curve_P256R1 -> Scalar Curve_P256R1 -> Point Curve_P256R1
    pointBaseSmul proxy Curve_P256R1
    _ = Scalar -> Point
    Scalar Curve_P256R1 -> Point Curve_P256R1
    P256.toPoint
        pointsSmulVarTime :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1
    -> Scalar Curve_P256R1
    -> Point Curve_P256R1
    -> Point Curve_P256R1
    pointsSmulVarTime proxy Curve_P256R1
    _ = Scalar -> Scalar -> Point -> Point
    Scalar Curve_P256R1
    -> Scalar Curve_P256R1 -> Point Curve_P256R1 -> Point Curve_P256R1
    P256.pointsMulVarTime
        scalarToInteger :: forall (proxy :: * -> *).
    proxy Curve_P256R1 -> Scalar Curve_P256R1 -> Integer
    scalarToInteger proxy Curve_P256R1
    _ = Scalar -> Integer
    Scalar Curve_P256R1 -> Integer
    P256.scalarToInteger
        scalarFromInteger :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Integer -> CryptoFailable (Scalar Curve_P256R1)
    scalarFromInteger proxy Curve_P256R1
    _ = Integer -> CryptoFailable Scalar
    Integer -> CryptoFailable (Scalar Curve_P256R1)
    P256.scalarFromInteger
        scalarAdd :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1
    -> Scalar Curve_P256R1
    -> Scalar Curve_P256R1
    scalarAdd proxy Curve_P256R1
    _ = Scalar -> Scalar -> Scalar
    Scalar Curve_P256R1 -> Scalar Curve_P256R1 -> Scalar Curve_P256R1
    P256.scalarAdd
        scalarMul :: forall (proxy :: * -> *).
    proxy Curve_P256R1
    -> Scalar Curve_P256R1
    -> Scalar Curve_P256R1
    -> Scalar Curve_P256R1
    scalarMul proxy Curve_P256R1
    _ = Scalar -> Scalar -> Scalar
    Scalar Curve_P256R1 -> Scalar Curve_P256R1 -> Scalar Curve_P256R1
    P256.scalarMul

    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
    $cshowsPrec :: Int -> Curve_P384R1 -> ShowS
    showsPrec :: Int -> Curve_P384R1 -> ShowS
    $cshow :: Curve_P384R1 -> String
    show :: Curve_P384R1 -> String
    $cshowList :: [Curve_P384R1] -> ShowS
    showList :: [Curve_P384R1] -> ShowS
    Show, Typeable Curve_P384R1
    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 -> Constr
    Curve_P384R1 -> DataType
    (forall b. Data b => b -> b) -> Curve_P384R1 -> 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)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> c Curve_P384R1
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P384R1 -> 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
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P384R1
    $ctoConstr :: Curve_P384R1 -> Constr
    toConstr :: Curve_P384R1 -> Constr
    $cdataTypeOf :: Curve_P384R1 -> DataType
    dataTypeOf :: Curve_P384R1 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P384R1)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> 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)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P384R1)
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1
    gmapT :: (forall b. Data b => b -> b) -> Curve_P384R1 -> Curve_P384R1
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    gmapQl :: forall r r'.
    (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
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P384R1 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P384R1 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P384R1 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P384R1 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m Curve_P384R1
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (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
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (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
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P384R1 -> m 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 :: forall (proxy :: * -> *). proxy Curve_P384R1 -> Int
    curveSizeBits proxy Curve_P384R1
    _ = Int
    384
        curveGenerateScalar :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P384R1 -> randomly (Scalar Curve_P384R1)
    curveGenerateScalar proxy Curve_P384R1
    _ = randomly (Scalar SEC_p384r1)
    randomly (Scalar Curve_P384R1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
        curveGenerateKeyPair :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P384R1 -> randomly (KeyPair Curve_P384R1)
    curveGenerateKeyPair proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> KeyPair Curve_P384R1
    forall {curve} {curve}.
    (Point curve ~ Point curve, Scalar curve ~ Scalar curve,
     Curve 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 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P384R1 -> Point Curve_P384R1 -> bs
    encodePoint proxy Curve_P384R1
    _ 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P384R1 -> bs -> CryptoFailable (Point Curve_P384R1)
    decodePoint proxy Curve_P384R1
    _ bs
    bs = bs -> CryptoFailable (Point SEC_p384r1)
    forall curve bs.
    (Curve curve, ByteArray bs) =>
    bs -> CryptoFailable (Point curve)
    decodeECPoint bs
    bs
        encodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P384R1 -> Scalar Curve_P384R1 -> bs
    encodeScalar proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> bs
    Scalar Curve_P384R1 -> bs
    forall curve bs. (Curve curve, ByteArray bs) => Scalar curve -> bs
    ecScalarToBinary
        decodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P384R1 -> bs -> CryptoFailable (Scalar Curve_P384R1)
    decodeScalar proxy Curve_P384R1
    _ = bs -> CryptoFailable (Scalar SEC_p384r1)
    bs -> CryptoFailable (Scalar Curve_P384R1)
    forall curve bs.
    (Curve curve, ByteArrayAccess bs) =>
    bs -> CryptoFailable (Scalar curve)
    ecScalarFromBinary
        scalarToPoint :: forall (proxy :: * -> *).
    proxy Curve_P384R1 -> Scalar Curve_P384R1 -> Point Curve_P384R1
    scalarToPoint proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> Point SEC_p384r1
    Scalar Curve_P384R1 -> Point Curve_P384R1
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul

    instance EllipticCurveArith Curve_P384R1 where
        pointAdd :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Point Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointAdd proxy Curve_P384R1
    _ Point Curve_P384R1
    a 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 :: forall (proxy :: * -> *).
    proxy Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointNegate proxy Curve_P384R1
    _ 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 :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Scalar Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    pointSmul proxy Curve_P384R1
    _ Scalar Curve_P384R1
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Scalar Curve_P384R1
    -> Point Curve_P384R1
    -> CryptoFailable SharedSecret
    ecdh proxy Curve_P384R1
    _ Scalar Curve_P384R1
    s 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

    instance EllipticCurveBasepointArith Curve_P384R1 where
        curveOrderBits :: forall (proxy :: * -> *). proxy Curve_P384R1 -> Int
    curveOrderBits proxy Curve_P384R1
    _ = Int
    384
        pointBaseSmul :: forall (proxy :: * -> *).
    proxy Curve_P384R1 -> Scalar Curve_P384R1 -> Point Curve_P384R1
    pointBaseSmul proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> Point SEC_p384r1
    Scalar Curve_P384R1 -> Point Curve_P384R1
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul
        pointsSmulVarTime :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Scalar Curve_P384R1
    -> Scalar Curve_P384R1
    -> Point Curve_P384R1
    -> Point Curve_P384R1
    pointsSmulVarTime proxy Curve_P384R1
    _ = Scalar SEC_p384r1
    -> Scalar SEC_p384r1 -> Point SEC_p384r1 -> Point SEC_p384r1
    Scalar Curve_P384R1
    -> Scalar Curve_P384R1 -> Point Curve_P384R1 -> Point Curve_P384R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Point curve -> Point curve
    ecPointsMulVarTime
        scalarToInteger :: forall (proxy :: * -> *).
    proxy Curve_P384R1 -> Scalar Curve_P384R1 -> Integer
    scalarToInteger proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> Integer
    Scalar Curve_P384R1 -> Integer
    forall curve. Scalar curve -> Integer
    ecScalarToInteger
        scalarFromInteger :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Integer -> CryptoFailable (Scalar Curve_P384R1)
    scalarFromInteger proxy Curve_P384R1
    _ = Integer -> CryptoFailable (Scalar SEC_p384r1)
    Integer -> CryptoFailable (Scalar Curve_P384R1)
    forall curve.
    Curve curve =>
    Integer -> CryptoFailable (Scalar curve)
    ecScalarFromInteger
        scalarAdd :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Scalar Curve_P384R1
    -> Scalar Curve_P384R1
    -> Scalar Curve_P384R1
    scalarAdd proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> Scalar SEC_p384r1 -> Scalar SEC_p384r1
    Scalar Curve_P384R1 -> Scalar Curve_P384R1 -> Scalar Curve_P384R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarAdd
        scalarMul :: forall (proxy :: * -> *).
    proxy Curve_P384R1
    -> Scalar Curve_P384R1
    -> Scalar Curve_P384R1
    -> Scalar Curve_P384R1
    scalarMul proxy Curve_P384R1
    _ = Scalar SEC_p384r1 -> Scalar SEC_p384r1 -> Scalar SEC_p384r1
    Scalar Curve_P384R1 -> Scalar Curve_P384R1 -> Scalar Curve_P384R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarMul

    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
    $cshowsPrec :: Int -> Curve_P521R1 -> ShowS
    showsPrec :: Int -> Curve_P521R1 -> ShowS
    $cshow :: Curve_P521R1 -> String
    show :: Curve_P521R1 -> String
    $cshowList :: [Curve_P521R1] -> ShowS
    showList :: [Curve_P521R1] -> ShowS
    Show, Typeable Curve_P521R1
    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 -> Constr
    Curve_P521R1 -> DataType
    (forall b. Data b => b -> b) -> Curve_P521R1 -> 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)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> c Curve_P521R1
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_P521R1 -> 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
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_P521R1
    $ctoConstr :: Curve_P521R1 -> Constr
    toConstr :: Curve_P521R1 -> Constr
    $cdataTypeOf :: Curve_P521R1 -> DataType
    dataTypeOf :: Curve_P521R1 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_P521R1)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> 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)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_P521R1)
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1
    gmapT :: (forall b. Data b => b -> b) -> Curve_P521R1 -> Curve_P521R1
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    gmapQl :: forall r r'.
    (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
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_P521R1 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P521R1 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_P521R1 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_P521R1 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m Curve_P521R1
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (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
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (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
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_P521R1 -> m 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 :: forall (proxy :: * -> *). proxy Curve_P521R1 -> Int
    curveSizeBits proxy Curve_P521R1
    _ = Int
    521
        curveGenerateScalar :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P521R1 -> randomly (Scalar Curve_P521R1)
    curveGenerateScalar proxy Curve_P521R1
    _ = randomly (Scalar SEC_p521r1)
    randomly (Scalar Curve_P521R1)
    forall (randomly :: * -> *) curve.
    (MonadRandom randomly, Curve curve) =>
    randomly (Scalar curve)
    Simple.scalarGenerate
        curveGenerateKeyPair :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_P521R1 -> randomly (KeyPair Curve_P521R1)
    curveGenerateKeyPair proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> KeyPair Curve_P521R1
    forall {curve} {curve}.
    (Point curve ~ Point curve, Scalar curve ~ Scalar curve,
     Curve 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 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P521R1 -> Point Curve_P521R1 -> bs
    encodePoint proxy Curve_P521R1
    _ 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P521R1 -> bs -> CryptoFailable (Point Curve_P521R1)
    decodePoint proxy Curve_P521R1
    _ bs
    bs = bs -> CryptoFailable (Point SEC_p521r1)
    forall curve bs.
    (Curve curve, ByteArray bs) =>
    bs -> CryptoFailable (Point curve)
    decodeECPoint bs
    bs
        encodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P521R1 -> Scalar Curve_P521R1 -> bs
    encodeScalar proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> bs
    Scalar Curve_P521R1 -> bs
    forall curve bs. (Curve curve, ByteArray bs) => Scalar curve -> bs
    ecScalarToBinary
        decodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_P521R1 -> bs -> CryptoFailable (Scalar Curve_P521R1)
    decodeScalar proxy Curve_P521R1
    _ = bs -> CryptoFailable (Scalar SEC_p521r1)
    bs -> CryptoFailable (Scalar Curve_P521R1)
    forall curve bs.
    (Curve curve, ByteArrayAccess bs) =>
    bs -> CryptoFailable (Scalar curve)
    ecScalarFromBinary
        scalarToPoint :: forall (proxy :: * -> *).
    proxy Curve_P521R1 -> Scalar Curve_P521R1 -> Point Curve_P521R1
    scalarToPoint proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> Point SEC_p521r1
    Scalar Curve_P521R1 -> Point Curve_P521R1
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul

    instance EllipticCurveArith Curve_P521R1 where
        pointAdd :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Point Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointAdd proxy Curve_P521R1
    _ Point Curve_P521R1
    a 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 :: forall (proxy :: * -> *).
    proxy Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointNegate proxy Curve_P521R1
    _ 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 :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Scalar Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    pointSmul proxy Curve_P521R1
    _ Scalar Curve_P521R1
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Scalar Curve_P521R1
    -> Point Curve_P521R1
    -> CryptoFailable SharedSecret
    ecdh proxy Curve_P521R1
    _ Scalar Curve_P521R1
    s 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

    instance EllipticCurveBasepointArith Curve_P521R1 where
        curveOrderBits :: forall (proxy :: * -> *). proxy Curve_P521R1 -> Int
    curveOrderBits proxy Curve_P521R1
    _ = Int
    521
        pointBaseSmul :: forall (proxy :: * -> *).
    proxy Curve_P521R1 -> Scalar Curve_P521R1 -> Point Curve_P521R1
    pointBaseSmul proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> Point SEC_p521r1
    Scalar Curve_P521R1 -> Point Curve_P521R1
    forall curve. Curve curve => Scalar curve -> Point curve
    Simple.pointBaseMul
        pointsSmulVarTime :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Scalar Curve_P521R1
    -> Scalar Curve_P521R1
    -> Point Curve_P521R1
    -> Point Curve_P521R1
    pointsSmulVarTime proxy Curve_P521R1
    _ = Scalar SEC_p521r1
    -> Scalar SEC_p521r1 -> Point SEC_p521r1 -> Point SEC_p521r1
    Scalar Curve_P521R1
    -> Scalar Curve_P521R1 -> Point Curve_P521R1 -> Point Curve_P521R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Point curve -> Point curve
    ecPointsMulVarTime
        scalarToInteger :: forall (proxy :: * -> *).
    proxy Curve_P521R1 -> Scalar Curve_P521R1 -> Integer
    scalarToInteger proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> Integer
    Scalar Curve_P521R1 -> Integer
    forall curve. Scalar curve -> Integer
    ecScalarToInteger
        scalarFromInteger :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Integer -> CryptoFailable (Scalar Curve_P521R1)
    scalarFromInteger proxy Curve_P521R1
    _ = Integer -> CryptoFailable (Scalar SEC_p521r1)
    Integer -> CryptoFailable (Scalar Curve_P521R1)
    forall curve.
    Curve curve =>
    Integer -> CryptoFailable (Scalar curve)
    ecScalarFromInteger
        scalarAdd :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Scalar Curve_P521R1
    -> Scalar Curve_P521R1
    -> Scalar Curve_P521R1
    scalarAdd proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> Scalar SEC_p521r1 -> Scalar SEC_p521r1
    Scalar Curve_P521R1 -> Scalar Curve_P521R1 -> Scalar Curve_P521R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarAdd
        scalarMul :: forall (proxy :: * -> *).
    proxy Curve_P521R1
    -> Scalar Curve_P521R1
    -> Scalar Curve_P521R1
    -> Scalar Curve_P521R1
    scalarMul proxy Curve_P521R1
    _ = Scalar SEC_p521r1 -> Scalar SEC_p521r1 -> Scalar SEC_p521r1
    Scalar Curve_P521R1 -> Scalar Curve_P521R1 -> Scalar Curve_P521R1
    forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarMul

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

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

    instance EllipticCurveDH Curve_X25519 where
        ecdhRaw :: forall (proxy :: * -> *).
    proxy Curve_X25519
    -> Scalar Curve_X25519 -> Point Curve_X25519 -> SharedSecret
    ecdhRaw proxy Curve_X25519
    _ Scalar Curve_X25519
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_X25519
    -> Scalar Curve_X25519
    -> Point Curve_X25519
    -> CryptoFailable SharedSecret
    ecdh proxy Curve_X25519
    prx Scalar Curve_X25519
    s 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
    forall (proxy :: * -> *).
    proxy Curve_X25519
    -> Scalar Curve_X25519 -> Point Curve_X25519 -> 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
    $cshowsPrec :: Int -> Curve_X448 -> ShowS
    showsPrec :: Int -> Curve_X448 -> ShowS
    $cshow :: Curve_X448 -> String
    show :: Curve_X448 -> String
    $cshowList :: [Curve_X448] -> ShowS
    showList :: [Curve_X448] -> ShowS
    Show, Typeable Curve_X448
    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 -> Constr
    Curve_X448 -> DataType
    (forall b. Data b => b -> b) -> Curve_X448 -> 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)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> c Curve_X448
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Curve_X448 -> 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
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_X448
    $ctoConstr :: Curve_X448 -> Constr
    toConstr :: Curve_X448 -> Constr
    $cdataTypeOf :: Curve_X448 -> DataType
    dataTypeOf :: Curve_X448 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_X448)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> 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)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Curve_X448)
    $cgmapT :: (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448
    gmapT :: (forall b. Data b => b -> b) -> Curve_X448 -> Curve_X448
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    gmapQl :: forall r r'.
    (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
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_X448 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_X448 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_X448 -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Curve_X448 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (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
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (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
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Curve_X448 -> m Curve_X448
    Data)

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

    instance EllipticCurveDH Curve_X448 where
        ecdhRaw :: forall (proxy :: * -> *).
    proxy Curve_X448
    -> Scalar Curve_X448 -> Point Curve_X448 -> SharedSecret
    ecdhRaw proxy Curve_X448
    _ Scalar Curve_X448
    s 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 :: forall (proxy :: * -> *).
    proxy Curve_X448
    -> Scalar Curve_X448
    -> Point Curve_X448
    -> CryptoFailable SharedSecret
    ecdh proxy Curve_X448
    prx Scalar Curve_X448
    s 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
    forall (proxy :: * -> *).
    proxy Curve_X448
    -> Scalar Curve_X448 -> Point Curve_X448 -> 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
    $cshowsPrec :: Int -> Curve_Edwards25519 -> ShowS
    showsPrec :: Int -> Curve_Edwards25519 -> ShowS
    $cshow :: Curve_Edwards25519 -> String
    show :: Curve_Edwards25519 -> String
    $cshowList :: [Curve_Edwards25519] -> ShowS
    showList :: [Curve_Edwards25519] -> ShowS
    Show, Typeable Curve_Edwards25519
    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 -> Constr
    Curve_Edwards25519 -> DataType
    (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> 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)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> c Curve_Edwards25519
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> Curve_Edwards25519
    -> 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
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Curve_Edwards25519
    $ctoConstr :: Curve_Edwards25519 -> Constr
    toConstr :: Curve_Edwards25519 -> Constr
    $cdataTypeOf :: Curve_Edwards25519 -> DataType
    dataTypeOf :: Curve_Edwards25519 -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Curve_Edwards25519)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> 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)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Curve_Edwards25519)
    $cgmapT :: (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> Curve_Edwards25519
    gmapT :: (forall b. Data b => b -> b)
    -> Curve_Edwards25519 -> Curve_Edwards25519
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    gmapQl :: forall r r'.
    (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
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Curve_Edwards25519 -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Curve_Edwards25519 -> [u]
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> Curve_Edwards25519 -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (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
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (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
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Curve_Edwards25519 -> m Curve_Edwards25519
    Data)

    instance EllipticCurve Curve_Edwards25519 where
        type Point Curve_Edwards25519 = Edwards25519.Point
        type Scalar Curve_Edwards25519 = Edwards25519.Scalar
        curveSizeBits :: forall (proxy :: * -> *). proxy Curve_Edwards25519 -> Int
    curveSizeBits proxy Curve_Edwards25519
    _ = Int
    255
        curveGenerateScalar :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_Edwards25519 -> randomly (Scalar Curve_Edwards25519)
    curveGenerateScalar proxy Curve_Edwards25519
    _ = randomly Scalar
    randomly (Scalar Curve_Edwards25519)
    forall (randomly :: * -> *).
    MonadRandom randomly =>
    randomly Scalar
    Edwards25519.scalarGenerate
        curveGenerateKeyPair :: forall (randomly :: * -> *) (proxy :: * -> *).
    MonadRandom randomly =>
    proxy Curve_Edwards25519 -> randomly (KeyPair Curve_Edwards25519)
    curveGenerateKeyPair proxy Curve_Edwards25519
    _ = 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 = 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 :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_Edwards25519 -> Point Curve_Edwards25519 -> bs
    encodePoint proxy Curve_Edwards25519
    _ Point Curve_Edwards25519
    point = Point -> bs
    forall bs. ByteArray bs => Point -> bs
    Edwards25519.pointEncode Point
    Point Curve_Edwards25519
    point
        decodePoint :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_Edwards25519
    -> bs -> CryptoFailable (Point Curve_Edwards25519)
    decodePoint proxy Curve_Edwards25519
    _ bs
    bs = bs -> CryptoFailable Point
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable Point
    Edwards25519.pointDecode bs
    bs
        encodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_Edwards25519 -> Scalar Curve_Edwards25519 -> bs
    encodeScalar proxy Curve_Edwards25519
    _ = bs -> bs
    forall bs. ByteArray bs => bs -> bs
    B.reverse (bs -> bs) -> (Scalar -> bs) -> Scalar -> bs
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Scalar -> bs
    forall bs. ByteArray bs => Scalar -> bs
    Edwards25519.scalarEncode
        decodeScalar :: forall bs (proxy :: * -> *).
    ByteArray bs =>
    proxy Curve_Edwards25519
    -> bs -> CryptoFailable (Scalar Curve_Edwards25519)
    decodeScalar proxy Curve_Edwards25519
    _ bs
    bs
            | bs -> Int
    forall ba. ByteArrayAccess ba => ba -> Int
    B.length bs
    bs Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    32 = bs -> CryptoFailable Scalar
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable Scalar
    Edwards25519.scalarDecodeLong (bs -> bs
    forall bs. ByteArray bs => bs -> bs
    B.reverse bs
    bs)
            | Bool
    otherwise = CryptoError -> CryptoFailable Scalar
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_SecretKeySizeInvalid
        scalarToPoint :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519 -> Point Curve_Edwards25519
    scalarToPoint proxy Curve_Edwards25519
    _ = Scalar -> Point
    Scalar Curve_Edwards25519 -> Point Curve_Edwards25519
    Edwards25519.toPoint

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

    instance EllipticCurveBasepointArith Curve_Edwards25519 where
        curveOrderBits :: forall (proxy :: * -> *). proxy Curve_Edwards25519 -> Int
    curveOrderBits proxy Curve_Edwards25519
    _ = Int
    253
        pointBaseSmul :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519 -> Point Curve_Edwards25519
    pointBaseSmul proxy Curve_Edwards25519
    _ = Scalar -> Point
    Scalar Curve_Edwards25519 -> Point Curve_Edwards25519
    Edwards25519.toPoint
        pointsSmulVarTime :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Point Curve_Edwards25519
    -> Point Curve_Edwards25519
    pointsSmulVarTime proxy Curve_Edwards25519
    _ = Scalar -> Scalar -> Point -> Point
    Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Point Curve_Edwards25519
    -> Point Curve_Edwards25519
    Edwards25519.pointsMulVarTime
        scalarToInteger :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519 -> Scalar Curve_Edwards25519 -> Integer
    scalarToInteger proxy Curve_Edwards25519
    _ Scalar Curve_Edwards25519
    s = Bytes -> Integer
    forall ba. ByteArrayAccess ba => ba -> Integer
    LE.os2ip (Scalar -> Bytes
    forall bs. ByteArray bs => Scalar -> bs
    Edwards25519.scalarEncode Scalar
    Scalar Curve_Edwards25519
    s :: B.Bytes)
        scalarFromInteger :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Integer -> CryptoFailable (Scalar Curve_Edwards25519)
    scalarFromInteger proxy Curve_Edwards25519
    _ Integer
    i =
            case Int -> Integer -> Maybe Bytes
    forall ba. ByteArray ba => Int -> Integer -> Maybe ba
    LE.i2ospOf Int
    32 Integer
    i of
                Maybe Bytes
    Nothing -> CryptoError -> CryptoFailable Scalar
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_SecretKeySizeInvalid
                Just Bytes
    bs -> Bytes -> CryptoFailable Scalar
    forall bs. ByteArrayAccess bs => bs -> CryptoFailable Scalar
    Edwards25519.scalarDecodeLong (Bytes
    bs :: B.Bytes)
        scalarAdd :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    scalarAdd proxy Curve_Edwards25519
    _ = Scalar -> Scalar -> Scalar
    Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519 -> Scalar Curve_Edwards25519
    Edwards25519.scalarAdd
        scalarMul :: forall (proxy :: * -> *).
    proxy Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519
    scalarMul proxy Curve_Edwards25519
    _ = Scalar -> Scalar -> Scalar
    Scalar Curve_Edwards25519
    -> Scalar Curve_Edwards25519 -> Scalar Curve_Edwards25519
    Edwards25519.scalarMul

    checkNonZeroDH :: SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH :: SharedSecret -> CryptoFailable SharedSecret
    checkNonZeroDH s :: SharedSecret
    s@(SharedSecret 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 :: forall curve.
    Curve curve =>
    Proxy curve -> Point curve -> CryptoFailable SharedSecret
    encodeECShared Proxy curve
    _ Point curve
    Simple.PointO = CryptoError -> CryptoFailable SharedSecret
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_ScalarMultiplicationInvalid
    encodeECShared Proxy curve
    prx (Simple.Point Integer
    x Integer
    _) = 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 :: forall curve bs. (Curve curve, ByteArray bs) => Point curve -> bs
    encodeECPoint Point curve
    Simple.PointO = String -> bs
    forall a. HasCallStack => String -> a
    error String
    "encodeECPoint: cannot serialize point at infinity"
    encodeECPoint (Simple.Point Integer
    x 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 Word8
    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 :: forall curve bs.
    (Curve curve, ByteArray bs) =>
    bs -> CryptoFailable (Point curve)
    decodeECPoint bs
    mxy = case bs -> Maybe (Word8, bs)
    forall a. ByteArray a => a -> Maybe (Word8, a)
    B.uncons bs
    mxy of
        Maybe (Word8, bs)
    Nothing -> CryptoError -> CryptoFailable (Point curve)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_PointSizeInvalid
        Just (Word8
    m, bs
    xy)
            -- uncompressed
            | Word8
    m Word8 -> Word8 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Word8
    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` Int
    2
                    (bs
    xb, 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
    CryptoError_PointFormatInvalid

    ecPointsMulVarTime
        :: forall curve
         . Simple.Curve curve
        => Simple.Scalar curve
        -> Simple.Scalar curve
        -> Simple.Point curve
        -> Simple.Point curve
    ecPointsMulVarTime :: forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Point curve -> Point curve
    ecPointsMulVarTime Scalar curve
    n1 = Scalar curve
    -> Point curve -> Scalar curve -> Point curve -> Point curve
    forall curve.
    Curve curve =>
    Scalar curve
    -> Point curve -> Scalar curve -> Point curve -> Point curve
    Simple.pointAddTwoMuls Scalar curve
    n1 Point curve
    g
      where
        g :: Point curve
    g = CurveParameters curve -> Point curve
    forall curve. CurveParameters curve -> Point curve
    Simple.curveEccG (CurveParameters curve -> Point curve)
    -> CurveParameters curve -> Point curve
    forall a b. (a -> b) -> a -> b
    $ Proxy curve -> CurveParameters curve
    forall curve (proxy :: * -> *).
    Curve curve =>
    proxy curve -> CurveParameters curve
    forall (proxy :: * -> *). proxy curve -> CurveParameters curve
    Simple.curveParameters (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)

    ecScalarFromBinary
        :: forall curve bs
         . (Simple.Curve curve, ByteArrayAccess bs)
        => bs -> CryptoFailable (Simple.Scalar curve)
    ecScalarFromBinary :: forall curve bs.
    (Curve curve, ByteArrayAccess bs) =>
    bs -> CryptoFailable (Scalar curve)
    ecScalarFromBinary bs
    ba
        | bs -> Int
    forall ba. ByteArrayAccess ba => ba -> Int
    B.length bs
    ba Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Int
    size = CryptoError -> CryptoFailable (Scalar curve)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_SecretKeySizeInvalid
        | Bool
    otherwise = Scalar curve -> CryptoFailable (Scalar curve)
    forall a. a -> CryptoFailable a
    CryptoPassed (Integer -> Scalar curve
    forall curve. Integer -> Scalar curve
    Simple.Scalar (Integer -> Scalar curve) -> Integer -> Scalar curve
    forall a b. (a -> b) -> a -> b
    $ bs -> Integer
    forall ba. ByteArrayAccess ba => ba -> Integer
    os2ip bs
    ba)
      where
        size :: Int
    size = Proxy curve -> Int
    forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    ecCurveOrderBytes (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)

    ecScalarToBinary
        :: forall curve bs
         . (Simple.Curve curve, ByteArray bs)
        => Simple.Scalar curve -> bs
    ecScalarToBinary :: forall curve bs. (Curve curve, ByteArray bs) => Scalar curve -> bs
    ecScalarToBinary (Simple.Scalar Integer
    s) = Int -> Integer -> bs
    forall ba. ByteArray ba => Int -> Integer -> ba
    i2ospOf_ Int
    size Integer
    s
      where
        size :: Int
    size = Proxy curve -> Int
    forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    ecCurveOrderBytes (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)

    ecScalarFromInteger
        :: forall curve
         . Simple.Curve curve
        => Integer -> CryptoFailable (Simple.Scalar curve)
    ecScalarFromInteger :: forall curve.
    Curve curve =>
    Integer -> CryptoFailable (Scalar curve)
    ecScalarFromInteger Integer
    s
        | Integer -> Int
    numBits Integer
    s Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    nb = CryptoError -> CryptoFailable (Scalar curve)
    forall a. CryptoError -> CryptoFailable a
    CryptoFailed CryptoError
    CryptoError_SecretKeySizeInvalid
        | Bool
    otherwise = Scalar curve -> CryptoFailable (Scalar curve)
    forall a. a -> CryptoFailable a
    CryptoPassed (Integer -> Scalar curve
    forall curve. Integer -> Scalar curve
    Simple.Scalar Integer
    s)
      where
        nb :: Int
    nb = Int
    8 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    * Proxy curve -> Int
    forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    ecCurveOrderBytes (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)

    ecScalarToInteger :: Simple.Scalar curve -> Integer
    ecScalarToInteger :: forall curve. Scalar curve -> Integer
    ecScalarToInteger (Simple.Scalar Integer
    s) = Integer
    s

    ecCurveOrderBytes :: Simple.Curve c => proxy c -> Int
    ecCurveOrderBytes :: forall curve (proxy :: * -> *). Curve curve => proxy curve -> Int
    ecCurveOrderBytes proxy c
    prx = (Integer -> Int
    numBits Integer
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    7) Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `div` Int
    8
      where
        n :: Integer
    n = CurveParameters c -> Integer
    forall curve. CurveParameters curve -> Integer
    Simple.curveEccN (CurveParameters c -> Integer) -> CurveParameters c -> Integer
    forall a b. (a -> b) -> a -> b
    $ proxy c -> CurveParameters c
    forall curve (proxy :: * -> *).
    Curve curve =>
    proxy curve -> CurveParameters curve
    forall (proxy :: * -> *). proxy c -> CurveParameters c
    Simple.curveParameters proxy c
    prx

    ecScalarAdd
        :: forall curve
         . Simple.Curve curve
        => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
    ecScalarAdd :: forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarAdd (Simple.Scalar Integer
    a) (Simple.Scalar Integer
    b) = Integer -> Scalar curve
    forall curve. Integer -> Scalar curve
    Simple.Scalar ((Integer
    a Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Integer
    b) Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    n)
      where
        n :: Integer
    n = CurveParameters curve -> Integer
    forall curve. CurveParameters curve -> Integer
    Simple.curveEccN (CurveParameters curve -> Integer)
    -> CurveParameters curve -> Integer
    forall a b. (a -> b) -> a -> b
    $ Proxy curve -> CurveParameters curve
    forall curve (proxy :: * -> *).
    Curve curve =>
    proxy curve -> CurveParameters curve
    forall (proxy :: * -> *). proxy curve -> CurveParameters curve
    Simple.curveParameters (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)

    ecScalarMul
        :: forall curve
         . Simple.Curve curve
        => Simple.Scalar curve -> Simple.Scalar curve -> Simple.Scalar curve
    ecScalarMul :: forall curve.
    Curve curve =>
    Scalar curve -> Scalar curve -> Scalar curve
    ecScalarMul (Simple.Scalar Integer
    a) (Simple.Scalar Integer
    b) = Integer -> Scalar curve
    forall curve. Integer -> Scalar curve
    Simple.Scalar ((Integer
    a Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    * Integer
    b) Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    n)
      where
        n :: Integer
    n = CurveParameters curve -> Integer
    forall curve. CurveParameters curve -> Integer
    Simple.curveEccN (CurveParameters curve -> Integer)
    -> CurveParameters curve -> Integer
    forall a b. (a -> b) -> a -> b
    $ Proxy curve -> CurveParameters curve
    forall curve (proxy :: * -> *).
    Curve curve =>
    proxy curve -> CurveParameters curve
    forall (proxy :: * -> *). proxy curve -> CurveParameters curve
    Simple.curveParameters (Proxy curve
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy curve)