{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneKindSignatures #-}
module Cardano.Crypto.Signing.Redeem.SigningKey (
RedeemSigningKey (..),
redeemToVerification,
) where
import Cardano.Crypto.Signing.Redeem.VerificationKey (
RedeemVerificationKey (..),
redeemVKB64F,
)
import Cardano.Ledger.Binary (
DecCBOR,
EncCBOR,
FromCBOR (..),
ToCBOR (..),
fromByronCBOR,
toByronCBOR,
)
import Cardano.Prelude
import qualified Crypto.PubKey.Ed25519 as Ed25519
import Formatting (bprint)
import qualified Formatting.Buildable as B
import NoThunks.Class (InspectHeap (..), NoThunks (..))
type RedeemSigningKey :: Type
newtype RedeemSigningKey
= RedeemSigningKey Ed25519.SecretKey
deriving (RedeemSigningKey -> RedeemSigningKey -> Bool
(RedeemSigningKey -> RedeemSigningKey -> Bool)
-> (RedeemSigningKey -> RedeemSigningKey -> Bool)
-> Eq RedeemSigningKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RedeemSigningKey -> RedeemSigningKey -> Bool
== :: RedeemSigningKey -> RedeemSigningKey -> Bool
$c/= :: RedeemSigningKey -> RedeemSigningKey -> Bool
/= :: RedeemSigningKey -> RedeemSigningKey -> Bool
Eq, Int -> RedeemSigningKey -> ShowS
[RedeemSigningKey] -> ShowS
RedeemSigningKey -> String
(Int -> RedeemSigningKey -> ShowS)
-> (RedeemSigningKey -> String)
-> ([RedeemSigningKey] -> ShowS)
-> Show RedeemSigningKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RedeemSigningKey -> ShowS
showsPrec :: Int -> RedeemSigningKey -> ShowS
$cshow :: RedeemSigningKey -> String
show :: RedeemSigningKey -> String
$cshowList :: [RedeemSigningKey] -> ShowS
showList :: [RedeemSigningKey] -> ShowS
Show, (forall x. RedeemSigningKey -> Rep RedeemSigningKey x)
-> (forall x. Rep RedeemSigningKey x -> RedeemSigningKey)
-> Generic RedeemSigningKey
forall x. Rep RedeemSigningKey x -> RedeemSigningKey
forall x. RedeemSigningKey -> Rep RedeemSigningKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RedeemSigningKey -> Rep RedeemSigningKey x
from :: forall x. RedeemSigningKey -> Rep RedeemSigningKey x
$cto :: forall x. Rep RedeemSigningKey x -> RedeemSigningKey
to :: forall x. Rep RedeemSigningKey x -> RedeemSigningKey
Generic, RedeemSigningKey -> ()
(RedeemSigningKey -> ()) -> NFData RedeemSigningKey
forall a. (a -> ()) -> NFData a
$crnf :: RedeemSigningKey -> ()
rnf :: RedeemSigningKey -> ()
NFData, Typeable RedeemSigningKey
Typeable RedeemSigningKey =>
(forall s. Decoder s RedeemSigningKey)
-> (forall s. Proxy RedeemSigningKey -> Decoder s ())
-> (Proxy RedeemSigningKey -> Text)
-> DecCBOR RedeemSigningKey
Proxy RedeemSigningKey -> Text
forall s. Decoder s RedeemSigningKey
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy RedeemSigningKey -> Decoder s ()
$cdecCBOR :: forall s. Decoder s RedeemSigningKey
decCBOR :: forall s. Decoder s RedeemSigningKey
$cdropCBOR :: forall s. Proxy RedeemSigningKey -> Decoder s ()
dropCBOR :: forall s. Proxy RedeemSigningKey -> Decoder s ()
$clabel :: Proxy RedeemSigningKey -> Text
label :: Proxy RedeemSigningKey -> Text
DecCBOR, Typeable RedeemSigningKey
Typeable RedeemSigningKey =>
(RedeemSigningKey -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy RedeemSigningKey -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [RedeemSigningKey] -> Size)
-> EncCBOR RedeemSigningKey
RedeemSigningKey -> Encoding
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [RedeemSigningKey] -> Size
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy RedeemSigningKey -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> EncCBOR a
$cencCBOR :: RedeemSigningKey -> Encoding
encCBOR :: RedeemSigningKey -> Encoding
$cencodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy RedeemSigningKey -> Size
encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy RedeemSigningKey -> Size
$cencodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [RedeemSigningKey] -> Size
encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [RedeemSigningKey] -> Size
EncCBOR)
deriving (Context -> RedeemSigningKey -> IO (Maybe ThunkInfo)
Proxy RedeemSigningKey -> String
(Context -> RedeemSigningKey -> IO (Maybe ThunkInfo))
-> (Context -> RedeemSigningKey -> IO (Maybe ThunkInfo))
-> (Proxy RedeemSigningKey -> String)
-> NoThunks RedeemSigningKey
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> RedeemSigningKey -> IO (Maybe ThunkInfo)
noThunks :: Context -> RedeemSigningKey -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> RedeemSigningKey -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> RedeemSigningKey -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy RedeemSigningKey -> String
showTypeOf :: Proxy RedeemSigningKey -> String
NoThunks) via InspectHeap RedeemSigningKey
instance ToCBOR RedeemSigningKey where
toCBOR :: RedeemSigningKey -> Encoding
toCBOR = RedeemSigningKey -> Encoding
forall a. EncCBOR a => a -> Encoding
toByronCBOR
instance FromCBOR RedeemSigningKey where
fromCBOR :: forall s. Decoder s RedeemSigningKey
fromCBOR = Decoder s RedeemSigningKey
forall a s. DecCBOR a => Decoder s a
fromByronCBOR
instance B.Buildable RedeemSigningKey where
build :: RedeemSigningKey -> Builder
build = Format Builder (RedeemVerificationKey -> Builder)
-> RedeemVerificationKey -> Builder
forall a. Format Builder a -> a
bprint (Format
(RedeemVerificationKey -> Builder)
(RedeemVerificationKey -> Builder)
"redeem_sec_of_vk:" Format
(RedeemVerificationKey -> Builder)
(RedeemVerificationKey -> Builder)
-> Format Builder (RedeemVerificationKey -> Builder)
-> Format Builder (RedeemVerificationKey -> Builder)
forall b c a. Format b c -> Format a b -> Format a c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Format Builder (RedeemVerificationKey -> Builder)
forall r. Format r (RedeemVerificationKey -> r)
redeemVKB64F) (RedeemVerificationKey -> Builder)
-> (RedeemSigningKey -> RedeemVerificationKey)
-> RedeemSigningKey
-> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. RedeemSigningKey -> RedeemVerificationKey
redeemToVerification
redeemToVerification :: RedeemSigningKey -> RedeemVerificationKey
redeemToVerification :: RedeemSigningKey -> RedeemVerificationKey
redeemToVerification (RedeemSigningKey SecretKey
k) = PublicKey -> RedeemVerificationKey
RedeemVerificationKey (SecretKey -> PublicKey
Ed25519.toPublic SecretKey
k)