{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE EmptyDataDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

-- | Helpers to derive @BlockSupportsPeras@ for block types without Peras support.
module Ouroboros.Consensus.Peras.Void
  ( VoidPerasVote (..)
  , VoidPerasCert (..)
  , VoidPerasError (..)
  , VoidPerasCrypto
  , VoidPerasVotingCommitteeScheme
  , absurdVoidPerasVotingCommitteeError
  , absurdVoidPerasCert
  ) where

import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Control.Exception.Base (Exception)
import qualified Data.List.NonEmpty as NonEmpty
import Data.Typeable (Typeable)
import Data.Void (Void, absurd)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Block.Abstract (Point)
import Ouroboros.Consensus.Committee.Class
  ( CryptoSupportsVotingCommittee (..)
  , VotingCommittee
  , getRawVotes
  )
import Ouroboros.Consensus.Committee.Crypto
  ( CryptoSupportsVoteSigning (..)
  , ElectionId
  , PrivateKey
  , PublicKey
  , VoteCandidate
  )
import Ouroboros.Consensus.Peras.Cert.Class
import Ouroboros.Consensus.Peras.Types (BoostedBlock, PerasRoundNo)
import Ouroboros.Consensus.Peras.Vote.Class
import Ouroboros.Consensus.Peras.Voting.Adapter
  ( PerasCertCompatibleWithVotingCommittee (..)
  , PerasVoteCompatibleWithVotingCommittee (..)
  )
import Ouroboros.Consensus.Util (ShowProxy)

-- | Imposible Peras vote for @blk@.
--
-- NOTE: the phantom @blk@ is used to keep the 'PerasVote' type family injective.
newtype VoidPerasVote blk
  = VoidPerasVote
  { forall blk. VoidPerasVote blk -> Void
unVoidPerasVote :: Void
  }
  deriving newtype (Int -> VoidPerasVote blk -> ShowS
[VoidPerasVote blk] -> ShowS
VoidPerasVote blk -> String
(Int -> VoidPerasVote blk -> ShowS)
-> (VoidPerasVote blk -> String)
-> ([VoidPerasVote blk] -> ShowS)
-> Show (VoidPerasVote blk)
forall blk. Int -> VoidPerasVote blk -> ShowS
forall blk. [VoidPerasVote blk] -> ShowS
forall blk. VoidPerasVote blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> VoidPerasVote blk -> ShowS
showsPrec :: Int -> VoidPerasVote blk -> ShowS
$cshow :: forall blk. VoidPerasVote blk -> String
show :: VoidPerasVote blk -> String
$cshowList :: forall blk. [VoidPerasVote blk] -> ShowS
showList :: [VoidPerasVote blk] -> ShowS
Show, VoidPerasVote blk -> VoidPerasVote blk -> Bool
(VoidPerasVote blk -> VoidPerasVote blk -> Bool)
-> (VoidPerasVote blk -> VoidPerasVote blk -> Bool)
-> Eq (VoidPerasVote blk)
forall blk. VoidPerasVote blk -> VoidPerasVote blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. VoidPerasVote blk -> VoidPerasVote blk -> Bool
== :: VoidPerasVote blk -> VoidPerasVote blk -> Bool
$c/= :: forall blk. VoidPerasVote blk -> VoidPerasVote blk -> Bool
/= :: VoidPerasVote blk -> VoidPerasVote blk -> Bool
Eq, Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
Proxy (VoidPerasVote blk) -> String
(Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo))
-> (Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo))
-> (Proxy (VoidPerasVote blk) -> String)
-> NoThunks (VoidPerasVote blk)
forall blk. Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
forall blk. Proxy (VoidPerasVote blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk. Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk. Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> VoidPerasVote blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. Proxy (VoidPerasVote blk) -> String
showTypeOf :: Proxy (VoidPerasVote blk) -> String
NoThunks, Proxy (VoidPerasVote blk) -> String
(Proxy (VoidPerasVote blk) -> String)
-> ShowProxy (VoidPerasVote blk)
forall blk. Proxy (VoidPerasVote blk) -> String
forall {k} (p :: k). (Proxy p -> String) -> ShowProxy p
$cshowProxy :: forall blk. Proxy (VoidPerasVote blk) -> String
showProxy :: Proxy (VoidPerasVote blk) -> String
ShowProxy)

