{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Cardano.Api.KeysPraos (
KesKey
, VrfKey
, AsType (..)
, Hash (..)
, SigningKey (..)
, VerificationKey (..)
) where
import Cardano.Api.Any
import Cardano.Api.Key
import Cardano.Api.SerialiseTextEnvelope
import Cardano.Api.SerialiseUsing
import qualified Cardano.Crypto.DSIGN.Class as Crypto
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.KES.Class as Crypto
import qualified Cardano.Crypto.VRF.Class as Crypto
import Cardano.Ledger.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Crypto as Shelley (KES, VRF)
import qualified Cardano.Ledger.Keys as Shelley
import Data.String (IsString (..))
data KesKey
instance HasTypeProxy KesKey where
data AsType KesKey = AsKesKey
proxyToAsType :: Proxy KesKey -> AsType KesKey
proxyToAsType Proxy KesKey
_ = AsType KesKey
AsKesKey
instance Key KesKey where
newtype VerificationKey KesKey =
KesVerificationKey (Shelley.VerKeyKES StandardCrypto)
deriving stock (VerificationKey KesKey -> VerificationKey KesKey -> Bool
(VerificationKey KesKey -> VerificationKey KesKey -> Bool)
-> (VerificationKey KesKey -> VerificationKey KesKey -> Bool)
-> Eq (VerificationKey KesKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
== :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
$c/= :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
/= :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
Eq)
deriving (Int -> VerificationKey KesKey -> ShowS
[VerificationKey KesKey] -> ShowS
VerificationKey KesKey -> String
(Int -> VerificationKey KesKey -> ShowS)
-> (VerificationKey KesKey -> String)
-> ([VerificationKey KesKey] -> ShowS)
-> Show (VerificationKey KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerificationKey KesKey -> ShowS
showsPrec :: Int -> VerificationKey KesKey -> ShowS
$cshow :: VerificationKey KesKey -> String
show :: VerificationKey KesKey -> String
$cshowList :: [VerificationKey KesKey] -> ShowS
showList :: [VerificationKey KesKey] -> ShowS
Show, String -> VerificationKey KesKey
(String -> VerificationKey KesKey)
-> IsString (VerificationKey KesKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> VerificationKey KesKey
fromString :: String -> VerificationKey KesKey
IsString) via UsingRawBytesHex (VerificationKey KesKey)
deriving newtype (Typeable (VerificationKey KesKey)
Typeable (VerificationKey KesKey) =>
(VerificationKey KesKey -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size)
-> EncCBOR (VerificationKey KesKey)
VerificationKey KesKey -> Encoding
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> 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 :: VerificationKey KesKey -> Encoding
encCBOR :: VerificationKey KesKey -> Encoding
$cencodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
$cencodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
EncCBOR, Typeable (VerificationKey KesKey)
Typeable (VerificationKey KesKey) =>
(forall s. Decoder s (VerificationKey KesKey))
-> (forall s. Proxy (VerificationKey KesKey) -> Decoder s ())
-> (Proxy (VerificationKey KesKey) -> Text)
-> DecCBOR (VerificationKey KesKey)
Proxy (VerificationKey KesKey) -> Text
forall s. Decoder s (VerificationKey KesKey)
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy (VerificationKey KesKey) -> Decoder s ()
$cdecCBOR :: forall s. Decoder s (VerificationKey KesKey)
decCBOR :: forall s. Decoder s (VerificationKey KesKey)
$cdropCBOR :: forall s. Proxy (VerificationKey KesKey) -> Decoder s ()
dropCBOR :: forall s. Proxy (VerificationKey KesKey) -> Decoder s ()
$clabel :: Proxy (VerificationKey KesKey) -> Text
label :: Proxy (VerificationKey KesKey) -> Text
DecCBOR, Typeable (VerificationKey KesKey)
Typeable (VerificationKey KesKey) =>
(VerificationKey KesKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size)
-> ToCBOR (VerificationKey KesKey)
VerificationKey KesKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: VerificationKey KesKey -> Encoding
toCBOR :: VerificationKey KesKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
ToCBOR, Typeable (VerificationKey KesKey)
Typeable (VerificationKey KesKey) =>
(forall s. Decoder s (VerificationKey KesKey))
-> (Proxy (VerificationKey KesKey) -> Text)
-> FromCBOR (VerificationKey KesKey)
Proxy (VerificationKey KesKey) -> Text
forall s. Decoder s (VerificationKey KesKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (VerificationKey KesKey)
fromCBOR :: forall s. Decoder s (VerificationKey KesKey)
$clabel :: Proxy (VerificationKey KesKey) -> Text
label :: Proxy (VerificationKey KesKey) -> Text
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey KesKey)
HasTypeProxy (VerificationKey KesKey) =>
(VerificationKey KesKey -> ByteString)
-> (AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey))
-> SerialiseAsCBOR (VerificationKey KesKey)
AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
VerificationKey KesKey -> ByteString
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: VerificationKey KesKey -> ByteString
serialiseToCBOR :: VerificationKey KesKey -> ByteString
$cdeserialiseFromCBOR :: AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
deserialiseFromCBOR :: AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
SerialiseAsCBOR
newtype SigningKey KesKey =
KesSigningKey (Shelley.SignKeyKES StandardCrypto)
deriving (Int -> SigningKey KesKey -> ShowS
[SigningKey KesKey] -> ShowS
SigningKey KesKey -> String
(Int -> SigningKey KesKey -> ShowS)
-> (SigningKey KesKey -> String)
-> ([SigningKey KesKey] -> ShowS)
-> Show (SigningKey KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SigningKey KesKey -> ShowS
showsPrec :: Int -> SigningKey KesKey -> ShowS
$cshow :: SigningKey KesKey -> String
show :: SigningKey KesKey -> String
$cshowList :: [SigningKey KesKey] -> ShowS
showList :: [SigningKey KesKey] -> ShowS
Show, String -> SigningKey KesKey
(String -> SigningKey KesKey) -> IsString (SigningKey KesKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> SigningKey KesKey
fromString :: String -> SigningKey KesKey
IsString) via UsingRawBytesHex (SigningKey KesKey)
deriving newtype (Typeable (SigningKey KesKey)
Typeable (SigningKey KesKey) =>
(SigningKey KesKey -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size)
-> EncCBOR (SigningKey KesKey)
SigningKey KesKey -> Encoding
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> 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 :: SigningKey KesKey -> Encoding
encCBOR :: SigningKey KesKey -> Encoding
$cencodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
$cencodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
EncCBOR, Typeable (SigningKey KesKey)
Typeable (SigningKey KesKey) =>
(forall s. Decoder s (SigningKey KesKey))
-> (forall s. Proxy (SigningKey KesKey) -> Decoder s ())
-> (Proxy (SigningKey KesKey) -> Text)
-> DecCBOR (SigningKey KesKey)
Proxy (SigningKey KesKey) -> Text
forall s. Decoder s (SigningKey KesKey)
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy (SigningKey KesKey) -> Decoder s ()
$cdecCBOR :: forall s. Decoder s (SigningKey KesKey)
decCBOR :: forall s. Decoder s (SigningKey KesKey)
$cdropCBOR :: forall s. Proxy (SigningKey KesKey) -> Decoder s ()
dropCBOR :: forall s. Proxy (SigningKey KesKey) -> Decoder s ()
$clabel :: Proxy (SigningKey KesKey) -> Text
label :: Proxy (SigningKey KesKey) -> Text
DecCBOR, Typeable (SigningKey KesKey)
Typeable (SigningKey KesKey) =>
(SigningKey KesKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size)
-> ToCBOR (SigningKey KesKey)
SigningKey KesKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: SigningKey KesKey -> Encoding
toCBOR :: SigningKey KesKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
ToCBOR, Typeable (SigningKey KesKey)
Typeable (SigningKey KesKey) =>
(forall s. Decoder s (SigningKey KesKey))
-> (Proxy (SigningKey KesKey) -> Text)
-> FromCBOR (SigningKey KesKey)
Proxy (SigningKey KesKey) -> Text
forall s. Decoder s (SigningKey KesKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (SigningKey KesKey)
fromCBOR :: forall s. Decoder s (SigningKey KesKey)
$clabel :: Proxy (SigningKey KesKey) -> Text
label :: Proxy (SigningKey KesKey) -> Text
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey KesKey)
HasTypeProxy (SigningKey KesKey) =>
(SigningKey KesKey -> ByteString)
-> (AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey))
-> SerialiseAsCBOR (SigningKey KesKey)
AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
SigningKey KesKey -> ByteString
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: SigningKey KesKey -> ByteString
serialiseToCBOR :: SigningKey KesKey -> ByteString
$cdeserialiseFromCBOR :: AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
deserialiseFromCBOR :: AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType KesKey -> Crypto.Seed -> SigningKey KesKey
deterministicSigningKey :: AsType KesKey -> Seed -> SigningKey KesKey
deterministicSigningKey AsType KesKey
R:AsTypeKesKey
AsKesKey =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> SigningKey KesKey
SignKeyKES StandardCrypto -> SigningKey KesKey
KesSigningKey (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> SigningKey KesKey)
-> (Seed -> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Seed
-> SigningKey KesKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seed -> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
forall v. KESAlgorithm v => Seed -> SignKeyKES v
Crypto.genKeyKES
deterministicSigningKeySeedSize :: AsType KesKey -> Word
deterministicSigningKeySeedSize :: AsType KesKey -> Word
deterministicSigningKeySeedSize AsType KesKey
R:AsTypeKesKey
AsKesKey =
Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> Word
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Word
forall (proxy :: * -> *).
proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> Word
Crypto.seedSizeKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey KesKey -> VerificationKey KesKey
getVerificationKey :: SigningKey KesKey -> VerificationKey KesKey
getVerificationKey (KesSigningKey SignKeyKES StandardCrypto
sk) =
VerKeyKES StandardCrypto -> VerificationKey KesKey
KesVerificationKey (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
forall v. KESAlgorithm v => SignKeyKES v -> VerKeyKES v
Crypto.deriveVerKeyKES SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
SignKeyKES StandardCrypto
sk)
verificationKeyHash :: VerificationKey KesKey -> Hash KesKey
verificationKeyHash :: VerificationKey KesKey -> Hash KesKey
verificationKeyHash (KesVerificationKey VerKeyKES StandardCrypto
vkey) =
Hash StandardCrypto (VerKeyKES StandardCrypto) -> Hash KesKey
KesKeyHash (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall h.
HashAlgorithm h =>
VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> Hash h (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v h.
(KESAlgorithm v, HashAlgorithm h) =>
VerKeyKES v -> Hash h (VerKeyKES v)
Crypto.hashVerKeyKES VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
VerKeyKES StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey KesKey) where
serialiseToRawBytes :: VerificationKey KesKey -> ByteString
serialiseToRawBytes (KesVerificationKey VerKeyKES StandardCrypto
vk) =
VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> ByteString
forall v. KESAlgorithm v => VerKeyKES v -> ByteString
Crypto.rawSerialiseVerKeyKES VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
VerKeyKES StandardCrypto
vk
deserialiseFromRawBytes :: AsType (VerificationKey KesKey)
-> ByteString -> Maybe (VerificationKey KesKey)
deserialiseFromRawBytes (AsVerificationKey AsType KesKey
R:AsTypeKesKey
AsKesKey) ByteString
bs =
VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerificationKey KesKey
VerKeyKES StandardCrypto -> VerificationKey KesKey
KesVerificationKey (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerificationKey KesKey)
-> Maybe (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Maybe (VerificationKey KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
Crypto.rawDeserialiseVerKeyKES ByteString
bs
instance SerialiseAsRawBytes (SigningKey KesKey) where
serialiseToRawBytes :: SigningKey KesKey -> ByteString
serialiseToRawBytes (KesSigningKey SignKeyKES StandardCrypto
sk) =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> ByteString
forall v. KESAlgorithm v => SignKeyKES v -> ByteString
Crypto.rawSerialiseSignKeyKES SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
SignKeyKES StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey KesKey)
-> ByteString -> Maybe (SigningKey KesKey)
deserialiseFromRawBytes (AsSigningKey AsType KesKey
R:AsTypeKesKey
AsKesKey) ByteString
bs =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> SigningKey KesKey
SignKeyKES StandardCrypto -> SigningKey KesKey
KesSigningKey (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> SigningKey KesKey)
-> Maybe (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Maybe (SigningKey KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v. KESAlgorithm v => ByteString -> Maybe (SignKeyKES v)
Crypto.rawDeserialiseSignKeyKES ByteString
bs
instance SerialiseAsBech32 (VerificationKey KesKey) where
bech32PrefixFor :: VerificationKey KesKey -> Text
bech32PrefixFor VerificationKey KesKey
_ = Text
"kes_vk"
bech32PrefixesPermitted :: AsType (VerificationKey KesKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey KesKey)
_ = [Text
"kes_vk"]
instance SerialiseAsBech32 (SigningKey KesKey) where
bech32PrefixFor :: SigningKey KesKey -> Text
bech32PrefixFor SigningKey KesKey
_ = Text
"kes_sk"
bech32PrefixesPermitted :: AsType (SigningKey KesKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey KesKey)
_ = [Text
"kes_sk"]
newtype instance Hash KesKey =
KesKeyHash (Shelley.Hash StandardCrypto
(Shelley.VerKeyKES StandardCrypto))
deriving stock (Hash KesKey -> Hash KesKey -> Bool
(Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool) -> Eq (Hash KesKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hash KesKey -> Hash KesKey -> Bool
== :: Hash KesKey -> Hash KesKey -> Bool
$c/= :: Hash KesKey -> Hash KesKey -> Bool
/= :: Hash KesKey -> Hash KesKey -> Bool
Eq, Eq (Hash KesKey)
Eq (Hash KesKey) =>
(Hash KesKey -> Hash KesKey -> Ordering)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Hash KesKey)
-> (Hash KesKey -> Hash KesKey -> Hash KesKey)
-> Ord (Hash KesKey)
Hash KesKey -> Hash KesKey -> Bool
Hash KesKey -> Hash KesKey -> Ordering
Hash KesKey -> Hash KesKey -> Hash KesKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Hash KesKey -> Hash KesKey -> Ordering
compare :: Hash KesKey -> Hash KesKey -> Ordering
$c< :: Hash KesKey -> Hash KesKey -> Bool
< :: Hash KesKey -> Hash KesKey -> Bool
$c<= :: Hash KesKey -> Hash KesKey -> Bool
<= :: Hash KesKey -> Hash KesKey -> Bool
$c> :: Hash KesKey -> Hash KesKey -> Bool
> :: Hash KesKey -> Hash KesKey -> Bool
$c>= :: Hash KesKey -> Hash KesKey -> Bool
>= :: Hash KesKey -> Hash KesKey -> Bool
$cmax :: Hash KesKey -> Hash KesKey -> Hash KesKey
max :: Hash KesKey -> Hash KesKey -> Hash KesKey
$cmin :: Hash KesKey -> Hash KesKey -> Hash KesKey
min :: Hash KesKey -> Hash KesKey -> Hash KesKey
Ord)
deriving (Int -> Hash KesKey -> ShowS
[Hash KesKey] -> ShowS
Hash KesKey -> String
(Int -> Hash KesKey -> ShowS)
-> (Hash KesKey -> String)
-> ([Hash KesKey] -> ShowS)
-> Show (Hash KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hash KesKey -> ShowS
showsPrec :: Int -> Hash KesKey -> ShowS
$cshow :: Hash KesKey -> String
show :: Hash KesKey -> String
$cshowList :: [Hash KesKey] -> ShowS
showList :: [Hash KesKey] -> ShowS
Show, String -> Hash KesKey
(String -> Hash KesKey) -> IsString (Hash KesKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> Hash KesKey
fromString :: String -> Hash KesKey
IsString) via UsingRawBytesHex (Hash KesKey)
deriving (Typeable (Hash KesKey)
Typeable (Hash KesKey) =>
(Hash KesKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash KesKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash KesKey] -> Size)
-> ToCBOR (Hash KesKey)
Hash KesKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash KesKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash KesKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: Hash KesKey -> Encoding
toCBOR :: Hash KesKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash KesKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash KesKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash KesKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash KesKey] -> Size
ToCBOR, Typeable (Hash KesKey)
Typeable (Hash KesKey) =>
(forall s. Decoder s (Hash KesKey))
-> (Proxy (Hash KesKey) -> Text) -> FromCBOR (Hash KesKey)
Proxy (Hash KesKey) -> Text
forall s. Decoder s (Hash KesKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (Hash KesKey)
fromCBOR :: forall s. Decoder s (Hash KesKey)
$clabel :: Proxy (Hash KesKey) -> Text
label :: Proxy (Hash KesKey) -> Text
FromCBOR) via UsingRawBytes (Hash KesKey)
deriving anyclass HasTypeProxy (Hash KesKey)
Hash KesKey -> ByteString
HasTypeProxy (Hash KesKey) =>
(Hash KesKey -> ByteString)
-> (AsType (Hash KesKey)
-> ByteString -> Either DecoderError (Hash KesKey))
-> SerialiseAsCBOR (Hash KesKey)
AsType (Hash KesKey)
-> ByteString -> Either DecoderError (Hash KesKey)
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: Hash KesKey -> ByteString
serialiseToCBOR :: Hash KesKey -> ByteString
$cdeserialiseFromCBOR :: AsType (Hash KesKey)
-> ByteString -> Either DecoderError (Hash KesKey)
deserialiseFromCBOR :: AsType (Hash KesKey)
-> ByteString -> Either DecoderError (Hash KesKey)
SerialiseAsCBOR
instance SerialiseAsRawBytes (Hash KesKey) where
serialiseToRawBytes :: Hash KesKey -> ByteString
serialiseToRawBytes (KesKeyHash Hash StandardCrypto (VerKeyKES StandardCrypto)
vkh) =
Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
Hash StandardCrypto (VerKeyKES StandardCrypto)
vkh
deserialiseFromRawBytes :: AsType (Hash KesKey) -> ByteString -> Maybe (Hash KesKey)
deserialiseFromRawBytes (AsHash AsType KesKey
R:AsTypeKesKey
AsKesKey) ByteString
bs =
Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Hash KesKey
Hash StandardCrypto (VerKeyKES StandardCrypto) -> Hash KesKey
KesKeyHash (Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Hash KesKey)
-> Maybe
(Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)))
-> Maybe (Hash KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString
-> Maybe
(Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey KesKey) where
textEnvelopeType :: AsType (VerificationKey KesKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey KesKey)
_ = TextEnvelopeType
"KesVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> String
forall (proxy :: * -> *).
proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
Crypto.algorithmNameKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey KesKey) where
textEnvelopeType :: AsType (SigningKey KesKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey KesKey)
_ = TextEnvelopeType
"KesSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> String
forall (proxy :: * -> *).
proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
Crypto.algorithmNameKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy
data VrfKey
instance HasTypeProxy VrfKey where
data AsType VrfKey = AsVrfKey
proxyToAsType :: Proxy VrfKey -> AsType VrfKey
proxyToAsType Proxy VrfKey
_ = AsType VrfKey
AsVrfKey
instance Key VrfKey where
newtype VerificationKey VrfKey =
VrfVerificationKey (Shelley.VerKeyVRF StandardCrypto)
deriving stock (VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
(VerificationKey VrfKey -> VerificationKey VrfKey -> Bool)
-> (VerificationKey VrfKey -> VerificationKey VrfKey -> Bool)
-> Eq (VerificationKey VrfKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
== :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
$c/= :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
/= :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
Eq)
deriving (Int -> VerificationKey VrfKey -> ShowS
[VerificationKey VrfKey] -> ShowS
VerificationKey VrfKey -> String
(Int -> VerificationKey VrfKey -> ShowS)
-> (VerificationKey VrfKey -> String)
-> ([VerificationKey VrfKey] -> ShowS)
-> Show (VerificationKey VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerificationKey VrfKey -> ShowS
showsPrec :: Int -> VerificationKey VrfKey -> ShowS
$cshow :: VerificationKey VrfKey -> String
show :: VerificationKey VrfKey -> String
$cshowList :: [VerificationKey VrfKey] -> ShowS
showList :: [VerificationKey VrfKey] -> ShowS
Show, String -> VerificationKey VrfKey
(String -> VerificationKey VrfKey)
-> IsString (VerificationKey VrfKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> VerificationKey VrfKey
fromString :: String -> VerificationKey VrfKey
IsString) via UsingRawBytesHex (VerificationKey VrfKey)
deriving newtype (Typeable (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey) =>
(VerificationKey VrfKey -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size)
-> EncCBOR (VerificationKey VrfKey)
VerificationKey VrfKey -> Encoding
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> 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 :: VerificationKey VrfKey -> Encoding
encCBOR :: VerificationKey VrfKey -> Encoding
$cencodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
$cencodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
EncCBOR, Typeable (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey) =>
(forall s. Decoder s (VerificationKey VrfKey))
-> (forall s. Proxy (VerificationKey VrfKey) -> Decoder s ())
-> (Proxy (VerificationKey VrfKey) -> Text)
-> DecCBOR (VerificationKey VrfKey)
Proxy (VerificationKey VrfKey) -> Text
forall s. Decoder s (VerificationKey VrfKey)
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy (VerificationKey VrfKey) -> Decoder s ()
$cdecCBOR :: forall s. Decoder s (VerificationKey VrfKey)
decCBOR :: forall s. Decoder s (VerificationKey VrfKey)
$cdropCBOR :: forall s. Proxy (VerificationKey VrfKey) -> Decoder s ()
dropCBOR :: forall s. Proxy (VerificationKey VrfKey) -> Decoder s ()
$clabel :: Proxy (VerificationKey VrfKey) -> Text
label :: Proxy (VerificationKey VrfKey) -> Text
DecCBOR, Typeable (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey) =>
(VerificationKey VrfKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size)
-> ToCBOR (VerificationKey VrfKey)
VerificationKey VrfKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: VerificationKey VrfKey -> Encoding
toCBOR :: VerificationKey VrfKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
ToCBOR, Typeable (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey) =>
(forall s. Decoder s (VerificationKey VrfKey))
-> (Proxy (VerificationKey VrfKey) -> Text)
-> FromCBOR (VerificationKey VrfKey)
Proxy (VerificationKey VrfKey) -> Text
forall s. Decoder s (VerificationKey VrfKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (VerificationKey VrfKey)
fromCBOR :: forall s. Decoder s (VerificationKey VrfKey)
$clabel :: Proxy (VerificationKey VrfKey) -> Text
label :: Proxy (VerificationKey VrfKey) -> Text
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey VrfKey)
HasTypeProxy (VerificationKey VrfKey) =>
(VerificationKey VrfKey -> ByteString)
-> (AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey))
-> SerialiseAsCBOR (VerificationKey VrfKey)
AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
VerificationKey VrfKey -> ByteString
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: VerificationKey VrfKey -> ByteString
serialiseToCBOR :: VerificationKey VrfKey -> ByteString
$cdeserialiseFromCBOR :: AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
deserialiseFromCBOR :: AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
SerialiseAsCBOR
newtype SigningKey VrfKey =
VrfSigningKey (Shelley.SignKeyVRF StandardCrypto)
deriving (Int -> SigningKey VrfKey -> ShowS
[SigningKey VrfKey] -> ShowS
SigningKey VrfKey -> String
(Int -> SigningKey VrfKey -> ShowS)
-> (SigningKey VrfKey -> String)
-> ([SigningKey VrfKey] -> ShowS)
-> Show (SigningKey VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SigningKey VrfKey -> ShowS
showsPrec :: Int -> SigningKey VrfKey -> ShowS
$cshow :: SigningKey VrfKey -> String
show :: SigningKey VrfKey -> String
$cshowList :: [SigningKey VrfKey] -> ShowS
showList :: [SigningKey VrfKey] -> ShowS
Show, String -> SigningKey VrfKey
(String -> SigningKey VrfKey) -> IsString (SigningKey VrfKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> SigningKey VrfKey
fromString :: String -> SigningKey VrfKey
IsString) via UsingRawBytesHex (SigningKey VrfKey)
deriving newtype (Typeable (SigningKey VrfKey)
Typeable (SigningKey VrfKey) =>
(SigningKey VrfKey -> Encoding)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size)
-> ((forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size)
-> EncCBOR (SigningKey VrfKey)
SigningKey VrfKey -> Encoding
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
(forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> 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 :: SigningKey VrfKey -> Encoding
encCBOR :: SigningKey VrfKey -> Encoding
$cencodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
$cencodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
encodedListSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
EncCBOR, Typeable (SigningKey VrfKey)
Typeable (SigningKey VrfKey) =>
(forall s. Decoder s (SigningKey VrfKey))
-> (forall s. Proxy (SigningKey VrfKey) -> Decoder s ())
-> (Proxy (SigningKey VrfKey) -> Text)
-> DecCBOR (SigningKey VrfKey)
Proxy (SigningKey VrfKey) -> Text
forall s. Decoder s (SigningKey VrfKey)
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy (SigningKey VrfKey) -> Decoder s ()
$cdecCBOR :: forall s. Decoder s (SigningKey VrfKey)
decCBOR :: forall s. Decoder s (SigningKey VrfKey)
$cdropCBOR :: forall s. Proxy (SigningKey VrfKey) -> Decoder s ()
dropCBOR :: forall s. Proxy (SigningKey VrfKey) -> Decoder s ()
$clabel :: Proxy (SigningKey VrfKey) -> Text
label :: Proxy (SigningKey VrfKey) -> Text
DecCBOR, Typeable (SigningKey VrfKey)
Typeable (SigningKey VrfKey) =>
(SigningKey VrfKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size)
-> ToCBOR (SigningKey VrfKey)
SigningKey VrfKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: SigningKey VrfKey -> Encoding
toCBOR :: SigningKey VrfKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
ToCBOR, Typeable (SigningKey VrfKey)
Typeable (SigningKey VrfKey) =>
(forall s. Decoder s (SigningKey VrfKey))
-> (Proxy (SigningKey VrfKey) -> Text)
-> FromCBOR (SigningKey VrfKey)
Proxy (SigningKey VrfKey) -> Text
forall s. Decoder s (SigningKey VrfKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (SigningKey VrfKey)
fromCBOR :: forall s. Decoder s (SigningKey VrfKey)
$clabel :: Proxy (SigningKey VrfKey) -> Text
label :: Proxy (SigningKey VrfKey) -> Text
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey VrfKey)
HasTypeProxy (SigningKey VrfKey) =>
(SigningKey VrfKey -> ByteString)
-> (AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey))
-> SerialiseAsCBOR (SigningKey VrfKey)
AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
SigningKey VrfKey -> ByteString
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: SigningKey VrfKey -> ByteString
serialiseToCBOR :: SigningKey VrfKey -> ByteString
$cdeserialiseFromCBOR :: AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
deserialiseFromCBOR :: AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType VrfKey -> Crypto.Seed -> SigningKey VrfKey
deterministicSigningKey :: AsType VrfKey -> Seed -> SigningKey VrfKey
deterministicSigningKey AsType VrfKey
R:AsTypeVrfKey
AsVrfKey Seed
seed =
SignKeyVRF StandardCrypto -> SigningKey VrfKey
VrfSigningKey (Seed -> SignKeyVRF PraosVRF
forall v. VRFAlgorithm v => Seed -> SignKeyVRF v
Crypto.genKeyVRF Seed
seed)
deterministicSigningKeySeedSize :: AsType VrfKey -> Word
deterministicSigningKeySeedSize :: AsType VrfKey -> Word
deterministicSigningKeySeedSize AsType VrfKey
R:AsTypeVrfKey
AsVrfKey =
Proxy PraosVRF -> Word
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> Word
forall (proxy :: * -> *). proxy PraosVRF -> Word
Crypto.seedSizeVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy PraosVRF
Proxy (VRF StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey VrfKey -> VerificationKey VrfKey
getVerificationKey :: SigningKey VrfKey -> VerificationKey VrfKey
getVerificationKey (VrfSigningKey SignKeyVRF StandardCrypto
sk) =
VerKeyVRF StandardCrypto -> VerificationKey VrfKey
VrfVerificationKey (SignKeyVRF PraosVRF -> VerKeyVRF PraosVRF
forall v. VRFAlgorithm v => SignKeyVRF v -> VerKeyVRF v
Crypto.deriveVerKeyVRF SignKeyVRF PraosVRF
SignKeyVRF StandardCrypto
sk)
verificationKeyHash :: VerificationKey VrfKey -> Hash VrfKey
verificationKeyHash :: VerificationKey VrfKey -> Hash VrfKey
verificationKeyHash (VrfVerificationKey VerKeyVRF StandardCrypto
vkey) =
Hash StandardCrypto (VerKeyVRF StandardCrypto) -> Hash VrfKey
VrfKeyHash (VerKeyVRF PraosVRF -> Hash Blake2b_256 (VerKeyVRF PraosVRF)
forall h.
HashAlgorithm h =>
VerKeyVRF PraosVRF -> Hash h (VerKeyVRF PraosVRF)
forall v h.
(VRFAlgorithm v, HashAlgorithm h) =>
VerKeyVRF v -> Hash h (VerKeyVRF v)
Shelley.hashVerKeyVRF VerKeyVRF PraosVRF
VerKeyVRF StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey VrfKey) where
serialiseToRawBytes :: VerificationKey VrfKey -> ByteString
serialiseToRawBytes (VrfVerificationKey VerKeyVRF StandardCrypto
vk) =
VerKeyVRF PraosVRF -> ByteString
forall v. VRFAlgorithm v => VerKeyVRF v -> ByteString
Crypto.rawSerialiseVerKeyVRF VerKeyVRF PraosVRF
VerKeyVRF StandardCrypto
vk
deserialiseFromRawBytes :: AsType (VerificationKey VrfKey)
-> ByteString -> Maybe (VerificationKey VrfKey)
deserialiseFromRawBytes (AsVerificationKey AsType VrfKey
R:AsTypeVrfKey
AsVrfKey) ByteString
bs =
VerKeyVRF PraosVRF -> VerificationKey VrfKey
VerKeyVRF StandardCrypto -> VerificationKey VrfKey
VrfVerificationKey (VerKeyVRF PraosVRF -> VerificationKey VrfKey)
-> Maybe (VerKeyVRF PraosVRF) -> Maybe (VerificationKey VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (VerKeyVRF PraosVRF)
forall v. VRFAlgorithm v => ByteString -> Maybe (VerKeyVRF v)
Crypto.rawDeserialiseVerKeyVRF ByteString
bs
instance SerialiseAsRawBytes (SigningKey VrfKey) where
serialiseToRawBytes :: SigningKey VrfKey -> ByteString
serialiseToRawBytes (VrfSigningKey SignKeyVRF StandardCrypto
sk) =
SignKeyVRF PraosVRF -> ByteString
forall v. VRFAlgorithm v => SignKeyVRF v -> ByteString
Crypto.rawSerialiseSignKeyVRF SignKeyVRF PraosVRF
SignKeyVRF StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey VrfKey)
-> ByteString -> Maybe (SigningKey VrfKey)
deserialiseFromRawBytes (AsSigningKey AsType VrfKey
R:AsTypeVrfKey
AsVrfKey) ByteString
bs =
SignKeyVRF PraosVRF -> SigningKey VrfKey
SignKeyVRF StandardCrypto -> SigningKey VrfKey
VrfSigningKey (SignKeyVRF PraosVRF -> SigningKey VrfKey)
-> Maybe (SignKeyVRF PraosVRF) -> Maybe (SigningKey VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyVRF PraosVRF)
forall v. VRFAlgorithm v => ByteString -> Maybe (SignKeyVRF v)
Crypto.rawDeserialiseSignKeyVRF ByteString
bs
instance SerialiseAsBech32 (VerificationKey VrfKey) where
bech32PrefixFor :: VerificationKey VrfKey -> Text
bech32PrefixFor VerificationKey VrfKey
_ = Text
"vrf_vk"
bech32PrefixesPermitted :: AsType (VerificationKey VrfKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey VrfKey)
_ = [Text
"vrf_vk"]
instance SerialiseAsBech32 (SigningKey VrfKey) where
bech32PrefixFor :: SigningKey VrfKey -> Text
bech32PrefixFor SigningKey VrfKey
_ = Text
"vrf_sk"
bech32PrefixesPermitted :: AsType (SigningKey VrfKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey VrfKey)
_ = [Text
"vrf_sk"]
newtype instance Hash VrfKey =
VrfKeyHash (Shelley.Hash StandardCrypto
(Shelley.VerKeyVRF StandardCrypto))
deriving stock (Hash VrfKey -> Hash VrfKey -> Bool
(Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool) -> Eq (Hash VrfKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hash VrfKey -> Hash VrfKey -> Bool
== :: Hash VrfKey -> Hash VrfKey -> Bool
$c/= :: Hash VrfKey -> Hash VrfKey -> Bool
/= :: Hash VrfKey -> Hash VrfKey -> Bool
Eq, Eq (Hash VrfKey)
Eq (Hash VrfKey) =>
(Hash VrfKey -> Hash VrfKey -> Ordering)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Hash VrfKey)
-> (Hash VrfKey -> Hash VrfKey -> Hash VrfKey)
-> Ord (Hash VrfKey)
Hash VrfKey -> Hash VrfKey -> Bool
Hash VrfKey -> Hash VrfKey -> Ordering
Hash VrfKey -> Hash VrfKey -> Hash VrfKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Hash VrfKey -> Hash VrfKey -> Ordering
compare :: Hash VrfKey -> Hash VrfKey -> Ordering
$c< :: Hash VrfKey -> Hash VrfKey -> Bool
< :: Hash VrfKey -> Hash VrfKey -> Bool
$c<= :: Hash VrfKey -> Hash VrfKey -> Bool
<= :: Hash VrfKey -> Hash VrfKey -> Bool
$c> :: Hash VrfKey -> Hash VrfKey -> Bool
> :: Hash VrfKey -> Hash VrfKey -> Bool
$c>= :: Hash VrfKey -> Hash VrfKey -> Bool
>= :: Hash VrfKey -> Hash VrfKey -> Bool
$cmax :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
max :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
$cmin :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
min :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
Ord)
deriving (Int -> Hash VrfKey -> ShowS
[Hash VrfKey] -> ShowS
Hash VrfKey -> String
(Int -> Hash VrfKey -> ShowS)
-> (Hash VrfKey -> String)
-> ([Hash VrfKey] -> ShowS)
-> Show (Hash VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hash VrfKey -> ShowS
showsPrec :: Int -> Hash VrfKey -> ShowS
$cshow :: Hash VrfKey -> String
show :: Hash VrfKey -> String
$cshowList :: [Hash VrfKey] -> ShowS
showList :: [Hash VrfKey] -> ShowS
Show, String -> Hash VrfKey
(String -> Hash VrfKey) -> IsString (Hash VrfKey)
forall a. (String -> a) -> IsString a
$cfromString :: String -> Hash VrfKey
fromString :: String -> Hash VrfKey
IsString) via UsingRawBytesHex (Hash VrfKey)
deriving (Typeable (Hash VrfKey)
Typeable (Hash VrfKey) =>
(Hash VrfKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash VrfKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash VrfKey] -> Size)
-> ToCBOR (Hash VrfKey)
Hash VrfKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash VrfKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash VrfKey) -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: Hash VrfKey -> Encoding
toCBOR :: Hash VrfKey -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash VrfKey) -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (Hash VrfKey) -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash VrfKey] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Hash VrfKey] -> Size
ToCBOR, Typeable (Hash VrfKey)
Typeable (Hash VrfKey) =>
(forall s. Decoder s (Hash VrfKey))
-> (Proxy (Hash VrfKey) -> Text) -> FromCBOR (Hash VrfKey)
Proxy (Hash VrfKey) -> Text
forall s. Decoder s (Hash VrfKey)
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s (Hash VrfKey)
fromCBOR :: forall s. Decoder s (Hash VrfKey)
$clabel :: Proxy (Hash VrfKey) -> Text
label :: Proxy (Hash VrfKey) -> Text
FromCBOR) via UsingRawBytes (Hash VrfKey)
deriving anyclass HasTypeProxy (Hash VrfKey)
Hash VrfKey -> ByteString
HasTypeProxy (Hash VrfKey) =>
(Hash VrfKey -> ByteString)
-> (AsType (Hash VrfKey)
-> ByteString -> Either DecoderError (Hash VrfKey))
-> SerialiseAsCBOR (Hash VrfKey)
AsType (Hash VrfKey)
-> ByteString -> Either DecoderError (Hash VrfKey)
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
$cserialiseToCBOR :: Hash VrfKey -> ByteString
serialiseToCBOR :: Hash VrfKey -> ByteString
$cdeserialiseFromCBOR :: AsType (Hash VrfKey)
-> ByteString -> Either DecoderError (Hash VrfKey)
deserialiseFromCBOR :: AsType (Hash VrfKey)
-> ByteString -> Either DecoderError (Hash VrfKey)
SerialiseAsCBOR
instance SerialiseAsRawBytes (Hash VrfKey) where
serialiseToRawBytes :: Hash VrfKey -> ByteString
serialiseToRawBytes (VrfKeyHash Hash StandardCrypto (VerKeyVRF StandardCrypto)
vkh) =
Hash Blake2b_256 (VerKeyVRF PraosVRF) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 (VerKeyVRF PraosVRF)
Hash StandardCrypto (VerKeyVRF StandardCrypto)
vkh
deserialiseFromRawBytes :: AsType (Hash VrfKey) -> ByteString -> Maybe (Hash VrfKey)
deserialiseFromRawBytes (AsHash AsType VrfKey
R:AsTypeVrfKey
AsVrfKey) ByteString
bs =
Hash Blake2b_256 (VerKeyVRF PraosVRF) -> Hash VrfKey
Hash StandardCrypto (VerKeyVRF StandardCrypto) -> Hash VrfKey
VrfKeyHash (Hash Blake2b_256 (VerKeyVRF PraosVRF) -> Hash VrfKey)
-> Maybe (Hash Blake2b_256 (VerKeyVRF PraosVRF))
-> Maybe (Hash VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_256 (VerKeyVRF PraosVRF))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey VrfKey) where
textEnvelopeType :: AsType (VerificationKey VrfKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey VrfKey)
_ = TextEnvelopeType
"VrfVerificationKey_" TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy PraosVRF -> String
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> String
forall (proxy :: * -> *). proxy PraosVRF -> String
Crypto.algorithmNameVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy PraosVRF
Proxy (VRF StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey VrfKey) where
textEnvelopeType :: AsType (SigningKey VrfKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey VrfKey)
_ = TextEnvelopeType
"VrfSigningKey_" TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy PraosVRF -> String
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> String
forall (proxy :: * -> *). proxy PraosVRF -> String
Crypto.algorithmNameVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy PraosVRF
Proxy (VRF StandardCrypto)
forall {k} (t :: k). Proxy t
Proxy