{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Cardano.Crypto.KES.Sum (
SumKES
, VerKeyKES (..)
, SignKeyKES (..)
, SigKES (..)
, Sum0KES
, Sum1KES
, Sum2KES
, Sum3KES
, Sum4KES
, Sum5KES
, Sum6KES
, Sum7KES
) where
import Data.Proxy (Proxy(..))
import GHC.Generics (Generic)
import qualified Data.ByteString as BS
import Control.Monad (guard)
import NoThunks.Class (NoThunks)
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Crypto.Util
import Cardano.Crypto.Seed
import Cardano.Crypto.Hash.Class
import Cardano.Crypto.KES.Class
import Cardano.Crypto.KES.Single (SingleKES)
import Control.DeepSeq (NFData)
type Sum0KES d = SingleKES d
type Sum1KES d h = SumKES h (Sum0KES d)
type Sum2KES d h = SumKES h (Sum1KES d h)
type Sum3KES d h = SumKES h (Sum2KES d h)
type Sum4KES d h = SumKES h (Sum3KES d h)
type Sum5KES d h = SumKES h (Sum4KES d h)
type Sum6KES d h = SumKES h (Sum5KES d h)
type Sum7KES d h = SumKES h (Sum6KES d h)
data SumKES h d
instance (NFData (SigKES d), NFData (VerKeyKES d)) =>
NFData (SigKES (SumKES h d)) where
instance (NFData (SignKeyKES d), NFData (VerKeyKES d)) =>
NFData (SignKeyKES (SumKES h d)) where
instance (KESAlgorithm d, HashAlgorithm h)
=> KESAlgorithm (SumKES h d) where
type SeedSizeKES (SumKES h d) = SeedSizeKES d
newtype VerKeyKES (SumKES h d) =
VerKeySumKES (Hash h (VerKeyKES d, VerKeyKES d))
deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall h d x.
Rep (VerKeyKES (SumKES h d)) x -> VerKeyKES (SumKES h d)
forall h d x.
VerKeyKES (SumKES h d) -> Rep (VerKeyKES (SumKES h d)) x
$cto :: forall h d x.
Rep (VerKeyKES (SumKES h d)) x -> VerKeyKES (SumKES h d)
$cfrom :: forall h d x.
VerKeyKES (SumKES h d) -> Rep (VerKeyKES (SumKES h d)) x
Generic
deriving newtype VerKeyKES (SumKES h d) -> ()
forall a. (a -> ()) -> NFData a
forall h d. VerKeyKES (SumKES h d) -> ()
rnf :: VerKeyKES (SumKES h d) -> ()
$crnf :: forall h d. VerKeyKES (SumKES h d) -> ()
NFData
data SignKeyKES (SumKES h d) =
SignKeySumKES !(SignKeyKES d)
!Seed
!(VerKeyKES d)
!(VerKeyKES d)
deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall h d x.
Rep (SignKeyKES (SumKES h d)) x -> SignKeyKES (SumKES h d)
forall h d x.
SignKeyKES (SumKES h d) -> Rep (SignKeyKES (SumKES h d)) x
$cto :: forall h d x.
Rep (SignKeyKES (SumKES h d)) x -> SignKeyKES (SumKES h d)
$cfrom :: forall h d x.
SignKeyKES (SumKES h d) -> Rep (SignKeyKES (SumKES h d)) x
Generic
data SigKES (SumKES h d) =
SigSumKES !(SigKES d)
!(VerKeyKES d)
!(VerKeyKES d)
deriving forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall h d x. Rep (SigKES (SumKES h d)) x -> SigKES (SumKES h d)
forall h d x. SigKES (SumKES h d) -> Rep (SigKES (SumKES h d)) x
$cto :: forall h d x. Rep (SigKES (SumKES h d)) x -> SigKES (SumKES h d)
$cfrom :: forall h d x. SigKES (SumKES h d) -> Rep (SigKES (SumKES h d)) x
Generic
algorithmNameKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> String
algorithmNameKES proxy (SumKES h d)
_ = String -> String
mungeName (forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> String
algorithmNameKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d))
deriveVerKeyKES :: SignKeyKES (SumKES h d) -> VerKeyKES (SumKES h d)
deriveVerKeyKES (SignKeySumKES SignKeyKES d
_ Seed
_ VerKeyKES d
vk_0 VerKeyKES d
vk_1) =
forall h d.
Hash h (VerKeyKES d, VerKeyKES d) -> VerKeyKES (SumKES h d)
VerKeySumKES (forall d h.
(KESAlgorithm d, HashAlgorithm h) =>
(VerKeyKES d, VerKeyKES d) -> Hash h (VerKeyKES d, VerKeyKES d)
hashPairOfVKeys (VerKeyKES d
vk_0, VerKeyKES d
vk_1))
hashVerKeyKES :: forall h.
HashAlgorithm h =>
VerKeyKES (SumKES h d) -> Hash h (VerKeyKES (SumKES h d))
hashVerKeyKES (VerKeySumKES Hash h (VerKeyKES d, VerKeyKES d)
vk) = forall h a b. Hash h a -> Hash h b
castHash (forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
hashWith forall h a. Hash h a -> ByteString
hashToBytes Hash h (VerKeyKES d, VerKeyKES d)
vk)
type Signable (SumKES h d) = Signable d
type ContextKES (SumKES h d) = ContextKES d
signKES :: forall a.
(Signable (SumKES h d) a, HasCallStack) =>
ContextKES (SumKES h d)
-> Period -> a -> SignKeyKES (SumKES h d) -> SigKES (SumKES h d)
signKES ContextKES (SumKES h d)
ctxt Period
t a
a (SignKeySumKES SignKeyKES d
sk Seed
_r_1 VerKeyKES d
vk_0 VerKeyKES d
vk_1) =
forall h d.
SigKES d -> VerKeyKES d -> VerKeyKES d -> SigKES (SumKES h d)
SigSumKES SigKES d
sigma VerKeyKES d
vk_0 VerKeyKES d
vk_1
where
sigma :: SigKES d
sigma | Period
t forall a. Ord a => a -> a -> Bool
< Period
_T = forall v a.
(KESAlgorithm v, Signable v a, HasCallStack) =>
ContextKES v -> Period -> a -> SignKeyKES v -> SigKES v
signKES ContextKES (SumKES h d)
ctxt Period
t a
a SignKeyKES d
sk
| Bool
otherwise = forall v a.
(KESAlgorithm v, Signable v a, HasCallStack) =>
ContextKES v -> Period -> a -> SignKeyKES v -> SigKES v
signKES ContextKES (SumKES h d)
ctxt (Period
t forall a. Num a => a -> a -> a
- Period
_T) a
a SignKeyKES d
sk
_T :: Period
_T = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
verifyKES :: forall a.
(Signable (SumKES h d) a, HasCallStack) =>
ContextKES (SumKES h d)
-> VerKeyKES (SumKES h d)
-> Period
-> a
-> SigKES (SumKES h d)
-> Either String ()
verifyKES ContextKES (SumKES h d)
ctxt (VerKeySumKES Hash h (VerKeyKES d, VerKeyKES d)
vk) Period
t a
a (SigSumKES SigKES d
sigma VerKeyKES d
vk_0 VerKeyKES d
vk_1)
| forall d h.
(KESAlgorithm d, HashAlgorithm h) =>
(VerKeyKES d, VerKeyKES d) -> Hash h (VerKeyKES d, VerKeyKES d)
hashPairOfVKeys (VerKeyKES d
vk_0, VerKeyKES d
vk_1) forall a. Eq a => a -> a -> Bool
/= Hash h (VerKeyKES d, VerKeyKES d)
vk
= forall a b. a -> Either a b
Left String
"Reject"
| Period
t forall a. Ord a => a -> a -> Bool
< Period
_T = forall v a.
(KESAlgorithm v, Signable v a, HasCallStack) =>
ContextKES v
-> VerKeyKES v -> Period -> a -> SigKES v -> Either String ()
verifyKES ContextKES (SumKES h d)
ctxt VerKeyKES d
vk_0 Period
t a
a SigKES d
sigma
| Bool
otherwise = forall v a.
(KESAlgorithm v, Signable v a, HasCallStack) =>
ContextKES v
-> VerKeyKES v -> Period -> a -> SigKES v -> Either String ()
verifyKES ContextKES (SumKES h d)
ctxt VerKeyKES d
vk_1 (Period
t forall a. Num a => a -> a -> a
- Period
_T) a
a SigKES d
sigma
where
_T :: Period
_T = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
updateKES :: HasCallStack =>
ContextKES (SumKES h d)
-> SignKeyKES (SumKES h d)
-> Period
-> Maybe (SignKeyKES (SumKES h d))
updateKES ContextKES (SumKES h d)
ctx (SignKeySumKES SignKeyKES d
sk Seed
r_1 VerKeyKES d
vk_0 VerKeyKES d
vk_1) Period
t
| Period
tforall a. Num a => a -> a -> a
+Period
1 forall a. Ord a => a -> a -> Bool
< Period
_T = do SignKeyKES d
sk' <- forall v.
(KESAlgorithm v, HasCallStack) =>
ContextKES v -> SignKeyKES v -> Period -> Maybe (SignKeyKES v)
updateKES ContextKES (SumKES h d)
ctx SignKeyKES d
sk Period
t
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall h d.
SignKeyKES d
-> Seed -> VerKeyKES d -> VerKeyKES d -> SignKeyKES (SumKES h d)
SignKeySumKES SignKeyKES d
sk' Seed
r_1 VerKeyKES d
vk_0 VerKeyKES d
vk_1
| Period
tforall a. Num a => a -> a -> a
+Period
1 forall a. Eq a => a -> a -> Bool
== Period
_T = do let sk' :: SignKeyKES d
sk' = forall v. KESAlgorithm v => Seed -> SignKeyKES v
genKeyKES Seed
r_1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall h d.
SignKeyKES d
-> Seed -> VerKeyKES d -> VerKeyKES d -> SignKeyKES (SumKES h d)
SignKeySumKES SignKeyKES d
sk' Seed
zero VerKeyKES d
vk_0 VerKeyKES d
vk_1
| Bool
otherwise = do SignKeyKES d
sk' <- forall v.
(KESAlgorithm v, HasCallStack) =>
ContextKES v -> SignKeyKES v -> Period -> Maybe (SignKeyKES v)
updateKES ContextKES (SumKES h d)
ctx SignKeyKES d
sk (Period
t forall a. Num a => a -> a -> a
- Period
_T)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall h d.
SignKeyKES d
-> Seed -> VerKeyKES d -> VerKeyKES d -> SignKeyKES (SumKES h d)
SignKeySumKES SignKeyKES d
sk' Seed
r_1 VerKeyKES d
vk_0 VerKeyKES d
vk_1
where
_T :: Period
_T = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
zero :: Seed
zero = forall d. KESAlgorithm d => Proxy d -> Seed
zeroSeed (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
totalPeriodsKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> Period
totalPeriodsKES proxy (SumKES h d)
_ = Period
2 forall a. Num a => a -> a -> a
* forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
totalPeriodsKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
seedSizeKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> Period
seedSizeKES proxy (SumKES h d)
_ = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
seedSizeKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
genKeyKES :: Seed -> SignKeyKES (SumKES h d)
genKeyKES Seed
r = forall h d.
SignKeyKES d
-> Seed -> VerKeyKES d -> VerKeyKES d -> SignKeyKES (SumKES h d)
SignKeySumKES SignKeyKES d
sk_0 Seed
r1 VerKeyKES d
vk_0 VerKeyKES d
vk_1
where
(Seed
r0, Seed
r1) = forall h (proxy :: * -> *).
HashAlgorithm h =>
proxy h -> Seed -> (Seed, Seed)
expandSeed (forall {k} (t :: k). Proxy t
Proxy :: Proxy h) Seed
r
sk_0 :: SignKeyKES d
sk_0 = forall v. KESAlgorithm v => Seed -> SignKeyKES v
genKeyKES Seed
r0
vk_0 :: VerKeyKES d
vk_0 = forall v. KESAlgorithm v => SignKeyKES v -> VerKeyKES v
deriveVerKeyKES SignKeyKES d
sk_0
sk_1 :: SignKeyKES d
sk_1 = forall v. KESAlgorithm v => Seed -> SignKeyKES v
genKeyKES Seed
r1
vk_1 :: VerKeyKES d
vk_1 = forall v. KESAlgorithm v => SignKeyKES v -> VerKeyKES v
deriveVerKeyKES SignKeyKES d
sk_1
sizeVerKeyKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> Period
sizeVerKeyKES proxy (SumKES h d)
_ = forall h (proxy :: * -> *). HashAlgorithm h => proxy h -> Period
sizeHash (forall {k} (t :: k). Proxy t
Proxy :: Proxy h)
sizeSignKeyKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> Period
sizeSignKeyKES proxy (SumKES h d)
_ = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSignKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
forall a. Num a => a -> a -> a
+ forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
seedSizeKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
forall a. Num a => a -> a -> a
+ forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeVerKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d) forall a. Num a => a -> a -> a
* Period
2
sizeSigKES :: forall (proxy :: * -> *). proxy (SumKES h d) -> Period
sizeSigKES proxy (SumKES h d)
_ = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSigKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
forall a. Num a => a -> a -> a
+ forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeVerKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d) forall a. Num a => a -> a -> a
* Period
2
rawSerialiseVerKeyKES :: VerKeyKES (SumKES h d) -> ByteString
rawSerialiseVerKeyKES (VerKeySumKES Hash h (VerKeyKES d, VerKeyKES d)
vk) = forall h a. Hash h a -> ByteString
hashToBytes Hash h (VerKeyKES d, VerKeyKES d)
vk
rawSerialiseSignKeyKES :: SignKeyKES (SumKES h d) -> ByteString
rawSerialiseSignKeyKES (SignKeySumKES SignKeyKES d
sk Seed
r_1 VerKeyKES d
vk_0 VerKeyKES d
vk_1) =
forall a. Monoid a => [a] -> a
mconcat
[ forall v. KESAlgorithm v => SignKeyKES v -> ByteString
rawSerialiseSignKeyKES SignKeyKES d
sk
, Seed -> ByteString
getSeedBytes Seed
r_1
, forall v. KESAlgorithm v => VerKeyKES v -> ByteString
rawSerialiseVerKeyKES VerKeyKES d
vk_0
, forall v. KESAlgorithm v => VerKeyKES v -> ByteString
rawSerialiseVerKeyKES VerKeyKES d
vk_1
]
rawSerialiseSigKES :: SigKES (SumKES h d) -> ByteString
rawSerialiseSigKES (SigSumKES SigKES d
sigma VerKeyKES d
vk_0 VerKeyKES d
vk_1) =
forall a. Monoid a => [a] -> a
mconcat
[ forall v. KESAlgorithm v => SigKES v -> ByteString
rawSerialiseSigKES SigKES d
sigma
, forall v. KESAlgorithm v => VerKeyKES v -> ByteString
rawSerialiseVerKeyKES VerKeyKES d
vk_0
, forall v. KESAlgorithm v => VerKeyKES v -> ByteString
rawSerialiseVerKeyKES VerKeyKES d
vk_1
]
rawDeserialiseVerKeyKES :: ByteString -> Maybe (VerKeyKES (SumKES h d))
rawDeserialiseVerKeyKES = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall h d.
Hash h (VerKeyKES d, VerKeyKES d) -> VerKeyKES (SumKES h d)
VerKeySumKES forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
hashFromBytes
rawDeserialiseSignKeyKES :: ByteString -> Maybe (SignKeyKES (SumKES h d))
rawDeserialiseSignKeyKES ByteString
b = do
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (ByteString -> Int
BS.length ByteString
b forall a. Eq a => a -> a -> Bool
== forall a b. (Integral a, Num b) => a -> b
fromIntegral Period
size_total)
SignKeyKES d
sk <- forall v. KESAlgorithm v => ByteString -> Maybe (SignKeyKES v)
rawDeserialiseSignKeyKES ByteString
b_sk
let r :: Seed
r = ByteString -> Seed
mkSeedFromBytes ByteString
b_r
VerKeyKES d
vk_0 <- forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
rawDeserialiseVerKeyKES ByteString
b_vk0
VerKeyKES d
vk_1 <- forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
rawDeserialiseVerKeyKES ByteString
b_vk1
forall (m :: * -> *) a. Monad m => a -> m a
return (forall h d.
SignKeyKES d
-> Seed -> VerKeyKES d -> VerKeyKES d -> SignKeyKES (SumKES h d)
SignKeySumKES SignKeyKES d
sk Seed
r VerKeyKES d
vk_0 VerKeyKES d
vk_1)
where
b_sk :: ByteString
b_sk = Period -> Period -> ByteString -> ByteString
slice Period
off_sk Period
size_sk ByteString
b
b_r :: ByteString
b_r = Period -> Period -> ByteString -> ByteString
slice Period
off_r Period
size_r ByteString
b
b_vk0 :: ByteString
b_vk0 = Period -> Period -> ByteString -> ByteString
slice Period
off_vk0 Period
size_vk ByteString
b
b_vk1 :: ByteString
b_vk1 = Period -> Period -> ByteString -> ByteString
slice Period
off_vk1 Period
size_vk ByteString
b
size_sk :: Period
size_sk = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSignKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
size_r :: Period
size_r = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
seedSizeKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
size_vk :: Period
size_vk = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeVerKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
size_total :: Period
size_total = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSignKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy (SumKES h d))
off_sk :: Period
off_sk = Period
0 :: Word
off_r :: Period
off_r = Period
size_sk
off_vk0 :: Period
off_vk0 = Period
off_r forall a. Num a => a -> a -> a
+ Period
size_r
off_vk1 :: Period
off_vk1 = Period
off_vk0 forall a. Num a => a -> a -> a
+ Period
size_vk
rawDeserialiseSigKES :: ByteString -> Maybe (SigKES (SumKES h d))
rawDeserialiseSigKES ByteString
b = do
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (ByteString -> Int
BS.length ByteString
b forall a. Eq a => a -> a -> Bool
== forall a b. (Integral a, Num b) => a -> b
fromIntegral Period
size_total)
SigKES d
sigma <- forall v. KESAlgorithm v => ByteString -> Maybe (SigKES v)
rawDeserialiseSigKES ByteString
b_sig
VerKeyKES d
vk_0 <- forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
rawDeserialiseVerKeyKES ByteString
b_vk0
VerKeyKES d
vk_1 <- forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
rawDeserialiseVerKeyKES ByteString
b_vk1
forall (m :: * -> *) a. Monad m => a -> m a
return (forall h d.
SigKES d -> VerKeyKES d -> VerKeyKES d -> SigKES (SumKES h d)
SigSumKES SigKES d
sigma VerKeyKES d
vk_0 VerKeyKES d
vk_1)
where
b_sig :: ByteString
b_sig = Period -> Period -> ByteString -> ByteString
slice Period
off_sig Period
size_sig ByteString
b
b_vk0 :: ByteString
b_vk0 = Period -> Period -> ByteString -> ByteString
slice Period
off_vk0 Period
size_vk ByteString
b
b_vk1 :: ByteString
b_vk1 = Period -> Period -> ByteString -> ByteString
slice Period
off_vk1 Period
size_vk ByteString
b
size_sig :: Period
size_sig = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSigKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
size_vk :: Period
size_vk = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeVerKeyKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy d)
size_total :: Period
size_total = forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Period
sizeSigKES (forall {k} (t :: k). Proxy t
Proxy :: Proxy (SumKES h d))
off_sig :: Period
off_sig = Period
0 :: Word
off_vk0 :: Period
off_vk0 = Period
size_sig
off_vk1 :: Period
off_vk1 = Period
off_vk0 forall a. Num a => a -> a -> a
+ Period
size_vk
deriving instance HashAlgorithm h => Show (VerKeyKES (SumKES h d))
deriving instance Eq (VerKeyKES (SumKES h d))
instance (KESAlgorithm d) => NoThunks (SignKeyKES (SumKES h d))
instance (KESAlgorithm d, HashAlgorithm h)
=> ToCBOR (VerKeyKES (SumKES h d)) where
toCBOR :: VerKeyKES (SumKES h d) -> Encoding
toCBOR = forall v. KESAlgorithm v => VerKeyKES v -> Encoding
encodeVerKeyKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerKeyKES (SumKES h d)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (VerKeyKES v) -> Size
encodedVerKeyKESSizeExpr
instance (KESAlgorithm d, HashAlgorithm h)
=> FromCBOR (VerKeyKES (SumKES h d)) where
fromCBOR :: forall s. Decoder s (VerKeyKES (SumKES h d))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (VerKeyKES v)
decodeVerKeyKES
deriving instance KESAlgorithm d => Show (SignKeyKES (SumKES h d))
instance (KESAlgorithm d) => NoThunks (VerKeyKES (SumKES h d))
instance (KESAlgorithm d, HashAlgorithm h)
=> ToCBOR (SignKeyKES (SumKES h d)) where
toCBOR :: SignKeyKES (SumKES h d) -> Encoding
toCBOR = forall v. KESAlgorithm v => SignKeyKES v -> Encoding
encodeSignKeyKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SignKeyKES (SumKES h d)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (SignKeyKES v) -> Size
encodedSignKeyKESSizeExpr
instance (KESAlgorithm d, HashAlgorithm h)
=> FromCBOR (SignKeyKES (SumKES h d)) where
fromCBOR :: forall s. Decoder s (SignKeyKES (SumKES h d))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (SignKeyKES v)
decodeSignKeyKES
deriving instance KESAlgorithm d => Show (SigKES (SumKES h d))
deriving instance KESAlgorithm d => Eq (SigKES (SumKES h d))
instance KESAlgorithm d => NoThunks (SigKES (SumKES h d))
instance (KESAlgorithm d, HashAlgorithm h)
=> ToCBOR (SigKES (SumKES h d)) where
toCBOR :: SigKES (SumKES h d) -> Encoding
toCBOR = forall v. KESAlgorithm v => SigKES v -> Encoding
encodeSigKES
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigKES (SumKES h d)) -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
_size = forall v. KESAlgorithm v => Proxy (SigKES v) -> Size
encodedSigKESSizeExpr
instance (KESAlgorithm d, HashAlgorithm h)
=> FromCBOR (SigKES (SumKES h d)) where
fromCBOR :: forall s. Decoder s (SigKES (SumKES h d))
fromCBOR = forall v s. KESAlgorithm v => Decoder s (SigKES v)
decodeSigKES