-- | Imposible Peras certificate for @blk@.
--
-- NOTE: the phantom @blk@ is used to keep the 'PerasCert' type family injective.
newtype VoidPerasCert blk
  = VoidPerasCert
  { forall blk. VoidPerasCert blk -> Void
unVoidPerasCert :: Void
  }
  deriving newtype (Int -> VoidPerasCert blk -> ShowS
[VoidPerasCert blk] -> ShowS
VoidPerasCert blk -> String
(Int -> VoidPerasCert blk -> ShowS)
-> (VoidPerasCert blk -> String)
-> ([VoidPerasCert blk] -> ShowS)
-> Show (VoidPerasCert blk)
forall blk. Int -> VoidPerasCert blk -> ShowS
forall blk. [VoidPerasCert blk] -> ShowS
forall blk. VoidPerasCert blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> VoidPerasCert blk -> ShowS
showsPrec :: Int -> VoidPerasCert blk -> ShowS
$cshow :: forall blk. VoidPerasCert blk -> String
show :: VoidPerasCert blk -> String
$cshowList :: forall blk. [VoidPerasCert blk] -> ShowS
showList :: [VoidPerasCert blk] -> ShowS
Show, VoidPerasCert blk -> VoidPerasCert blk -> Bool
(VoidPerasCert blk -> VoidPerasCert blk -> Bool)
-> (VoidPerasCert blk -> VoidPerasCert blk -> Bool)
-> Eq (VoidPerasCert blk)
forall blk. VoidPerasCert blk -> VoidPerasCert blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. VoidPerasCert blk -> VoidPerasCert blk -> Bool
== :: VoidPerasCert blk -> VoidPerasCert blk -> Bool
$c/= :: forall blk. VoidPerasCert blk -> VoidPerasCert blk -> Bool
/= :: VoidPerasCert blk -> VoidPerasCert blk -> Bool
Eq, Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
Proxy (VoidPerasCert blk) -> String
(Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo))
-> (Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo))
-> (Proxy (VoidPerasCert blk) -> String)
-> NoThunks (VoidPerasCert blk)
forall blk. Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
forall blk. Proxy (VoidPerasCert blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk. Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk. Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> VoidPerasCert blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. Proxy (VoidPerasCert blk) -> String
showTypeOf :: Proxy (VoidPerasCert blk) -> String
NoThunks, Proxy (VoidPerasCert blk) -> String
(Proxy (VoidPerasCert blk) -> String)
-> ShowProxy (VoidPerasCert blk)
forall blk. Proxy (VoidPerasCert blk) -> String
forall {k} (p :: k). (Proxy p -> String) -> ShowProxy p
$cshowProxy :: forall blk. Proxy (VoidPerasCert blk) -> String
showProxy :: Proxy (VoidPerasCert blk) -> String
ShowProxy)

type instance BoostedBlock (VoidPerasVote blk) = Point blk
type instance BoostedBlock (VoidPerasCert blk) = Point blk

instance IsPerasVote (VoidPerasVote blk) blk where
  getPerasVoteRound :: VoidPerasVote blk -> PerasRoundNo
getPerasVoteRound = Void -> PerasRoundNo
forall a. Void -> a
absurd (Void -> PerasRoundNo)
-> (VoidPerasVote blk -> Void) -> VoidPerasVote blk -> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote
  getPerasVoteBlock :: VoidPerasVote blk -> BoostedBlock (VoidPerasVote blk)
getPerasVoteBlock = Void -> Point blk
forall a. Void -> a
absurd (Void -> Point blk)
-> (VoidPerasVote blk -> Void) -> VoidPerasVote blk -> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote
  getPerasVoteSeatIndex :: VoidPerasVote blk -> PerasSeatIndex
getPerasVoteSeatIndex = Void -> PerasSeatIndex
forall a. Void -> a
absurd (Void -> PerasSeatIndex)
-> (VoidPerasVote blk -> Void)
-> VoidPerasVote blk
-> PerasSeatIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote

