{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}

module Cardano.Crypto.KES.NeverUsed (
  NeverKES,
  VerKeyKES (..),
  SignKeyKES (..),
  SigKES (..),
)
where

import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)

import Cardano.Crypto.KES.Class

-- | KES never used
--
-- The type of keys and signatures is isomorphic to unit, but when actually
-- trying to sign or verify something a runtime exception will be thrown.
data NeverKES

instance KESAlgorithm NeverKES where
  type SeedSizeKES NeverKES = 0

  data VerKeyKES NeverKES = NeverUsedVerKeyKES
    deriving (Int -> VerKeyKES NeverKES -> ShowS
[VerKeyKES NeverKES] -> ShowS
VerKeyKES NeverKES -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerKeyKES NeverKES] -> ShowS
$cshowList :: [VerKeyKES NeverKES] -> ShowS
show :: VerKeyKES NeverKES -> String
$cshow :: VerKeyKES NeverKES -> String
showsPrec :: Int -> VerKeyKES NeverKES -> ShowS
$cshowsPrec :: Int -> VerKeyKES NeverKES -> ShowS
Show, VerKeyKES NeverKES -> VerKeyKES NeverKES -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerKeyKES NeverKES -> VerKeyKES NeverKES -> Bool
$c/= :: VerKeyKES NeverKES -> VerKeyKES NeverKES -> Bool
== :: VerKeyKES NeverKES -> VerKeyKES NeverKES -> Bool
$c== :: VerKeyKES NeverKES -> VerKeyKES NeverKES -> Bool
Eq, forall x. Rep (VerKeyKES NeverKES) x -> VerKeyKES NeverKES
forall x. VerKeyKES NeverKES -> Rep (VerKeyKES NeverKES) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep (VerKeyKES NeverKES) x -> VerKeyKES NeverKES
$cfrom :: forall x. VerKeyKES NeverKES -> Rep (VerKeyKES NeverKES) x
Generic, Context -> VerKeyKES NeverKES -> IO (Maybe ThunkInfo)
Proxy (VerKeyKES NeverKES) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (VerKeyKES NeverKES) -> String
$cshowTypeOf :: Proxy (VerKeyKES NeverKES) -> String
wNoThunks :: Context -> VerKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> VerKeyKES NeverKES -> IO (Maybe ThunkInfo)
noThunks :: Context -> VerKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> VerKeyKES NeverKES -> IO (Maybe ThunkInfo)
NoThunks)

  data SigKES NeverKES = NeverUsedSigKES
    deriving (Int -> SigKES NeverKES -> ShowS
[SigKES NeverKES] -> ShowS
SigKES NeverKES -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigKES NeverKES] -> ShowS
$cshowList :: [SigKES NeverKES] -> ShowS
show :: SigKES NeverKES -> String
$cshow :: SigKES NeverKES -> String
showsPrec :: Int -> SigKES NeverKES -> ShowS
$cshowsPrec :: Int -> SigKES NeverKES -> ShowS
Show, SigKES NeverKES -> SigKES NeverKES -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SigKES NeverKES -> SigKES NeverKES -> Bool
$c/= :: SigKES NeverKES -> SigKES NeverKES -> Bool
== :: SigKES NeverKES -> SigKES NeverKES -> Bool
$c== :: SigKES NeverKES -> SigKES NeverKES -> Bool
Eq, forall x. Rep (SigKES NeverKES) x -> SigKES NeverKES
forall x. SigKES NeverKES -> Rep (SigKES NeverKES) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep (SigKES NeverKES) x -> SigKES NeverKES
$cfrom :: forall x. SigKES NeverKES -> Rep (SigKES NeverKES) x
Generic, Context -> SigKES NeverKES -> IO (Maybe ThunkInfo)
Proxy (SigKES NeverKES) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (SigKES NeverKES) -> String
$cshowTypeOf :: Proxy (SigKES NeverKES) -> String
wNoThunks :: Context -> SigKES NeverKES -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> SigKES NeverKES -> IO (Maybe ThunkInfo)
noThunks :: Context -> SigKES NeverKES -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> SigKES NeverKES -> IO (Maybe ThunkInfo)
NoThunks)

  data SignKeyKES NeverKES = NeverUsedSignKeyKES
    deriving (Int -> SignKeyKES NeverKES -> ShowS
[SignKeyKES NeverKES] -> ShowS
SignKeyKES NeverKES -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignKeyKES NeverKES] -> ShowS
$cshowList :: [SignKeyKES NeverKES] -> ShowS
show :: SignKeyKES NeverKES -> String
$cshow :: SignKeyKES NeverKES -> String
showsPrec :: Int -> SignKeyKES NeverKES -> ShowS
$cshowsPrec :: Int -> SignKeyKES NeverKES -> ShowS
Show, SignKeyKES NeverKES -> SignKeyKES NeverKES -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignKeyKES NeverKES -> SignKeyKES NeverKES -> Bool
$c/= :: SignKeyKES NeverKES -> SignKeyKES NeverKES -> Bool
== :: SignKeyKES NeverKES -> SignKeyKES NeverKES -> Bool
$c== :: SignKeyKES NeverKES -> SignKeyKES NeverKES -> Bool
Eq, forall x. Rep (SignKeyKES NeverKES) x -> SignKeyKES NeverKES
forall x. SignKeyKES NeverKES -> Rep (SignKeyKES NeverKES) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep (SignKeyKES NeverKES) x -> SignKeyKES NeverKES
$cfrom :: forall x. SignKeyKES NeverKES -> Rep (SignKeyKES NeverKES) x
Generic, Context -> SignKeyKES NeverKES -> IO (Maybe ThunkInfo)
Proxy (SignKeyKES NeverKES) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (SignKeyKES NeverKES) -> String
$cshowTypeOf :: Proxy (SignKeyKES NeverKES) -> String
wNoThunks :: Context -> SignKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> SignKeyKES NeverKES -> IO (Maybe ThunkInfo)
noThunks :: Context -> SignKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> SignKeyKES NeverKES -> IO (Maybe ThunkInfo)
NoThunks)

  algorithmNameKES :: forall (proxy :: * -> *). proxy NeverKES -> String
