{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-full-laziness #-}
module Cardano.Crypto.DSIGN.Ed25519
( Ed25519DSIGN
, SigDSIGN (..)
, SignKeyDSIGN (..)
, VerKeyDSIGN (..)
)
where
import Control.DeepSeq (NFData)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import System.IO.Unsafe (unsafeDupablePerformIO)
import GHC.IO.Exception (ioException)
import Control.Monad (unless)
import Foreign.C.Error (errnoToIOError, getErrno)
import Foreign.Ptr (castPtr, nullPtr)
import qualified Data.ByteString as BS
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Foreign
import Cardano.Crypto.PinnedSizedBytes
import Cardano.Crypto.Libsodium.C
import Cardano.Crypto.DSIGN.Class
import Cardano.Crypto.Seed
import Cardano.Crypto.Util (SignableRepresentation(..))
import Data.Proxy
data Ed25519DSIGN
instance NoThunks (VerKeyDSIGN Ed25519DSIGN)
instance NoThunks (SignKeyDSIGN Ed25519DSIGN)
instance NoThunks (SigDSIGN Ed25519DSIGN)
cOrError :: String -> String -> IO Int -> IO ()
cOrError :: String -> String -> IO Int -> IO ()
cOrError String
contextDesc String
cFunName IO Int
action = do
Int
res <- IO Int
action
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
res forall a. Eq a => a -> a -> Bool
== Int
0) forall a b. (a -> b) -> a -> b
$ do
Errno
errno <- IO Errno
getErrno
forall a. IOException -> IO a
ioException forall a b. (a -> b) -> a -> b
$ String -> Errno -> Maybe Handle -> Maybe String -> IOException
errnoToIOError (String
contextDesc forall a. [a] -> [a] -> [a]
++ String
": " forall a. [a] -> [a] -> [a]
++ String
cFunName) Errno
errno forall a. Maybe a
Nothing forall a. Maybe a
Nothing
instance DSIGNAlgorithm Ed25519DSIGN where
type SeedSizeDSIGN Ed25519DSIGN = CRYPTO_SIGN_ED25519_SEEDBYTES
type SizeVerKeyDSIGN Ed25519DSIGN = CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
type SizeSignKeyDSIGN Ed25519DSIGN = CRYPTO_SIGN_ED25519_SEEDBYTES
type SizeSigDSIGN Ed25519DSIGN = CRYPTO_SIGN_ED25519_BYTES
newtype VerKeyDSIGN Ed25519DSIGN = VerKeyEd25519DSIGN (PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN))
deriving (Int -> VerKeyDSIGN Ed25519DSIGN -> ShowS
[VerKeyDSIGN Ed25519DSIGN] -> ShowS
VerKeyDSIGN Ed25519DSIGN -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerKeyDSIGN Ed25519DSIGN] -> ShowS
$cshowList :: [VerKeyDSIGN Ed25519DSIGN] -> ShowS
show :: VerKeyDSIGN Ed25519DSIGN -> String
$cshow :: VerKeyDSIGN Ed25519DSIGN -> String
showsPrec :: Int -> VerKeyDSIGN Ed25519DSIGN -> ShowS
$cshowsPrec :: Int -> VerKeyDSIGN Ed25519DSIGN -> ShowS
Show, VerKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN -> Bool
$c/= :: VerKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN -> Bool
== :: VerKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN -> Bool
$c== :: VerKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN -> Bool
Eq, forall x.
Rep (VerKeyDSIGN Ed25519DSIGN) x -> VerKeyDSIGN Ed25519DSIGN
forall x.
VerKeyDSIGN Ed25519DSIGN -> Rep (VerKeyDSIGN Ed25519DSIGN) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep (VerKeyDSIGN Ed25519DSIGN) x -> VerKeyDSIGN Ed25519DSIGN
$cfrom :: forall x.
VerKeyDSIGN Ed25519DSIGN -> Rep (VerKeyDSIGN Ed25519DSIGN) x
Generic)
deriving newtype VerKeyDSIGN Ed25519DSIGN -> ()
forall a. (a -> ()) -> NFData a
rnf :: VerKeyDSIGN Ed25519DSIGN -> ()
$crnf :: VerKeyDSIGN Ed25519DSIGN -> ()
NFData
newtype SignKeyDSIGN Ed25519DSIGN = SignKeyEd25519DSIGN (PinnedSizedBytes CRYPTO_SIGN_ED25519_SECRETKEYBYTES)
deriving (Int -> SignKeyDSIGN Ed25519DSIGN -> ShowS
[SignKeyDSIGN Ed25519DSIGN] -> ShowS
SignKeyDSIGN Ed25519DSIGN -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignKeyDSIGN Ed25519DSIGN] -> ShowS
$cshowList :: [SignKeyDSIGN Ed25519DSIGN] -> ShowS
show :: SignKeyDSIGN Ed25519DSIGN -> String
$cshow :: SignKeyDSIGN Ed25519DSIGN -> String
showsPrec :: Int -> SignKeyDSIGN Ed25519DSIGN -> ShowS
$cshowsPrec :: Int -> SignKeyDSIGN Ed25519DSIGN -> ShowS
Show, SignKeyDSIGN Ed25519DSIGN -> SignKeyDSIGN Ed25519DSIGN -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignKeyDSIGN Ed25519DSIGN -> SignKeyDSIGN Ed25519DSIGN -> Bool
$c/= :: SignKeyDSIGN Ed25519DSIGN -> SignKeyDSIGN Ed25519DSIGN -> Bool
== :: SignKeyDSIGN Ed25519DSIGN -> SignKeyDSIGN Ed25519DSIGN -> Bool
$c== :: SignKeyDSIGN Ed25519DSIGN -> SignKeyDSIGN Ed25519DSIGN -> Bool
Eq, forall x.
Rep (SignKeyDSIGN Ed25519DSIGN) x -> SignKeyDSIGN Ed25519DSIGN
forall x.
SignKeyDSIGN Ed25519DSIGN -> Rep (SignKeyDSIGN Ed25519DSIGN) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep (SignKeyDSIGN Ed25519DSIGN) x -> SignKeyDSIGN Ed25519DSIGN
$cfrom :: forall x.
SignKeyDSIGN Ed25519DSIGN -> Rep (SignKeyDSIGN Ed25519DSIGN) x
Generic)
deriving newtype SignKeyDSIGN Ed25519DSIGN -> ()
forall a. (a -> ()) -> NFData a
rnf :: SignKeyDSIGN Ed25519DSIGN -> ()
$crnf :: SignKeyDSIGN Ed25519DSIGN -> ()
NFData
newtype SigDSIGN Ed25519DSIGN = SigEd25519DSIGN (PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN))
deriving (Int -> SigDSIGN Ed25519DSIGN -> ShowS
[SigDSIGN Ed25519DSIGN] -> ShowS
SigDSIGN Ed25519DSIGN -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigDSIGN Ed25519DSIGN] -> ShowS
$cshowList :: [SigDSIGN Ed25519DSIGN] -> ShowS
show :: SigDSIGN Ed25519DSIGN -> String
$cshow :: SigDSIGN Ed25519DSIGN -> String
showsPrec :: Int -> SigDSIGN Ed25519DSIGN -> ShowS
$cshowsPrec :: Int -> SigDSIGN Ed25519DSIGN -> ShowS
Show, SigDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SigDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN -> Bool
$c/= :: SigDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN -> Bool
== :: SigDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN -> Bool
$c== :: SigDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN -> Bool
Eq, forall x. Rep (SigDSIGN Ed25519DSIGN) x -> SigDSIGN Ed25519DSIGN
forall x. SigDSIGN Ed25519DSIGN -> Rep (SigDSIGN Ed25519DSIGN) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep (SigDSIGN Ed25519DSIGN) x -> SigDSIGN Ed25519DSIGN
$cfrom :: forall x. SigDSIGN Ed25519DSIGN -> Rep (SigDSIGN Ed25519DSIGN) x
Generic)
deriving newtype SigDSIGN Ed25519DSIGN -> ()
forall a. (a -> ()) -> NFData a
rnf :: SigDSIGN Ed25519DSIGN -> ()
$crnf :: SigDSIGN Ed25519DSIGN -> ()
NFData
algorithmNameDSIGN :: forall (proxy :: * -> *). proxy Ed25519DSIGN -> String
algorithmNameDSIGN proxy Ed25519DSIGN
_ = String
"ed25519"
deriveVerKeyDSIGN :: SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
deriveVerKeyDSIGN (SignKeyEd25519DSIGN PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk) =
PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
-> VerKeyDSIGN Ed25519DSIGN
VerKeyEd25519DSIGN forall a b. (a -> b) -> a -> b
$
forall a. IO a -> a
unsafeDupablePerformIO forall a b. (a -> b) -> a -> b
$
forall (n :: Nat) r.
PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
psbUseAsSizedPtr PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr ->
forall (n :: Nat).
KnownNat n =>
(SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n)
psbCreateSized forall a b. (a -> b) -> a -> b
$ \SizedPtr (SizeVerKeyDSIGN Ed25519DSIGN)
pkPtr ->
String -> String -> IO Int -> IO ()
cOrError String
"deriveVerKeyDSIGN @Ed25519DSIGN" String
"c_crypto_sign_ed25519_sk_to_pk"
forall a b. (a -> b) -> a -> b
$ SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> SizedPtr CRYPTO_SIGN_ED25519_BYTES -> IO Int
c_crypto_sign_ed25519_sk_to_pk SizedPtr (SizeVerKeyDSIGN Ed25519DSIGN)
pkPtr SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr
type Signable Ed25519DSIGN = SignableRepresentation
signDSIGN :: forall a.
(Signable Ed25519DSIGN a, HasCallStack) =>
ContextDSIGN Ed25519DSIGN
-> a -> SignKeyDSIGN Ed25519DSIGN -> SigDSIGN Ed25519DSIGN
signDSIGN () a
a (SignKeyEd25519DSIGN PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk) =
let bs :: ByteString
bs = forall a. SignableRepresentation a => a -> ByteString
getSignableRepresentation a
a
in PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
-> SigDSIGN Ed25519DSIGN
SigEd25519DSIGN forall a b. (a -> b) -> a -> b
$ forall a. IO a -> a
unsafeDupablePerformIO forall a b. (a -> b) -> a -> b
$
forall a. ByteString -> (CStringLen -> IO a) -> IO a
BS.useAsCStringLen ByteString
bs forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
ptr, Int
len) ->
forall (n :: Nat) r.
PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
psbUseAsSizedPtr PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr ->
forall (n :: Nat) b. KnownNat n => (SizedPtr n -> IO b) -> IO b
allocaSized forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
pkPtr -> do
String -> String -> IO Int -> IO ()
cOrError String
"signDSIGN @Ed25519DSIGN" String
"c_crypto_sign_ed25519_sk_to_pk"
forall a b. (a -> b) -> a -> b
$ SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> SizedPtr CRYPTO_SIGN_ED25519_BYTES -> IO Int
c_crypto_sign_ed25519_sk_to_pk SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
pkPtr SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr
forall (n :: Nat).
KnownNat n =>
(SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n)
psbCreateSized forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
sigPtr -> do
String -> String -> IO Int -> IO ()
cOrError String
"signDSIGN @Ed25519DSIGN" String
"c_crypto_sign_ed25519_detached"
forall a b. (a -> b) -> a -> b
$ SizedPtr CRYPTO_SIGN_ED25519_BYTES
-> Ptr CULLong
-> Ptr CUChar
-> CULLong
-> SizedPtr CRYPTO_SIGN_ED25519_BYTES
-> IO Int
c_crypto_sign_ed25519_detached SizedPtr CRYPTO_SIGN_ED25519_BYTES
sigPtr forall a. Ptr a
nullPtr (forall a b. Ptr a -> Ptr b
castPtr Ptr CChar
ptr) (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len) SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr
verifyDSIGN :: forall a.
(Signable Ed25519DSIGN a, HasCallStack) =>
ContextDSIGN Ed25519DSIGN
-> VerKeyDSIGN Ed25519DSIGN
-> a
-> SigDSIGN Ed25519DSIGN
-> Either String ()
verifyDSIGN () (VerKeyEd25519DSIGN PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
vk) a
a (SigEd25519DSIGN PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
sig) =
let bs :: ByteString
bs = forall a. SignableRepresentation a => a -> ByteString
getSignableRepresentation a
a
in forall a. IO a -> a
unsafeDupablePerformIO forall a b. (a -> b) -> a -> b
$
forall a. ByteString -> (CStringLen -> IO a) -> IO a
BS.useAsCStringLen ByteString
bs forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
ptr, Int
len) ->
forall (n :: Nat) r.
PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
psbUseAsSizedPtr PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
vk forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
vkPtr ->
forall (n :: Nat) r.
PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
psbUseAsSizedPtr PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
sig forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
sigPtr -> do
Int
res <- SizedPtr CRYPTO_SIGN_ED25519_BYTES
-> Ptr CUChar
-> CULLong
-> SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> IO Int
c_crypto_sign_ed25519_verify_detached SizedPtr CRYPTO_SIGN_ED25519_BYTES
sigPtr (forall a b. Ptr a -> Ptr b
castPtr Ptr CChar
ptr) (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len) SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
vkPtr
if Int
res forall a. Eq a => a -> a -> Bool
== Int
0
then forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. b -> Either a b
Right ())
else do
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. a -> Either a b
Left String
"Verification failed")
genKeyDSIGN :: Seed -> SignKeyDSIGN Ed25519DSIGN
genKeyDSIGN Seed
seed = PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
-> SignKeyDSIGN Ed25519DSIGN
SignKeyEd25519DSIGN forall a b. (a -> b) -> a -> b
$
let (ByteString
sb, Seed
_) = Word -> Seed -> (ByteString, Seed)
getBytesFromSeedT (forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
seedSizeDSIGN (forall {k} (t :: k). Proxy t
Proxy @Ed25519DSIGN)) Seed
seed
in forall a. IO a -> a
unsafeDupablePerformIO forall a b. (a -> b) -> a -> b
$ do
forall (n :: Nat).
KnownNat n =>
(SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n)
psbCreateSized forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr ->
forall a. ByteString -> (CStringLen -> IO a) -> IO a
BS.useAsCStringLen ByteString
sb forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
seedPtr, Int
_) ->
forall (n :: Nat) b. KnownNat n => (SizedPtr n -> IO b) -> IO b
allocaSized forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
pkPtr -> do
String -> String -> IO Int -> IO ()
cOrError String
"genKeyDSIGN @Ed25519DSIGN" String
"c_crypto_sign_ed25519_seed_keypair"
forall a b. (a -> b) -> a -> b
$ SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> SizedPtr CRYPTO_SIGN_ED25519_BYTES
-> SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> IO Int
c_crypto_sign_ed25519_seed_keypair SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
pkPtr SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr (forall (n :: Nat). Ptr Void -> SizedPtr n
SizedPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Ptr a -> Ptr b
castPtr forall a b. (a -> b) -> a -> b
$ Ptr CChar
seedPtr)
rawSerialiseVerKeyDSIGN :: VerKeyDSIGN Ed25519DSIGN -> ByteString
rawSerialiseVerKeyDSIGN (VerKeyEd25519DSIGN PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
vk) = forall (n :: Nat). PinnedSizedBytes n -> ByteString
psbToByteString PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
vk
rawSerialiseSignKeyDSIGN :: SignKeyDSIGN Ed25519DSIGN -> ByteString
rawSerialiseSignKeyDSIGN (SignKeyEd25519DSIGN PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk) =
forall (n :: Nat). PinnedSizedBytes n -> ByteString
psbToByteString @(SeedSizeDSIGN Ed25519DSIGN) forall a b. (a -> b) -> a -> b
$ forall a. IO a -> a
unsafeDupablePerformIO forall a b. (a -> b) -> a -> b
$ do
forall (n :: Nat).
KnownNat n =>
(SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n)
psbCreateSized forall a b. (a -> b) -> a -> b
$ \SizedPtr (SeedSizeDSIGN Ed25519DSIGN)
seedPtr ->
forall (n :: Nat) r.
PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
psbUseAsSizedPtr PinnedSizedBytes CRYPTO_SIGN_ED25519_BYTES
sk forall a b. (a -> b) -> a -> b
$ \SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr ->
String -> String -> IO Int -> IO ()
cOrError String
"deriveVerKeyDSIGN @Ed25519DSIGN" String
"c_crypto_sign_ed25519_sk_to_seed"
forall a b. (a -> b) -> a -> b
$ SizedPtr CRYPTO_SIGN_ED25519_PUBLICKEYBYTES
-> SizedPtr CRYPTO_SIGN_ED25519_BYTES -> IO Int
c_crypto_sign_ed25519_sk_to_seed SizedPtr (SeedSizeDSIGN Ed25519DSIGN)
seedPtr SizedPtr CRYPTO_SIGN_ED25519_BYTES
skPtr
rawSerialiseSigDSIGN :: SigDSIGN Ed25519DSIGN -> ByteString
rawSerialiseSigDSIGN (SigEd25519DSIGN PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
sig) = forall (n :: Nat). PinnedSizedBytes n -> ByteString
psbToByteString PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
sig
rawDeserialiseVerKeyDSIGN :: ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
rawDeserialiseVerKeyDSIGN = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PinnedSizedBytes (SizeVerKeyDSIGN Ed25519DSIGN)
-> VerKeyDSIGN Ed25519DSIGN
VerKeyEd25519DSIGN forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: Nat).
KnownNat n =>
ByteString -> Maybe (PinnedSizedBytes n)
psbFromByteStringCheck
rawDeserialiseSignKeyDSIGN :: ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
rawDeserialiseSignKeyDSIGN = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
genKeyDSIGN forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Seed
mkSeedFromBytes
rawDeserialiseSigDSIGN :: ByteString -> Maybe (SigDSIGN Ed25519DSIGN)
rawDeserialiseSigDSIGN = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PinnedSizedBytes (SizeSigDSIGN Ed25519DSIGN)
-> SigDSIGN Ed25519DSIGN
SigEd25519DSIGN forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: Nat).
KnownNat n =>
ByteString -> Maybe (PinnedSizedBytes n)
psbFromByteStringCheck
instance ToCBOR (VerKeyDSIGN Ed25519DSIGN) where
toCBOR :: VerKeyDSIGN Ed25519DSIGN -> Encoding
toCBOR = forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> Encoding
encodeVerKeyDSIGN
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerKeyDSIGN Ed25519DSIGN) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_ = forall v. DSIGNAlgorithm v => Proxy (VerKeyDSIGN v) -> Size
encodedVerKeyDSIGNSizeExpr
instance FromCBOR (VerKeyDSIGN Ed25519DSIGN) where
fromCBOR :: forall s. Decoder s (VerKeyDSIGN Ed25519DSIGN)
fromCBOR = forall v s. DSIGNAlgorithm v => Decoder s (VerKeyDSIGN v)
decodeVerKeyDSIGN
instance ToCBOR (SignKeyDSIGN Ed25519DSIGN) where
toCBOR :: SignKeyDSIGN Ed25519DSIGN -> Encoding
toCBOR = forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> Encoding
encodeSignKeyDSIGN
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SignKeyDSIGN Ed25519DSIGN) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_ = forall v. DSIGNAlgorithm v => Proxy (SignKeyDSIGN v) -> Size
encodedSignKeyDESIGNSizeExpr
instance FromCBOR (SignKeyDSIGN Ed25519DSIGN) where
fromCBOR :: forall s. Decoder s (SignKeyDSIGN Ed25519DSIGN)
fromCBOR = forall v s. DSIGNAlgorithm v => Decoder s (SignKeyDSIGN v)
decodeSignKeyDSIGN
instance ToCBOR (SigDSIGN Ed25519DSIGN) where
toCBOR :: SigDSIGN Ed25519DSIGN -> Encoding
toCBOR = forall v. DSIGNAlgorithm v => SigDSIGN v -> Encoding
encodeSigDSIGN
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigDSIGN Ed25519DSIGN) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_ = forall v. DSIGNAlgorithm v => Proxy (SigDSIGN v) -> Size
encodedSigDSIGNSizeExpr
instance FromCBOR (SigDSIGN Ed25519DSIGN) where
fromCBOR :: forall s. Decoder s (SigDSIGN Ed25519DSIGN)
fromCBOR = forall v s. DSIGNAlgorithm v => Decoder s (SigDSIGN v)
decodeSigDSIGN