instance IsPerasCert (VoidPerasCert blk) blk where
  getPerasCertRound :: VoidPerasCert blk -> PerasRoundNo
getPerasCertRound = Void -> PerasRoundNo
forall a. Void -> a
absurd (Void -> PerasRoundNo)
-> (VoidPerasCert blk -> Void) -> VoidPerasCert blk -> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasCert blk -> Void
forall blk. VoidPerasCert blk -> Void
unVoidPerasCert
  getPerasCertBlock :: VoidPerasCert blk -> BoostedBlock (VoidPerasCert blk)
getPerasCertBlock = Void -> Point blk
forall a. Void -> a
absurd (Void -> Point blk)
-> (VoidPerasCert blk -> Void) -> VoidPerasCert blk -> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasCert blk -> Void
forall blk. VoidPerasCert blk -> Void
unVoidPerasCert

-- | Void Peras error for @blk@.
--
-- NOTE: the phantom @blk@ is used to keep the 'PerasError' type family injective.
newtype VoidPerasError blk
  = VoidPerasError
  { forall blk. VoidPerasError blk -> Void
unVoidPerasError :: Void
  }
  deriving newtype (Int -> VoidPerasError blk -> ShowS
[VoidPerasError blk] -> ShowS
VoidPerasError blk -> String
(Int -> VoidPerasError blk -> ShowS)
-> (VoidPerasError blk -> String)
-> ([VoidPerasError blk] -> ShowS)
-> Show (VoidPerasError blk)
forall blk. Int -> VoidPerasError blk -> ShowS
forall blk. [VoidPerasError blk] -> ShowS
forall blk. VoidPerasError blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> VoidPerasError blk -> ShowS
showsPrec :: Int -> VoidPerasError blk -> ShowS
$cshow :: forall blk. VoidPerasError blk -> String
show :: VoidPerasError blk -> String
$cshowList :: forall blk. [VoidPerasError blk] -> ShowS
showList :: [VoidPerasError blk] -> ShowS
Show, VoidPerasError blk -> VoidPerasError blk -> Bool
(VoidPerasError blk -> VoidPerasError blk -> Bool)
-> (VoidPerasError blk -> VoidPerasError blk -> Bool)
-> Eq (VoidPerasError blk)
forall blk. VoidPerasError blk -> VoidPerasError blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. VoidPerasError blk -> VoidPerasError blk -> Bool
== :: VoidPerasError blk -> VoidPerasError blk -> Bool
$c/= :: forall blk. VoidPerasError blk -> VoidPerasError blk -> Bool
/= :: VoidPerasError blk -> VoidPerasError blk -> Bool
Eq, Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
Proxy (VoidPerasError blk) -> String
(Context -> VoidPerasError blk -> IO (Maybe ThunkInfo))
-> (Context -> VoidPerasError blk -> IO (Maybe ThunkInfo))
-> (Proxy (VoidPerasError blk) -> String)
-> NoThunks (VoidPerasError blk)
forall blk. Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
forall blk. Proxy (VoidPerasError blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk. Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk. Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> VoidPerasError blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. Proxy (VoidPerasError blk) -> String
showTypeOf :: Proxy (VoidPerasError blk) -> String
NoThunks, (forall x. VoidPerasError blk -> Rep (VoidPerasError blk) x)
-> (forall x. Rep (VoidPerasError blk) x -> VoidPerasError blk)
-> Generic (VoidPerasError blk)
forall x. Rep (VoidPerasError blk) x -> VoidPerasError blk
forall x. VoidPerasError blk -> Rep (VoidPerasError blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (VoidPerasError blk) x -> VoidPerasError blk
forall blk x. VoidPerasError blk -> Rep (VoidPerasError blk) x
$cfrom :: forall blk x. VoidPerasError blk -> Rep (VoidPerasError blk) x
from :: forall x. VoidPerasError blk -> Rep (VoidPerasError blk) x
$cto :: forall blk x. Rep (VoidPerasError blk) x -> VoidPerasError blk
to :: forall x. Rep (VoidPerasError blk) x -> VoidPerasError blk
Generic, Proxy (VoidPerasError blk) -> String
(Proxy (VoidPerasError blk) -> String)
-> ShowProxy (VoidPerasError blk)
forall blk. Proxy (VoidPerasError blk) -> String
forall {k} (p :: k). (Proxy p -> String) -> ShowProxy p
$cshowProxy :: forall blk. Proxy (VoidPerasError blk) -> String
showProxy :: Proxy (VoidPerasError blk) -> String
ShowProxy, Show (VoidPerasError blk)
Typeable (VoidPerasError blk)
(Typeable (VoidPerasError blk), Show (VoidPerasError blk)) =>
(VoidPerasError blk -> SomeException)
-> (SomeException -> Maybe (VoidPerasError blk))
-> (VoidPerasError blk -> String)
-> (VoidPerasError blk -> Bool)
-> Exception (VoidPerasError blk)
SomeException -> Maybe (VoidPerasError blk)
VoidPerasError blk -> Bool
VoidPerasError blk -> String
VoidPerasError blk -> SomeException
forall blk. Typeable blk => Show (VoidPerasError blk)
forall blk. Typeable blk => Typeable (VoidPerasError blk)
forall e.
(Typeable e, Show e) =>
(e -> SomeException)
-> (SomeException -> Maybe e)
-> (e -> String)
-> (e -> Bool)
-> Exception e
forall blk.
Typeable blk =>
SomeException -> Maybe (VoidPerasError blk)
forall blk. Typeable blk => VoidPerasError blk -> Bool
forall blk. Typeable blk => VoidPerasError blk -> String
forall blk. Typeable blk => VoidPerasError blk -> SomeException
$ctoException :: forall blk. Typeable blk => VoidPerasError blk -> SomeException
toException :: VoidPerasError blk -> SomeException
$cfromException :: forall blk.
Typeable blk =>
SomeException -> Maybe (VoidPerasError blk)
fromException :: SomeException -> Maybe (VoidPerasError blk)
$cdisplayException :: forall blk. Typeable blk => VoidPerasError blk -> String
displayException :: VoidPerasError blk -> String
$cbacktraceDesired :: forall blk. Typeable blk => VoidPerasError blk -> Bool
backtraceDesired :: VoidPerasError blk -> Bool
Exception)

-- | Void Peras committee for @blk@.
data VoidPerasVotingCommitteeScheme
  deriving (Int -> VoidPerasVotingCommitteeScheme -> ShowS
[VoidPerasVotingCommitteeScheme] -> ShowS
VoidPerasVotingCommitteeScheme -> String
(Int -> VoidPerasVotingCommitteeScheme -> ShowS)
-> (VoidPerasVotingCommitteeScheme -> String)
-> ([VoidPerasVotingCommitteeScheme] -> ShowS)
-> Show VoidPerasVotingCommitteeScheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VoidPerasVotingCommitteeScheme -> ShowS
showsPrec :: Int -> VoidPerasVotingCommitteeScheme -> ShowS
$cshow :: VoidPerasVotingCommitteeScheme -> String
show :: VoidPerasVotingCommitteeScheme -> String
$cshowList :: [VoidPerasVotingCommitteeScheme] -> ShowS
showList :: [VoidPerasVotingCommitteeScheme] -> ShowS
Show, VoidPerasVotingCommitteeScheme
-> VoidPerasVotingCommitteeScheme -> Bool
(VoidPerasVotingCommitteeScheme
 -> VoidPerasVotingCommitteeScheme -> Bool)
-> (VoidPerasVotingCommitteeScheme
    -> VoidPerasVotingCommitteeScheme -> Bool)
-> Eq VoidPerasVotingCommitteeScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VoidPerasVotingCommitteeScheme
-> VoidPerasVotingCommitteeScheme -> Bool
== :: VoidPerasVotingCommitteeScheme
-> VoidPerasVotingCommitteeScheme -> Bool
$c/= :: VoidPerasVotingCommitteeScheme
-> VoidPerasVotingCommitteeScheme -> Bool
/= :: VoidPerasVotingCommitteeScheme
-> VoidPerasVotingCommitteeScheme -> Bool
Eq, (forall x.
 VoidPerasVotingCommitteeScheme
 -> Rep VoidPerasVotingCommitteeScheme x)
-> (forall x.
    Rep VoidPerasVotingCommitteeScheme x
    -> VoidPerasVotingCommitteeScheme)
-> Generic VoidPerasVotingCommitteeScheme
forall x.
Rep VoidPerasVotingCommitteeScheme x
-> VoidPerasVotingCommitteeScheme
forall x.
VoidPerasVotingCommitteeScheme
-> Rep VoidPerasVotingCommitteeScheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
VoidPerasVotingCommitteeScheme
-> Rep VoidPerasVotingCommitteeScheme x
from :: forall x.
VoidPerasVotingCommitteeScheme
-> Rep VoidPerasVotingCommitteeScheme x
$cto :: forall x.
Rep VoidPerasVotingCommitteeScheme x
-> VoidPerasVotingCommitteeScheme
to :: forall x.
Rep VoidPerasVotingCommitteeScheme x
-> VoidPerasVotingCommitteeScheme
Generic, Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo)
Proxy VoidPerasVotingCommitteeScheme -> String
(Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo))
-> (Context
    -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo))