algorithmNameKES proxy NeverKES
_ = String
"never"

  verifyKES :: forall a.
(Signable NeverKES a, HasCallStack) =>
ContextKES NeverKES
-> VerKeyKES NeverKES
-> Period
-> a
-> SigKES NeverKES
-> Either String ()
verifyKES = forall a. HasCallStack => String -> a
error String
"KES not available"

  totalPeriodsKES :: forall (proxy :: * -> *). proxy NeverKES -> Period
totalPeriodsKES proxy NeverKES
_ = Period
0

  type SizeVerKeyKES NeverKES = 0
  type SizeSignKeyKES NeverKES = 0
  type SizeSigKES NeverKES = 0

  rawSerialiseVerKeyKES :: VerKeyKES NeverKES -> ByteString
rawSerialiseVerKeyKES VerKeyKES NeverKES
_ = forall a. Monoid a => a
mempty
  rawSerialiseSigKES :: SigKES NeverKES -> ByteString
rawSerialiseSigKES SigKES NeverKES
_ = forall a. Monoid a => a
mempty

  rawDeserialiseVerKeyKES :: ByteString -> Maybe (VerKeyKES NeverKES)
rawDeserialiseVerKeyKES ByteString
_ = forall a. a -> Maybe a
Just VerKeyKES NeverKES
NeverUsedVerKeyKES
  rawDeserialiseSigKES :: ByteString -> Maybe (SigKES NeverKES)
rawDeserialiseSigKES ByteString
_ = forall a. a -> Maybe a
Just SigKES NeverKES
NeverUsedSigKES

  deriveVerKeyKES :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
SignKeyKES NeverKES -> m (VerKeyKES NeverKES)
deriveVerKeyKES SignKeyKES NeverKES
_ = forall (m :: * -> *) a. Monad m => a -> m a
return VerKeyKES NeverKES
NeverUsedVerKeyKES

  signKES :: forall a (m :: * -> *).
(Signable NeverKES a, MonadST m, MonadThrow m) =>
ContextKES NeverKES
-> Period -> a -> SignKeyKES NeverKES -> m (SigKES NeverKES)
signKES = forall a. HasCallStack => String -> a
error String
"KES not available"
  updateKESWith :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
MLockedAllocator m
-> ContextKES NeverKES
-> SignKeyKES NeverKES
-> Period
-> m (Maybe (SignKeyKES NeverKES))
updateKESWith MLockedAllocator m
_ = forall a. HasCallStack => String -> a
error String
"KES not available"

  genKeyKESWith :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
MLockedAllocator m
-> MLockedSeed (SeedSizeKES NeverKES) -> m (SignKeyKES NeverKES)
genKeyKESWith MLockedAllocator m
_ MLockedSeed (SeedSizeKES NeverKES)
_ = forall (m :: * -> *) a. Monad m => a -> m a
return SignKeyKES NeverKES
NeverUsedSignKeyKES

  forgetSignKeyKESWith :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
MLockedAllocator m -> SignKeyKES NeverKES -> m ()
forgetSignKeyKESWith MLockedAllocator m
_ = forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return ()

instance UnsoundKESAlgorithm NeverKES where
  rawSerialiseSignKeyKES :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
SignKeyKES NeverKES -> m ByteString
rawSerialiseSignKeyKES SignKeyKES NeverKES
_ = forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
  rawDeserialiseSignKeyKESWith :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
MLockedAllocator m -> ByteString -> m (Maybe (SignKeyKES NeverKES))
rawDeserialiseSignKeyKESWith MLockedAllocator m
_ ByteString
_ = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just SignKeyKES NeverKES
NeverUsedSignKeyKES

