{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module Cardano.Crypto.KES.Mock
( MockKES
, VerKeyKES (..)
, SignKeyKES (..)
, SigKES (..)
)
where
import Data.Word (Word64)
import Data.Proxy (Proxy(..))
import GHC.Generics (Generic)
import GHC.TypeNats (Nat, KnownNat, natVal)
import NoThunks.Class (NoThunks)
import Control.Exception (assert)
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Crypto.Hash
import Cardano.Crypto.Seed
import Cardano.Crypto.KES.Class
import Cardano.Crypto.Util
data MockKES (t :: Nat)
instance KnownNat t => KESAlgorithm (MockKES t) where
type SeedSizeKES (MockKES t) = 8
newtype VerKeyKES (MockKES t) = VerKeyMockKES Word64
deriving stock (Int -> VerKeyKES (MockKES t) -> ShowS
forall (t :: Nat). Int -> VerKeyKES (MockKES t) -> ShowS
forall (t :: Nat). [VerKeyKES (MockKES t)] -> ShowS
forall (t :: Nat). VerKeyKES (MockKES t) -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerKeyKES (MockKES t)] -> ShowS
$cshowList :: forall (t :: Nat). [VerKeyKES (MockKES t)] -> ShowS
show :: VerKeyKES (MockKES t) -> String
$cshow :: forall (t :: Nat). VerKeyKES (MockKES t) -> String
showsPrec :: Int -> VerKeyKES (MockKES t) -> ShowS
$cshowsPrec :: forall (t :: Nat). Int -> VerKeyKES (MockKES t) -> ShowS
Show, VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
forall (t :: Nat).
VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
$c/= :: forall (t :: Nat).
VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
== :: VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
$c== :: forall (t :: Nat).
VerKeyKES (MockKES t) -> VerKeyKES (MockKES t) -> Bool
Eq, forall (t :: Nat) x.
Rep (VerKeyKES (MockKES t)) x -> VerKeyKES (MockKES t)
forall (t :: Nat) x.
VerKeyKES (MockKES t) -> Rep (VerKeyKES (MockKES t)) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall (t :: Nat) x.
Rep (VerKeyKES (MockKES t)) x -> VerKeyKES (MockKES t)
$cfrom :: forall (t :: Nat) x.
VerKeyKES (MockKES t) -> Rep (VerKeyKES (MockKES t)) x
Generic)
deriving newtype (Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
Proxy (VerKeyKES (MockKES t)) -> String
forall (t :: Nat).
Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
forall (t :: Nat). Proxy (VerKeyKES (MockKES t)) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (VerKeyKES (MockKES t)) -> String
$cshowTypeOf :: forall (t :: Nat). Proxy (VerKeyKES (MockKES t)) -> String
wNoThunks :: Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall (t :: Nat).
Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
noThunks :: Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
$cnoThunks :: forall (t :: Nat).
Context -> VerKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
NoThunks)
data SignKeyKES (MockKES t) =
SignKeyMockKES !(VerKeyKES (MockKES t)) !Period
deriving stock (Int -> SignKeyKES (MockKES t) -> ShowS
forall (t :: Nat). Int -> SignKeyKES (MockKES t) -> ShowS
forall (t :: Nat). [SignKeyKES (MockKES t)] -> ShowS
forall (t :: Nat). SignKeyKES (MockKES t) -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignKeyKES (MockKES t)] -> ShowS
$cshowList :: forall (t :: Nat). [SignKeyKES (MockKES t)] -> ShowS
show :: SignKeyKES (MockKES t) -> String
$cshow :: forall (t :: Nat). SignKeyKES (MockKES t) -> String
showsPrec :: Int -> SignKeyKES (MockKES t) -> ShowS
$cshowsPrec :: forall (t :: Nat). Int -> SignKeyKES (MockKES t) -> ShowS
Show, SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
forall (t :: Nat).
SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
$c/= :: forall (t :: Nat).
SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
== :: SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
$c== :: forall (t :: Nat).
SignKeyKES (MockKES t) -> SignKeyKES (MockKES t) -> Bool
Eq, forall (t :: Nat) x.
Rep (SignKeyKES (MockKES t)) x -> SignKeyKES (MockKES t)
forall (t :: Nat) x.
SignKeyKES (MockKES t) -> Rep (SignKeyKES (MockKES t)) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall (t :: Nat) x.
Rep (SignKeyKES (MockKES t)) x -> SignKeyKES (MockKES t)
$cfrom :: forall (t :: Nat) x.
SignKeyKES (MockKES t) -> Rep (SignKeyKES (MockKES t)) x
Generic)
deriving anyclass (forall (t :: Nat).
Context -> SignKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
forall (t :: Nat). Proxy (SignKeyKES (MockKES t)) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (SignKeyKES (MockKES t)) -> String
$cshowTypeOf :: forall (t :: Nat). Proxy (SignKeyKES (MockKES t)) -> String
wNoThunks :: Context -> SignKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall (t :: Nat).
Context -> SignKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
noThunks :: Context -> SignKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
$cnoThunks :: forall (t :: Nat).
Context -> SignKeyKES (MockKES t) -> IO (Maybe ThunkInfo)
NoThunks)
data SigKES (MockKES t) =
SigMockKES !(Hash ShortHash ()) !(SignKeyKES (MockKES t))
deriving stock (Int -> SigKES (MockKES t) -> ShowS
forall (t :: Nat). Int -> SigKES (MockKES t) -> ShowS
forall (t :: Nat). [SigKES (MockKES t)] -> ShowS
forall (t :: Nat). SigKES (MockKES t) -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigKES (MockKES t)] -> ShowS
$cshowList :: forall (t :: Nat). [SigKES (MockKES t)] -> ShowS
show :: SigKES (MockKES t) -> String
$cshow :: forall (t :: Nat). SigKES (MockKES t) -> String
showsPrec :: Int -> SigKES (MockKES t) -> ShowS
$cshowsPrec :: forall (t :: Nat). Int -> SigKES (MockKES t) -> ShowS
Show, SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
forall (t :: Nat). SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c/= :: forall (t :: Nat). SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
== :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c== :: forall (t :: Nat). SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
Eq, SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
SigKES (MockKES t) -> SigKES (MockKES t) -> Ordering
forall {t :: Nat}. (TypeError ...) => Eq (SigKES (MockKES t))
forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Ordering
forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> SigKES (MockKES t)
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
min :: SigKES (MockKES t) -> SigKES (MockKES t) -> SigKES (MockKES t)
$cmin :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> SigKES (MockKES t)
max :: SigKES (MockKES t) -> SigKES (MockKES t) -> SigKES (MockKES t)
$cmax :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> SigKES (MockKES t)
>= :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c>= :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
> :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c> :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
<= :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c<= :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
< :: SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
$c< :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Bool
compare :: SigKES (MockKES t) -> SigKES (MockKES t) -> Ordering
$ccompare :: forall (t :: Nat).
(TypeError ...) =>
SigKES (MockKES t) -> SigKES (MockKES t) -> Ordering
Ord, forall (t :: Nat) x.
Rep (SigKES (MockKES t)) x -> SigKES (MockKES t)
forall (t :: Nat) x.
SigKES (MockKES t) -> Rep (SigKES (MockKES t)) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall (t :: Nat) x.
Rep (SigKES (MockKES t)) x -> SigKES (MockKES t)
$cfrom :: forall (t :: Nat) x.
SigKES (MockKES t) -> Rep (SigKES (MockKES t)) x
Generic)
deriving anyclass (forall (t :: Nat).
Context -> SigKES (MockKES t) -> IO (Maybe ThunkInfo)
forall (t :: Nat). Proxy (SigKES (MockKES t)) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (SigKES (MockKES t)) -> String
$cshowTypeOf :: forall (t :: Nat). Proxy (SigKES (MockKES t)) -> String
wNoThunks :: Context -> SigKES (MockKES t) -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall (t :: Nat).
Context -> SigKES (MockKES t) -> IO (Maybe ThunkInfo)
noThunks :: Context -> SigKES (MockKES t) -> IO (Maybe ThunkInfo)
$cnoThunks :: forall (t :: Nat).
Context -> SigKES (MockKES t) -> IO (Maybe ThunkInfo)
NoThunks)
algorithmNameKES :: forall (proxy :: * -> *). proxy (MockKES t) -> String
algorithmNameKES proxy (MockKES t)
proxy = String
"mock_" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES proxy (MockKES t)
proxy)
deriveVerKeyKES :: SignKeyKES (MockKES t) -> VerKeyKES (MockKES t)
deriveVerKeyKES (SignKeyMockKES VerKeyKES (MockKES t)
vk Period
_) = VerKeyKES (MockKES t)
vk
sizeVerKeyKES :: forall (proxy :: * -> *). proxy (MockKES t) -> Period
sizeVerKeyKES proxy (MockKES t)
_ = Period
8
sizeSignKeyKES :: forall (proxy :: * -> *). proxy (MockKES t) -> Period
sizeSignKeyKES proxy (MockKES t)
_ = Period
16
sizeSigKES :: forall (proxy :: * -> *). proxy (MockKES t) -> Period
sizeSigKES proxy (MockKES t)
_ = Period
24
type Signable (MockKES t) = SignableRepresentation
updateKES :: HasCallStack =>
ContextKES (MockKES t)
-> SignKeyKES (MockKES t)
-> Period
-> Maybe (SignKeyKES (MockKES t))
updateKES () (SignKeyMockKES VerKeyKES (MockKES t)
vk Period
t') Period
t =
forall a. HasCallStack => Bool -> a -> a
assert (Period
t forall a. Eq a => a -> a -> Bool
== Period
t') forall a b. (a -> b) -> a -> b
$
if Period
tforall a. Num a => a -> a -> a
+Period
1 forall a. Ord a => a -> a -> Bool
< forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES (forall {k} (t :: k). Proxy t
Proxy @(MockKES t))
then forall a. a -> Maybe a
Just (forall (t :: Nat).
VerKeyKES (MockKES t) -> Period -> SignKeyKES (MockKES t)
SignKeyMockKES VerKeyKES (MockKES t)
vk (Period
tforall a. Num a => a -> a -> a
+Period
1))
else forall a. Maybe a
Nothing
signKES :: forall a.
(Signable (MockKES t) a, HasCallStack) =>
ContextKES (MockKES t)
-> Period -> a -> SignKeyKES (MockKES t) -> SigKES (MockKES t)
signKES () Period
t a
a (SignKeyMockKES VerKeyKES (MockKES t)
vk Period
t') =
forall a. HasCallStack => Bool -> a -> a
assert (Period
t forall a. Eq a => a -> a -> Bool
== Period
t') forall a b. (a -> b) -> a -> b
$
forall (t :: Nat).
Hash ShortHash () -> SignKeyKES (MockKES t) -> SigKES (MockKES t)
SigMockKES (forall h a b. Hash h a -> Hash h b
castHash (forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
hashWith forall a. SignableRepresentation a => a -> ByteString
getSignableRepresentation a
a))
(forall (t :: Nat).
VerKeyKES (MockKES t) -> Period -> SignKeyKES (MockKES t)
SignKeyMockKES VerKeyKES (MockKES t)
vk Period
t)
verifyKES :: forall a.
(Signable (MockKES t) a, HasCallStack) =>
ContextKES (MockKES t)
-> VerKeyKES (MockKES t)
-> Period
-> a
-> SigKES (MockKES t)
-> Either String ()
verifyKES () VerKeyKES (MockKES t)
vk Period
t a
a (SigMockKES Hash ShortHash ()
h (SignKeyMockKES VerKeyKES (MockKES t)
vk' Period
t'))
| VerKeyKES (MockKES t)
vk forall a. Eq a => a -> a -> Bool
/= VerKeyKES (MockKES t)
vk'
= forall a b. a -> Either a b
Left String
"KES verification failed"
| Period
t' forall a. Eq a => a -> a -> Bool
== Period
t
, forall h a b. Hash h a -> Hash h b
castHash (forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
hashWith forall a. SignableRepresentation a => a -> ByteString
getSignableRepresentation a
a) forall a. Eq a => a -> a -> Bool
== Hash ShortHash ()
h
= forall a b. b -> Either a b
Right ()
| Bool
otherwise
= forall a b. a -> Either a b
Left String
"KES verification failed"
totalPeriodsKES :: forall (proxy :: * -> *). proxy (MockKES t) -> Period
totalPeriodsKES proxy (MockKES t)
_ = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (n :: Nat) (proxy :: Nat -> *). KnownNat n => proxy n -> Nat
natVal (forall {k} (t :: k). Proxy t
Proxy @t))
genKeyKES :: Seed -> SignKeyKES (MockKES t)
genKeyKES Seed
seed =
let vk :: VerKeyKES (MockKES t)
vk = forall (t :: Nat). Word64 -> VerKeyKES (MockKES t)
VerKeyMockKES (forall a. Seed -> (forall (m :: * -> *). MonadRandom m => m a) -> a
runMonadRandomWithSeed Seed
seed forall (m :: * -> *). MonadRandom m => m Word64
getRandomWord64)
in forall (t :: Nat).
VerKeyKES (MockKES t) -> Period -> SignKeyKES (MockKES t)
SignKeyMockKES VerKeyKES (MockKES t)
vk Period
0
rawSerialiseVerKeyKES :: VerKeyKES (MockKES t) -> ByteString
rawSerialiseVerKeyKES (VerKeyMockKES Word64
vk) =
Word64 -> ByteString
writeBinaryWord64 Word64
vk
rawSerialiseSignKeyKES :: SignKeyKES (MockKES t) -> ByteString
rawSerialiseSignKeyKES (SignKeyMockKES VerKeyKES (MockKES t)
vk Period
t) =
forall v. KESAlgorithm v => VerKeyKES v -> ByteString
rawSerialiseVerKeyKES VerKeyKES (MockKES t)
vk
forall a. Semigroup a => a -> a -> a
<> Word64 -> ByteString
writeBinaryWord64 (forall a b. (Integral a, Num b) => a -> b
fromIntegral Period
t)
rawSerialiseSigKES :: SigKES (MockKES t) -> ByteString
rawSerialiseSigKES (SigMockKES Hash ShortHash ()
h SignKeyKES (MockKES t)
sk) =
forall h a. Hash h a -> ByteString
hashToBytes Hash ShortHash ()
h
forall a. Semigroup a => a -> a -> a
<> forall v. KESAlgorithm v => SignKeyKES v -> ByteString
rawSerialiseSignKeyKES SignKeyKES (MockKES t)
sk
rawDeserialiseVerKeyKES :: ByteString -> Maybe (VerKeyKES (MockKES t))
rawDeserialiseVerKeyKES ByteString
bs
| [ByteString
vkb] <- [Int] -> ByteString -> [ByteString]
splitsAt [Int
8] ByteString
bs
, let vk :: Word64
vk = ByteString -> Word64
readBinaryWord64 ByteString
vkb
= forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$! forall (t :: Nat). Word64 -> VerKeyKES (MockKES t)
VerKeyMockKES Word64
vk
| Bool
otherwise
= forall a. Maybe a
Nothing
rawDeserialiseSignKeyKES :: ByteString -> Maybe (SignKeyKES (MockKES t))
rawDeserialiseSignKeyKES ByteString
bs
| [ByteString
vkb, ByteString
tb] <- [Int] -> ByteString -> [ByteString]
splitsAt [Int
8, Int
8] ByteString
bs
, Just VerKeyKES (MockKES t)
vk <- forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
rawDeserialiseVerKeyKES ByteString
vkb
, let t :: Period
t = forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Word64
readBinaryWord64 ByteString
tb)
= forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$! forall (t :: Nat).
VerKeyKES (MockKES t) -> Period -> SignKeyKES (MockKES t)
SignKeyMockKES VerKeyKES (MockKES t)
vk Period
t
| Bool
otherwise
= forall a. Maybe a
Nothing
rawDeserialiseSigKES :: ByteString -> Maybe (SigKES (MockKES t))
rawDeserialiseSigKES ByteString
bs
| [ByteString
hb, ByteString
skb] <- [Int] -> ByteString -> [ByteString]
splitsAt [Int
8, Int
16] ByteString
bs
, Just Hash ShortHash ()
h <- forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
hashFromBytes ByteString
hb
, Just SignKeyKES (MockKES t)
sk <- forall v. KESAlgorithm v => ByteString -> Maybe (SignKeyKES v)
rawDeserialiseSignKeyKES ByteString
skb
= forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$! forall (t :: Nat).
Hash ShortHash () -> SignKeyKES (MockKES t) -> SigKES (MockKES t)
SigMockKES Hash ShortHash ()
h SignKeyKES (MockKES t)
sk
| Bool
otherwise
= forall a. Maybe a
Nothing
instance KnownNat t => ToCBOR (VerKeyKES (MockKES t)) where
toCBOR :: VerKeyKES (MockKES t) -> Encoding
toCBOR = forall v. KESAlgorithm v => VerKeyKES v -> Encoding
encodeVerKeyKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerKeyKES (MockKES t)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (VerKeyKES v) -> Size
encodedVerKeyKESSizeExpr
instance KnownNat t => FromCBOR (VerKeyKES (MockKES t)) where
fromCBOR :: forall s. Decoder s (VerKeyKES (MockKES t))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (VerKeyKES v)
decodeVerKeyKES
instance KnownNat t => ToCBOR (SignKeyKES (MockKES t)) where
toCBOR :: SignKeyKES (MockKES t) -> Encoding
toCBOR = forall v. KESAlgorithm v => SignKeyKES v -> Encoding
encodeSignKeyKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SignKeyKES (MockKES t)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (SignKeyKES v) -> Size
encodedSignKeyKESSizeExpr
instance KnownNat t => FromCBOR (SignKeyKES (MockKES t)) where
fromCBOR :: forall s. Decoder s (SignKeyKES (MockKES t))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (SignKeyKES v)
decodeSignKeyKES
instance KnownNat t => ToCBOR (SigKES (MockKES t)) where
toCBOR :: SigKES (MockKES t) -> Encoding
toCBOR = forall v. KESAlgorithm v => SigKES v -> Encoding
encodeSigKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigKES (MockKES t)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (SigKES v) -> Size
encodedSigKESSizeExpr
instance KnownNat t => FromCBOR (SigKES (MockKES t)) where
fromCBOR :: forall s. Decoder s (SigKES (MockKES t))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (SigKES v)
decodeSigKES