-> (Proxy VoidPerasVotingCommitteeScheme -> String)
-> NoThunks VoidPerasVotingCommitteeScheme
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo)
noThunks :: Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> VoidPerasVotingCommitteeScheme -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy VoidPerasVotingCommitteeScheme -> String
showTypeOf :: Proxy VoidPerasVotingCommitteeScheme -> String
NoThunks)

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

type instance ElectionId (VoidPerasCrypto blk) = PerasRoundNo
type instance VoteCandidate (VoidPerasCrypto blk) = Point blk

type instance PrivateKey (VoidPerasCrypto blk) = ()
type instance PublicKey (VoidPerasCrypto blk) = Void

instance CryptoSupportsVoteSigning (VoidPerasCrypto blk) where
  type VoteSigningKey (VoidPerasCrypto blk) = ()
  type VoteVerificationKey (VoidPerasCrypto blk) = Void
  data VoteSignature (VoidPerasCrypto blk) = VoidVoteSignature ()
  getVoteSigningKey :: Proxy (VoidPerasCrypto blk)
-> PrivateKey (VoidPerasCrypto blk)
-> VoteSigningKey (VoidPerasCrypto blk)
getVoteSigningKey Proxy (VoidPerasCrypto blk)
_proxy PrivateKey (VoidPerasCrypto blk)
_privateKey = ()
  getVoteVerificationKey :: Proxy (VoidPerasCrypto blk)