instance UnsoundPureKESAlgorithm NeverKES where
  data UnsoundPureSignKeyKES NeverKES = NeverUsedUnsoundPureSignKeyKES
    deriving (Int -> UnsoundPureSignKeyKES NeverKES -> ShowS
[UnsoundPureSignKeyKES NeverKES] -> ShowS
UnsoundPureSignKeyKES NeverKES -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnsoundPureSignKeyKES NeverKES] -> ShowS
$cshowList :: [UnsoundPureSignKeyKES NeverKES] -> ShowS
show :: UnsoundPureSignKeyKES NeverKES -> String
$cshow :: UnsoundPureSignKeyKES NeverKES -> String
showsPrec :: Int -> UnsoundPureSignKeyKES NeverKES -> ShowS
$cshowsPrec :: Int -> UnsoundPureSignKeyKES NeverKES -> ShowS
Show, UnsoundPureSignKeyKES NeverKES
-> UnsoundPureSignKeyKES NeverKES -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnsoundPureSignKeyKES NeverKES
-> UnsoundPureSignKeyKES NeverKES -> Bool
$c/= :: UnsoundPureSignKeyKES NeverKES
-> UnsoundPureSignKeyKES NeverKES -> Bool
== :: UnsoundPureSignKeyKES NeverKES
-> UnsoundPureSignKeyKES NeverKES -> Bool
$c== :: UnsoundPureSignKeyKES NeverKES
-> UnsoundPureSignKeyKES NeverKES -> Bool
Eq, forall x.
Rep (UnsoundPureSignKeyKES NeverKES) x
-> UnsoundPureSignKeyKES NeverKES
forall x.
UnsoundPureSignKeyKES NeverKES
-> Rep (UnsoundPureSignKeyKES NeverKES) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep (UnsoundPureSignKeyKES NeverKES) x
-> UnsoundPureSignKeyKES NeverKES
$cfrom :: forall x.
UnsoundPureSignKeyKES NeverKES
-> Rep (UnsoundPureSignKeyKES NeverKES) x
Generic, Context -> UnsoundPureSignKeyKES NeverKES -> IO (Maybe ThunkInfo)
Proxy (UnsoundPureSignKeyKES NeverKES) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (UnsoundPureSignKeyKES NeverKES) -> String
$cshowTypeOf :: Proxy (UnsoundPureSignKeyKES NeverKES) -> String
wNoThunks :: Context -> UnsoundPureSignKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> UnsoundPureSignKeyKES NeverKES -> IO (Maybe ThunkInfo)
noThunks :: Context -> UnsoundPureSignKeyKES NeverKES -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> UnsoundPureSignKeyKES NeverKES -> IO (Maybe ThunkInfo)
NoThunks)

  unsoundPureSignKES :: forall a.
Signable NeverKES a =>
ContextKES NeverKES
-> Period -> a -> UnsoundPureSignKeyKES NeverKES -> SigKES NeverKES
unsoundPureSignKES = forall a. HasCallStack => String -> a
error String
"KES not available"
  unsoundPureGenKeyKES :: Seed -> UnsoundPureSignKeyKES NeverKES
unsoundPureGenKeyKES Seed
_ = UnsoundPureSignKeyKES NeverKES
NeverUsedUnsoundPureSignKeyKES
  unsoundPureDeriveVerKeyKES :: UnsoundPureSignKeyKES NeverKES -> VerKeyKES NeverKES
unsoundPureDeriveVerKeyKES UnsoundPureSignKeyKES NeverKES
_ = VerKeyKES NeverKES
NeverUsedVerKeyKES
  unsoundPureUpdateKES :: ContextKES NeverKES
-> UnsoundPureSignKeyKES NeverKES
-> Period
-> Maybe (UnsoundPureSignKeyKES NeverKES)
unsoundPureUpdateKES ContextKES NeverKES
_ = forall a. HasCallStack => String -> a
error String
"KES not available"
  unsoundPureSignKeyKESToSoundSignKeyKES :: forall (m :: * -> *).
(MonadST m, MonadThrow m) =>
UnsoundPureSignKeyKES NeverKES -> m (SignKeyKES NeverKES)
unsoundPureSignKeyKESToSoundSignKeyKES UnsoundPureSignKeyKES NeverKES
_ = forall (m :: * -> *) a. Monad m => a -> m a
return SignKeyKES NeverKES
NeverUsedSignKeyKES
  rawSerialiseUnsoundPureSignKeyKES :: UnsoundPureSignKeyKES NeverKES -> ByteString
rawSerialiseUnsoundPureSignKeyKES UnsoundPureSignKeyKES NeverKES
_ = forall a. Monoid a => a
mempty
  rawDeserialiseUnsoundPureSignKeyKES :: ByteString -> Maybe (UnsoundPureSignKeyKES NeverKES)
rawDeserialiseUnsoundPureSignKeyKES ByteString
_ = forall a. a -> Maybe a
Just UnsoundPureSignKeyKES NeverKES
NeverUsedUnsoundPureSignKeyKES