{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Protocol.PBFT.Crypto (
PBftCrypto (..)
, PBftMockCrypto
, PBftMockVerKeyHash (..)
) where
import Cardano.Crypto.DSIGN.Class
import Cardano.Crypto.DSIGN.Mock (MockDSIGN, VerKeyDSIGN (..))
import Codec.Serialise (Serialise)
import Data.Kind (Type)
import Data.Typeable
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Util.Condense
class ( Typeable c
, DSIGNAlgorithm (PBftDSIGN c)
, Condense (SigDSIGN (PBftDSIGN c))
, Show (PBftVerKeyHash c)
, Ord (PBftVerKeyHash c)
, Eq (PBftVerKeyHash c)
, Show (PBftVerKeyHash c)
, NoThunks (PBftVerKeyHash c)
, NoThunks (PBftDelegationCert c)
) => PBftCrypto c where
type family PBftDSIGN c :: Type
type family PBftDelegationCert c = (d :: Type) | d -> c
type family PBftVerKeyHash c = (d :: Type) | d -> c
dlgCertGenVerKey :: PBftDelegationCert c -> VerKeyDSIGN (PBftDSIGN c)
dlgCertDlgVerKey :: PBftDelegationCert c -> VerKeyDSIGN (PBftDSIGN c)
hashVerKey :: VerKeyDSIGN (PBftDSIGN c) -> PBftVerKeyHash c
data PBftMockCrypto
instance PBftCrypto PBftMockCrypto where
type PBftDSIGN PBftMockCrypto = MockDSIGN
type PBftDelegationCert PBftMockCrypto = (VerKeyDSIGN MockDSIGN, VerKeyDSIGN MockDSIGN)
type PBftVerKeyHash PBftMockCrypto = PBftMockVerKeyHash
dlgCertGenVerKey :: PBftDelegationCert PBftMockCrypto
-> VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
dlgCertGenVerKey = (VerKeyDSIGN MockDSIGN, VerKeyDSIGN MockDSIGN)
-> VerKeyDSIGN MockDSIGN
PBftDelegationCert PBftMockCrypto
-> VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
forall a b. (a, b) -> a
fst
dlgCertDlgVerKey :: PBftDelegationCert PBftMockCrypto
-> VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
dlgCertDlgVerKey = (VerKeyDSIGN MockDSIGN, VerKeyDSIGN MockDSIGN)
-> VerKeyDSIGN MockDSIGN
PBftDelegationCert PBftMockCrypto
-> VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
forall a b. (a, b) -> b
snd
hashVerKey :: VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
-> PBftVerKeyHash PBftMockCrypto
hashVerKey = VerKeyDSIGN MockDSIGN -> PBftMockVerKeyHash
VerKeyDSIGN (PBftDSIGN PBftMockCrypto)
-> PBftVerKeyHash PBftMockCrypto
PBftMockVerKeyHash
newtype PBftMockVerKeyHash = PBftMockVerKeyHash {
PBftMockVerKeyHash -> VerKeyDSIGN MockDSIGN
getPBftMockVerKeyHash :: VerKeyDSIGN MockDSIGN
}
deriving (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
(PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> Eq PBftMockVerKeyHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
== :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
$c/= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
/= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
Eq, Int -> PBftMockVerKeyHash -> ShowS
[PBftMockVerKeyHash] -> ShowS
PBftMockVerKeyHash -> String
(Int -> PBftMockVerKeyHash -> ShowS)
-> (PBftMockVerKeyHash -> String)
-> ([PBftMockVerKeyHash] -> ShowS)
-> Show PBftMockVerKeyHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PBftMockVerKeyHash -> ShowS
showsPrec :: Int -> PBftMockVerKeyHash -> ShowS
$cshow :: PBftMockVerKeyHash -> String
show :: PBftMockVerKeyHash -> String
$cshowList :: [PBftMockVerKeyHash] -> ShowS
showList :: [PBftMockVerKeyHash] -> ShowS
Show, (forall x. PBftMockVerKeyHash -> Rep PBftMockVerKeyHash x)
-> (forall x. Rep PBftMockVerKeyHash x -> PBftMockVerKeyHash)
-> Generic PBftMockVerKeyHash
forall x. Rep PBftMockVerKeyHash x -> PBftMockVerKeyHash
forall x. PBftMockVerKeyHash -> Rep PBftMockVerKeyHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PBftMockVerKeyHash -> Rep PBftMockVerKeyHash x
from :: forall x. PBftMockVerKeyHash -> Rep PBftMockVerKeyHash x
$cto :: forall x. Rep PBftMockVerKeyHash x -> PBftMockVerKeyHash
to :: forall x. Rep PBftMockVerKeyHash x -> PBftMockVerKeyHash
Generic, Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo)
Proxy PBftMockVerKeyHash -> String
(Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo))
-> (Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo))
-> (Proxy PBftMockVerKeyHash -> String)
-> NoThunks PBftMockVerKeyHash
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo)
noThunks :: Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PBftMockVerKeyHash -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PBftMockVerKeyHash -> String
showTypeOf :: Proxy PBftMockVerKeyHash -> String
NoThunks)
deriving ([PBftMockVerKeyHash] -> Encoding
PBftMockVerKeyHash -> Encoding
(PBftMockVerKeyHash -> Encoding)
-> (forall s. Decoder s PBftMockVerKeyHash)
-> ([PBftMockVerKeyHash] -> Encoding)
-> (forall s. Decoder s [PBftMockVerKeyHash])
-> Serialise PBftMockVerKeyHash
forall s. Decoder s [PBftMockVerKeyHash]
forall s. Decoder s PBftMockVerKeyHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: PBftMockVerKeyHash -> Encoding
encode :: PBftMockVerKeyHash -> Encoding
$cdecode :: forall s. Decoder s PBftMockVerKeyHash
decode :: forall s. Decoder s PBftMockVerKeyHash
$cencodeList :: [PBftMockVerKeyHash] -> Encoding
encodeList :: [PBftMockVerKeyHash] -> Encoding
$cdecodeList :: forall s. Decoder s [PBftMockVerKeyHash]
decodeList :: forall s. Decoder s [PBftMockVerKeyHash]
Serialise, Eq PBftMockVerKeyHash
Eq PBftMockVerKeyHash =>
(PBftMockVerKeyHash -> PBftMockVerKeyHash -> Ordering)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash)
-> (PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash)
-> Ord PBftMockVerKeyHash
PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
PBftMockVerKeyHash -> PBftMockVerKeyHash -> Ordering
PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash
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 :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Ordering
compare :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Ordering
$c< :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
< :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
$c<= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
<= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
$c> :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
> :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
$c>= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
>= :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> Bool
$cmax :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash
max :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash
$cmin :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash
min :: PBftMockVerKeyHash -> PBftMockVerKeyHash -> PBftMockVerKeyHash
Ord) via Word64