-> PublicKey (VoidPerasCrypto blk)
-> VoteVerificationKey (VoidPerasCrypto blk)
getVoteVerificationKey Proxy (VoidPerasCrypto blk)
_proxy PublicKey (VoidPerasCrypto blk)
publicKey = Void -> Void
forall a. Void -> a
absurd Void
PublicKey (VoidPerasCrypto blk)
publicKey
  signVote :: VoteSigningKey (VoidPerasCrypto blk)
-> ElectionId (VoidPerasCrypto blk)
-> VoteCandidate (VoidPerasCrypto blk)
-> VoteSignature (VoidPerasCrypto blk)
signVote VoteSigningKey (VoidPerasCrypto blk)
_signingKey ElectionId (VoidPerasCrypto blk)
_ VoteCandidate (VoidPerasCrypto blk)
_ = () -> VoteSignature (VoidPerasCrypto blk)
forall blk. () -> VoteSignature (VoidPerasCrypto blk)
VoidVoteSignature ()
  verifyVoteSignature :: VoteVerificationKey (VoidPerasCrypto blk)
-> ElectionId (VoidPerasCrypto blk)
-> VoteCandidate (VoidPerasCrypto blk)
-> VoteSignature (VoidPerasCrypto blk)
-> Either String ()
verifyVoteSignature VoteVerificationKey (VoidPerasCrypto blk)
verificationKey ElectionId (VoidPerasCrypto blk)
_ VoteCandidate (VoidPerasCrypto blk)
_ VoteSignature (VoidPerasCrypto blk)
_ = Void -> Either String ()
forall a. Void -> a
absurd Void
VoteVerificationKey (VoidPerasCrypto blk)
verificationKey

newtype instance VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
  = VoidPerasVotingCommittee Void

instance CryptoSupportsVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme where
  newtype VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    = VoidPerasVotingCommitteeError Void
  newtype VotingCommitteeInput (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    = VoidPerasVotingCommitteeInput Void
  newtype EligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    = VoidPerasEligibilityWitness Void
  newtype Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    = VoidPerasCert' {forall blk.
Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasCert blk
unCommitteeCert :: VoidPerasCert blk}
  newtype Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    = VoidPerasVote' {forall blk.
Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
unCommitteeVote :: VoidPerasVote blk}

  mkVotingCommittee :: VotingCommitteeInput
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (VotingCommittee
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
mkVotingCommittee (VoidPerasVotingCommitteeInput Void
void) = Void
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (VotingCommittee
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall a. Void -> a
absurd Void
void
  checkShouldVote :: VotingCommittee
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> PoolId
-> PrivateKey (VoidPerasCrypto blk)
-> ElectionId (VoidPerasCrypto blk)
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (Maybe
        (EligibilityWitness
           (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
checkShouldVote (VoidPerasVotingCommittee Void
void) PoolId
_ PrivateKey (VoidPerasCrypto blk)
_ ElectionId (VoidPerasCrypto blk)
_ = Void
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (Maybe
        (EligibilityWitness
           (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
forall a. Void -> a
absurd Void
void
  forgeVote :: EligibilityWitness
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> PrivateKey (VoidPerasCrypto blk)
-> ElectionId (VoidPerasCrypto blk)
-> VoteCandidate (VoidPerasCrypto blk)
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
forgeVote (VoidPerasEligibilityWitness Void
void) PrivateKey (VoidPerasCrypto blk)
_ ElectionId (VoidPerasCrypto blk)
_ VoteCandidate (VoidPerasCrypto blk)
_ = Void -> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
forall a. Void -> a
absurd Void
void
  verifyVote :: VotingCommittee
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (EligibilityWitness
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
verifyVote (VoidPerasVotingCommittee Void
void) Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
_ = Void
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (EligibilityWitness
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall a. Void -> a
absurd Void
void
  eligiblePartyVoteWeight :: VotingCommittee
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> EligibilityWitness
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoteWeight
eligiblePartyVoteWeight (VoidPerasVotingCommittee Void
void) EligibilityWitness
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
_ = Void -> VoteWeight
forall a. Void -> a
absurd Void
void
  forgeCert :: UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forgeCert = Void
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall a. Void -> a
absurd (Void
 -> Either
      (VotingCommitteeError
         (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
      (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
-> (UniqueVotesWithSameTarget
      (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> Void)
-> UniqueVotesWithSameTarget
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
forall {blk}.
UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
telescope
   where
    telescope :: UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
telescope = VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote (VoidPerasVote blk -> Void)
-> (UniqueVotesWithSameTarget
      (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> VoidPerasVote blk)
-> UniqueVotesWithSameTarget
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
forall blk.
Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
unCommitteeVote (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
 -> VoidPerasVote blk)
-> (UniqueVotesWithSameTarget
      (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
-> UniqueVotesWithSameTarget
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty
  (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
forall a. NonEmpty a -> a
NonEmpty.head (NonEmpty
   (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
 -> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
-> (UniqueVotesWithSameTarget
      (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> NonEmpty
         (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
-> UniqueVotesWithSameTarget
     (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> NonEmpty
     (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
UniqueVotesWithSameTarget
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> NE [Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme]
forall crypto committee.
UniqueVotesWithSameTarget crypto committee
-> NE [Vote crypto committee]
getRawVotes
  verifyCert :: VotingCommittee
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (NE
        [EligibilityWitness
           (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme])
verifyCert (VoidPerasVotingCommittee Void
void) Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
_ = Void
-> Either
     (VotingCommitteeError
        (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
     (NonEmpty
        (EligibilityWitness
           (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
forall a. Void -> a
absurd Void
void
  voteTarget :: Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> (ElectionId (VoidPerasCrypto blk),
    VoteCandidate (VoidPerasCrypto blk))
voteTarget (VoidPerasVote' (VoidPerasVote Void
void)) = Void -> (PerasRoundNo, Point blk)
forall a. Void -> a
absurd Void
void
  compareVotesById :: Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Ordering
compareVotesById (VoidPerasVote' (VoidPerasVote Void
void)) Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
_ = Void -> Ordering
forall a. Void -> a
absurd Void
void

-- | Exists solely to silence a 'defined-but-not-used' warning on the
-- 'VoidPerasVotingCommitteeError' constructor.
absurdVoidPerasVotingCommitteeError ::
  VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme ->
  a
absurdVoidPerasVotingCommitteeError :: forall blk a.
VotingCommitteeError
  (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> a
absurdVoidPerasVotingCommitteeError (VoidPerasVotingCommitteeError Void
void) =
  Void -> a
forall a. Void -> a
absurd Void
void

-- | Exists solely to silence a 'defined-but-not-used' warning on the
-- 'VoidPerasCert' constructor.
absurdVoidPerasCert ::
  Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme ->
  a
absurdVoidPerasCert :: forall blk a.
Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme -> a
absurdVoidPerasCert (VoidPerasCert' (VoidPerasCert Void
void)) =
  Void -> a
forall a. Void -> a
absurd Void
void

deriving newtype instance
  Show (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
deriving newtype instance
  Eq (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
deriving newtype instance
  NoThunks (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
deriving newtype instance
  Generic (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)

deriving newtype instance
  Typeable blk =>
  FromCBOR (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
deriving newtype instance
  Typeable blk =>
  ToCBOR (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)

instance
  PerasVoteCompatibleWithVotingCommittee
    (VoidPerasVote blk)
    (VoidPerasCrypto blk)
    VoidPerasVotingCommitteeScheme
  where
  toPerasVote :: Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either PerasConversionError (VoidPerasVote blk)
toPerasVote = Void -> Either PerasConversionError (VoidPerasVote blk)
forall a. Void -> a
absurd (Void -> Either PerasConversionError (VoidPerasVote blk))
-> (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> Void)
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either PerasConversionError (VoidPerasVote blk)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote (VoidPerasVote blk -> Void)
-> (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> VoidPerasVote blk)
-> Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
forall blk.
Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasVote blk
unCommitteeVote
  fromPerasVote :: VoidPerasVote blk
-> Either
     PerasConversionError
     (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
fromPerasVote = Void
-> Either
     PerasConversionError
     (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall a. Void -> a
absurd (Void
 -> Either
      PerasConversionError
      (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
-> (VoidPerasVote blk -> Void)
-> VoidPerasVote blk
-> Either
     PerasConversionError
     (Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasVote blk -> Void
forall blk. VoidPerasVote blk -> Void
unVoidPerasVote

instance
  PerasCertCompatibleWithVotingCommittee
    (VoidPerasCert blk)
    (VoidPerasCrypto blk)
    VoidPerasVotingCommitteeScheme
  where
  toPerasCert :: Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either PerasConversionError (VoidPerasCert blk)
toPerasCert = Void -> Either PerasConversionError (VoidPerasCert blk)
forall a. Void -> a
absurd (Void -> Either PerasConversionError (VoidPerasCert blk))
-> (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> Void)
-> Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Either PerasConversionError (VoidPerasCert blk)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasCert blk -> Void
forall blk. VoidPerasCert blk -> Void
unVoidPerasCert (VoidPerasCert blk -> Void)
-> (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
    -> VoidPerasCert blk)
-> Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> Void
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasCert blk
forall blk.
Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme
-> VoidPerasCert blk
unCommitteeCert
  fromPerasCert :: VoidPerasCert blk
-> Either
     PerasConversionError
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
fromPerasCert = Void
-> Either
     PerasConversionError
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall a. Void -> a
absurd (Void
 -> Either
      PerasConversionError
      (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme))
-> (VoidPerasCert blk -> Void)
-> VoidPerasCert blk
-> Either
     PerasConversionError
     (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VoidPerasCert blk -> Void
forall blk. VoidPerasCert blk -> Void
unVoidPerasCert