{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unused-pattern-binds #-}
{-# OPTIONS_HADDOCK not-home #-}

-- | Provides BlockBody internals
--
-- = Warning
--
-- This module is considered __internal__.
--
-- The contents of this module may change __in any way whatsoever__
-- and __without any warning__ between minor versions of this package.
module Cardano.Ledger.Dijkstra.BlockBody.Internal (
  DijkstraBlockBody (DijkstraBlockBody, MkDijkstraBlockBody),
  DijkstraBlockBodyRaw (..),
  mkBasicBlockBodyDijkstra,
  DijkstraEraBlockBody (..),
  PerasCert (..),
  PerasKey (..),
  validatePerasCert,
) where

import Cardano.Crypto.Leios (LeiosCert)
import Cardano.Ledger.Alonzo.Tx (AlonzoEraTx (..))
import Cardano.Ledger.BaseTypes (Nonce, ProtVer (..))
import Cardano.Ledger.Binary (
  Annotator (..),
  DecCBOR (..),
  EncCBOR,
  decodeNullStrictMaybe,
  decodeRecordNamed,
  decodeSeq,
  encCBOR,
  encodeFoldableEncoder,
  encodeListLen,
  encodeNullStrictMaybe,
  serialize',
 )
import Cardano.Ledger.Core
import Cardano.Ledger.Dijkstra.Era
import Cardano.Ledger.Dijkstra.Tx (
  DijkstraTx,
  Tx (..),
  decodeDijkstraTopTxInBlock,
  toCBORForBlockInclusion,
 )
import Cardano.Ledger.MemoBytes (
  Mem,
  MemoBytes,
  MemoHashIndex,
  Memoized (..),
  getMemoBytesHash,
  getMemoRawType,
  lensMemoRawType,
  mkMemoized,
  mkMemoizedEra,
 )
import Cardano.Ledger.Orphans ()
import Control.DeepSeq (NFData)
import Data.Array.Byte (ByteArray)
import qualified Data.ByteString as BS
import Data.Coerce (Coercible, coerce)
import Data.Maybe.Strict (StrictMaybe (..))
import Data.Sequence.Strict (StrictSeq)
import qualified Data.Sequence.Strict as StrictSeq
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks)

-- =================================================

-- $BlockBody
--
-- * BlockBody
--
-- Unlike in the previous eras, transactions in a Dijkstra block body are not
-- deconstructed into segregated components. Each transaction is serialized
-- whole, as @[transaction_body, transaction_witness_set, auxiliary_data\/ nil,
-- is_valid]@, with the block-producer-supplied `IsPhase2Valid` flag as the
-- trailing element.

data DijkstraBlockBodyRaw era = DijkstraBlockBodyRaw
  { forall era. DijkstraBlockBodyRaw era -> StrictSeq (Tx TopTx era)
dbbrTxs :: !(StrictSeq (Tx TopTx era))
  , forall era. DijkstraBlockBodyRaw era -> StrictMaybe LeiosCert
dbbrLeiosCert :: !(StrictMaybe LeiosCert)
  -- ^ Optional Leios certificate
  , forall era. DijkstraBlockBodyRaw era -> StrictMaybe PerasCert
dbbrPerasCert :: !(StrictMaybe PerasCert)
  -- ^ Optional Peras certificate
  }
  deriving ((forall x.
 DijkstraBlockBodyRaw era -> Rep (DijkstraBlockBodyRaw era) x)
-> (forall x.
    Rep (DijkstraBlockBodyRaw era) x -> DijkstraBlockBodyRaw era)
-> Generic (DijkstraBlockBodyRaw era)
forall x.
Rep (DijkstraBlockBodyRaw era) x -> DijkstraBlockBodyRaw era
forall x.
DijkstraBlockBodyRaw era -> Rep (DijkstraBlockBodyRaw era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (DijkstraBlockBodyRaw era) x -> DijkstraBlockBodyRaw era
forall era x.
DijkstraBlockBodyRaw era -> Rep (DijkstraBlockBodyRaw era) x
$cfrom :: forall era x.
DijkstraBlockBodyRaw era -> Rep (DijkstraBlockBodyRaw era) x
from :: forall x.
DijkstraBlockBodyRaw era -> Rep (DijkstraBlockBodyRaw era) x
$cto :: forall era x.
Rep (DijkstraBlockBodyRaw era) x -> DijkstraBlockBodyRaw era
to :: forall x.
Rep (DijkstraBlockBodyRaw era) x -> DijkstraBlockBodyRaw era
Generic)

instance
  (NFData (Tx TopTx era), NFData LeiosCert, NFData PerasCert) =>
  NFData (DijkstraBlockBodyRaw era)

type instance MemoHashIndex (DijkstraBlockBodyRaw era) = EraIndependentBlockBody

instance EraBlockBody DijkstraEra where
  type BlockBody DijkstraEra = DijkstraBlockBody DijkstraEra
  mkBasicBlockBody :: BlockBody DijkstraEra
mkBasicBlockBody = BlockBody DijkstraEra
DijkstraBlockBody DijkstraEra
forall era. AlonzoEraTx era => DijkstraBlockBody era
mkBasicBlockBodyDijkstra
  txSeqBlockBodyL :: Lens' (BlockBody DijkstraEra) (StrictSeq (Tx TopTx DijkstraEra))
txSeqBlockBodyL = forall era t a b.
(Era era, EncCBOR (RawType t), Memoized t) =>
(RawType t -> a) -> (RawType t -> b -> RawType t) -> Lens t t a b
lensMemoRawType @DijkstraEra RawType (DijkstraBlockBody DijkstraEra)
-> StrictSeq (Tx TopTx DijkstraEra)
DijkstraBlockBodyRaw DijkstraEra
-> StrictSeq (Tx TopTx DijkstraEra)
forall era. DijkstraBlockBodyRaw era -> StrictSeq (Tx TopTx era)
dbbrTxs (\RawType (DijkstraBlockBody DijkstraEra)
bb StrictSeq (Tx TopTx DijkstraEra)
p -> RawType (DijkstraBlockBody DijkstraEra)
bb {dbbrTxs = p})
  hashBlockBody :: BlockBody DijkstraEra -> Hash HASH EraIndependentBlockBody
hashBlockBody (MkDijkstraBlockBody MemoBytes (DijkstraBlockBodyRaw DijkstraEra)
m) = SafeHash EraIndependentBlockBody
-> Hash HASH EraIndependentBlockBody
forall i. SafeHash i -> Hash HASH i
extractHash (SafeHash EraIndependentBlockBody
 -> Hash HASH EraIndependentBlockBody)
-> SafeHash EraIndependentBlockBody
-> Hash HASH EraIndependentBlockBody
forall a b. (a -> b) -> a -> b
$ MemoBytes (DijkstraBlockBodyRaw DijkstraEra)
-> SafeHash (MemoHashIndex (DijkstraBlockBodyRaw DijkstraEra))
forall t. MemoBytes t -> SafeHash (MemoHashIndex t)
getMemoBytesHash MemoBytes (DijkstraBlockBodyRaw DijkstraEra)
m
  blockBodySize :: ProtVer -> BlockBody DijkstraEra -> Int
blockBodySize (ProtVer Version
v Word32
_) = ByteString -> Int
BS.length (ByteString -> Int)
-> (DijkstraBlockBody DijkstraEra -> ByteString)
-> DijkstraBlockBody DijkstraEra
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> Encoding -> ByteString
forall a. EncCBOR a => Version -> a -> ByteString
serialize' Version
v (Encoding -> ByteString)
-> (DijkstraBlockBody DijkstraEra -> Encoding)
-> DijkstraBlockBody DijkstraEra
-> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DijkstraBlockBody DijkstraEra -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR

mkBasicBlockBodyDijkstra :: forall era. AlonzoEraTx era => DijkstraBlockBody era
mkBasicBlockBodyDijkstra :: forall era. AlonzoEraTx era => DijkstraBlockBody era
mkBasicBlockBodyDijkstra =
  Version -> RawType (DijkstraBlockBody era) -> DijkstraBlockBody era
forall t.
(EncCBOR (RawType t), Memoized t) =>
Version -> RawType t -> t
mkMemoized (forall era. Era era => Version
eraProtVerLow @era) (RawType (DijkstraBlockBody era) -> DijkstraBlockBody era)
-> RawType (DijkstraBlockBody era) -> DijkstraBlockBody era
forall a b. (a -> b) -> a -> b
$
    StrictSeq (Tx TopTx era)
-> StrictMaybe LeiosCert
-> StrictMaybe PerasCert
-> DijkstraBlockBodyRaw era
forall era.
StrictSeq (Tx TopTx era)
-> StrictMaybe LeiosCert
-> StrictMaybe PerasCert
-> DijkstraBlockBodyRaw era
DijkstraBlockBodyRaw StrictSeq (Tx TopTx era)
forall a. Monoid a => a
mempty StrictMaybe LeiosCert
forall a. StrictMaybe a
SNothing StrictMaybe PerasCert
forall a. StrictMaybe a
SNothing
{-# INLINEABLE mkBasicBlockBodyDijkstra #-}

-- | Dijkstra-specific extensions to 'EraBlockBody'
class EraBlockBody era => DijkstraEraBlockBody era where
  leiosCertBlockBodyL :: Lens' (BlockBody era) (StrictMaybe LeiosCert)
  -- ^ Lens to access the optional Leios certificate in the block body

  perasCertBlockBodyL :: Lens' (BlockBody era) (StrictMaybe PerasCert)
  -- ^ Lens to access the optional Peras certificate in the block body

instance DijkstraEraBlockBody DijkstraEra where
  leiosCertBlockBodyL :: Lens' (BlockBody DijkstraEra) (StrictMaybe LeiosCert)
leiosCertBlockBodyL = forall era t a b.
(Era era, EncCBOR (RawType t), Memoized t) =>
(RawType t -> a) -> (RawType t -> b -> RawType t) -> Lens t t a b
lensMemoRawType @DijkstraEra RawType (DijkstraBlockBody DijkstraEra) -> StrictMaybe LeiosCert
DijkstraBlockBodyRaw DijkstraEra -> StrictMaybe LeiosCert
forall era. DijkstraBlockBodyRaw era -> StrictMaybe LeiosCert
dbbrLeiosCert (\RawType (DijkstraBlockBody DijkstraEra)
bb StrictMaybe LeiosCert
c -> RawType (DijkstraBlockBody DijkstraEra)
bb {dbbrLeiosCert = c})

  perasCertBlockBodyL :: Lens' (BlockBody DijkstraEra) (StrictMaybe PerasCert)
perasCertBlockBodyL = forall era t a b.
(Era era, EncCBOR (RawType t), Memoized t) =>
(RawType t -> a) -> (RawType t -> b -> RawType t) -> Lens t t a b
lensMemoRawType @DijkstraEra RawType (DijkstraBlockBody DijkstraEra) -> StrictMaybe PerasCert
DijkstraBlockBodyRaw DijkstraEra -> StrictMaybe PerasCert
forall era. DijkstraBlockBodyRaw era -> StrictMaybe PerasCert
dbbrPerasCert (\RawType (DijkstraBlockBody DijkstraEra)
bb StrictMaybe PerasCert
c -> RawType (DijkstraBlockBody DijkstraEra)
bb {dbbrPerasCert = c})

deriving instance (Typeable era, NoThunks (Tx TopTx era)) => NoThunks (DijkstraBlockBodyRaw era)

deriving stock instance Show (Tx TopTx era) => Show (DijkstraBlockBodyRaw era)

deriving stock instance Eq (Tx TopTx era) => Eq (DijkstraBlockBodyRaw era)

newtype DijkstraBlockBody era = MkDijkstraBlockBody (MemoBytes (DijkstraBlockBodyRaw era))
  deriving ((forall x. DijkstraBlockBody era -> Rep (DijkstraBlockBody era) x)
-> (forall x.
    Rep (DijkstraBlockBody era) x -> DijkstraBlockBody era)
-> Generic (DijkstraBlockBody era)
forall x. Rep (DijkstraBlockBody era) x -> DijkstraBlockBody era
forall x. DijkstraBlockBody era -> Rep (DijkstraBlockBody era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (DijkstraBlockBody era) x -> DijkstraBlockBody era
forall era x.
DijkstraBlockBody era -> Rep (DijkstraBlockBody era) x
$cfrom :: forall era x.
DijkstraBlockBody era -> Rep (DijkstraBlockBody era) x
from :: forall x. DijkstraBlockBody era -> Rep (DijkstraBlockBody era) x
$cto :: forall era x.
Rep (DijkstraBlockBody era) x -> DijkstraBlockBody era
to :: forall x. Rep (DijkstraBlockBody era) x -> DijkstraBlockBody era
Generic)

deriving instance Eq (Tx TopTx era) => Eq (DijkstraBlockBody era)

deriving instance Show (Tx TopTx era) => Show (DijkstraBlockBody era)

deriving newtype instance
  (NFData (Tx TopTx era), NFData PerasCert) => NFData (DijkstraBlockBody era)

deriving newtype instance EncCBOR (DijkstraBlockBody era)

instance Memoized (DijkstraBlockBody era) where
  type RawType (DijkstraBlockBody era) = DijkstraBlockBodyRaw era

pattern DijkstraBlockBody ::
  AlonzoEraTx era =>
  StrictSeq (Tx TopTx era) ->
  StrictMaybe LeiosCert ->
  StrictMaybe PerasCert ->
  DijkstraBlockBody era
pattern $mDijkstraBlockBody :: forall {r} {era}.
AlonzoEraTx era =>
DijkstraBlockBody era
-> (StrictSeq (Tx TopTx era)
    -> StrictMaybe LeiosCert -> StrictMaybe PerasCert -> r)
-> ((# #) -> r)
-> r
$bDijkstraBlockBody :: forall era.
AlonzoEraTx era =>
StrictSeq (Tx TopTx era)
-> StrictMaybe LeiosCert
-> StrictMaybe PerasCert
-> DijkstraBlockBody era
DijkstraBlockBody txs mbLeiosCert mbPerasCert <-
  ( getMemoRawType ->
      DijkstraBlockBodyRaw txs mbLeiosCert mbPerasCert
    )
  where
    DijkstraBlockBody StrictSeq (Tx TopTx era)
txs StrictMaybe LeiosCert
leiosCert StrictMaybe PerasCert
perasCert =
      forall era t.
(Era era, EncCBOR (RawType t), Memoized t) =>
RawType t -> t
mkMemoizedEra @DijkstraEra (RawType (DijkstraBlockBody era) -> DijkstraBlockBody era)
-> RawType (DijkstraBlockBody era) -> DijkstraBlockBody era
forall a b. (a -> b) -> a -> b
$
        StrictSeq (Tx TopTx era)
-> StrictMaybe LeiosCert
-> StrictMaybe PerasCert
-> DijkstraBlockBodyRaw era
forall era.
StrictSeq (Tx TopTx era)
-> StrictMaybe LeiosCert
-> StrictMaybe PerasCert
-> DijkstraBlockBodyRaw era
DijkstraBlockBodyRaw StrictSeq (Tx TopTx era)
txs StrictMaybe LeiosCert
leiosCert StrictMaybe PerasCert
perasCert

{-# COMPLETE DijkstraBlockBody #-}

--------------------------------------------------------------------------------
-- Serialisation and hashing
--------------------------------------------------------------------------------

instance AlonzoEraTx era => EncCBOR (DijkstraBlockBodyRaw era) where
  encCBOR :: DijkstraBlockBodyRaw era -> Encoding
encCBOR (DijkstraBlockBodyRaw StrictSeq (Tx TopTx era)
txs StrictMaybe LeiosCert
mbLeiosCert StrictMaybe PerasCert
mbPerasCert) =
    Word -> Encoding
encodeListLen Word
3
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (Tx TopTx era -> Encoding) -> StrictSeq (Tx TopTx era) -> Encoding
forall (f :: * -> *) a.
Foldable f =>
(a -> Encoding) -> f a -> Encoding
encodeFoldableEncoder Tx TopTx era -> Encoding
forall era. AlonzoEraTx era => Tx TopTx era -> Encoding
toCBORForBlockInclusion StrictSeq (Tx TopTx era)
txs
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (LeiosCert -> Encoding) -> StrictMaybe LeiosCert -> Encoding
forall a. (a -> Encoding) -> StrictMaybe a -> Encoding
encodeNullStrictMaybe LeiosCert -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR StrictMaybe LeiosCert
mbLeiosCert
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (PerasCert -> Encoding) -> StrictMaybe PerasCert -> Encoding
forall a. (a -> Encoding) -> StrictMaybe a -> Encoding
encodeNullStrictMaybe PerasCert -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR StrictMaybe PerasCert
mbPerasCert

instance
  ( AlonzoEraTx era
  , DecCBOR (Annotator (TxAuxData era))
  , DecCBOR (Annotator (TxBody TopTx era))
  , DecCBOR (Annotator (TxWits era))
  , Coercible (DijkstraTx TopTx era) (Tx TopTx era)
  ) =>
  DecCBOR (Annotator (DijkstraBlockBodyRaw era))
  where
  decCBOR :: forall s. Decoder s (Annotator (DijkstraBlockBodyRaw era))
decCBOR = Text
-> (Annotator (DijkstraBlockBodyRaw era) -> Int)
-> Decoder s (Annotator (DijkstraBlockBodyRaw era))
-> Decoder s (Annotator (DijkstraBlockBodyRaw era))
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"DijkstraBlockBodyRaw" (Int -> Annotator (DijkstraBlockBodyRaw era) -> Int
forall a b. a -> b -> a
const Int
3) (Decoder s (Annotator (DijkstraBlockBodyRaw era))
 -> Decoder s (Annotator (DijkstraBlockBodyRaw era)))
-> Decoder s (Annotator (DijkstraBlockBodyRaw era))
-> Decoder s (Annotator (DijkstraBlockBodyRaw era))
forall a b. (a -> b) -> a -> b
$ do
    txs <- Decoder s (Annotator (DijkstraTx TopTx era))
-> Decoder s (Seq (Annotator (DijkstraTx TopTx era)))
forall s a. Decoder s a -> Decoder s (Seq a)
decodeSeq (forall era s.
EraTx era =>
Decoder s (Annotator (DijkstraTx TopTx era))
decodeDijkstraTopTxInBlock @era)
    mbLeiosCert <- decodeNullStrictMaybe decCBOR
    mbPerasCert <- decodeNullStrictMaybe decCBOR
    pure $
      DijkstraBlockBodyRaw
        <$> sequenceA (StrictSeq.forceToStrict (coerce txs))
        <*> pure mbLeiosCert
        <*> pure mbPerasCert

deriving via
  Mem (DijkstraBlockBodyRaw era)
  instance
    ( AlonzoEraTx era
    , Coercible (DijkstraTx TopTx era) (Tx TopTx era)
    , DecCBOR (Annotator (TxAuxData era))
    , DecCBOR (Annotator (TxBody TopTx era))
    , DecCBOR (Annotator (TxWits era))
    ) =>
    DecCBOR (Annotator (DijkstraBlockBody era))

-- | Placeholder for Peras certificates
--
-- NOTE: The real type will be brought from 'cardano-base' once it's ready.
newtype PerasCert = PerasCert ByteArray
  deriving (PerasCert -> PerasCert -> Bool
(PerasCert -> PerasCert -> Bool)
-> (PerasCert -> PerasCert -> Bool) -> Eq PerasCert
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasCert -> PerasCert -> Bool
== :: PerasCert -> PerasCert -> Bool
$c/= :: PerasCert -> PerasCert -> Bool
/= :: PerasCert -> PerasCert -> Bool
Eq, Eq PerasCert
Eq PerasCert =>
(PerasCert -> PerasCert -> Ordering)
-> (PerasCert -> PerasCert -> Bool)
-> (PerasCert -> PerasCert -> Bool)
-> (PerasCert -> PerasCert -> Bool)
-> (PerasCert -> PerasCert -> Bool)
-> (PerasCert -> PerasCert -> PerasCert)
-> (PerasCert -> PerasCert -> PerasCert)
-> Ord PerasCert
PerasCert -> PerasCert -> Bool
PerasCert -> PerasCert -> Ordering
PerasCert -> PerasCert -> PerasCert
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 :: PerasCert -> PerasCert -> Ordering
compare :: PerasCert -> PerasCert -> Ordering
$c< :: PerasCert -> PerasCert -> Bool
< :: PerasCert -> PerasCert -> Bool
$c<= :: PerasCert -> PerasCert -> Bool
<= :: PerasCert -> PerasCert -> Bool
$c> :: PerasCert -> PerasCert -> Bool
> :: PerasCert -> PerasCert -> Bool
$c>= :: PerasCert -> PerasCert -> Bool
>= :: PerasCert -> PerasCert -> Bool
$cmax :: PerasCert -> PerasCert -> PerasCert
max :: PerasCert -> PerasCert -> PerasCert
$cmin :: PerasCert -> PerasCert -> PerasCert
min :: PerasCert -> PerasCert -> PerasCert
Ord, Int -> PerasCert -> ShowS
[PerasCert] -> ShowS
PerasCert -> String
(Int -> PerasCert -> ShowS)
-> (PerasCert -> String)
-> ([PerasCert] -> ShowS)
-> Show PerasCert
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasCert -> ShowS
showsPrec :: Int -> PerasCert -> ShowS
$cshow :: PerasCert -> String
show :: PerasCert -> String
$cshowList :: [PerasCert] -> ShowS
showList :: [PerasCert] -> ShowS
Show, (forall x. PerasCert -> Rep PerasCert x)
-> (forall x. Rep PerasCert x -> PerasCert) -> Generic PerasCert
forall x. Rep PerasCert x -> PerasCert
forall x. PerasCert -> Rep PerasCert x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasCert -> Rep PerasCert x
from :: forall x. PerasCert -> Rep PerasCert x
$cto :: forall x. Rep PerasCert x -> PerasCert
to :: forall x. Rep PerasCert x -> PerasCert
Generic)
  deriving newtype (PerasCert -> Encoding
(PerasCert -> Encoding) -> EncCBOR PerasCert
forall a. (a -> Encoding) -> EncCBOR a
$cencCBOR :: PerasCert -> Encoding
encCBOR :: PerasCert -> Encoding
EncCBOR, Typeable PerasCert
Typeable PerasCert =>
(forall s. Decoder s PerasCert)
-> (forall s. Proxy PerasCert -> Decoder s ())
-> (Proxy PerasCert -> Text)
-> DecCBOR PerasCert
Proxy PerasCert -> Text
forall s. Decoder s PerasCert
forall a.
Typeable a =>
(forall s. Decoder s a)
-> (forall s. Proxy a -> Decoder s ())
-> (Proxy a -> Text)
-> DecCBOR a
forall s. Proxy PerasCert -> Decoder s ()
$cdecCBOR :: forall s. Decoder s PerasCert
decCBOR :: forall s. Decoder s PerasCert
$cdropCBOR :: forall s. Proxy PerasCert -> Decoder s ()
dropCBOR :: forall s. Proxy PerasCert -> Decoder s ()
$clabel :: Proxy PerasCert -> Text
label :: Proxy PerasCert -> Text
DecCBOR)

instance NoThunks PerasCert

instance NFData PerasCert

-- | Placeholder for Peras public keys
--
-- NOTE: The real type will be brought from 'cardano-base' once it's ready.
data PerasKey = PerasKey
  deriving (PerasKey -> PerasKey -> Bool
(PerasKey -> PerasKey -> Bool)
-> (PerasKey -> PerasKey -> Bool) -> Eq PerasKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasKey -> PerasKey -> Bool
== :: PerasKey -> PerasKey -> Bool
$c/= :: PerasKey -> PerasKey -> Bool
/= :: PerasKey -> PerasKey -> Bool
Eq, Int -> PerasKey -> ShowS
[PerasKey] -> ShowS
PerasKey -> String
(Int -> PerasKey -> ShowS)
-> (PerasKey -> String) -> ([PerasKey] -> ShowS) -> Show PerasKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasKey -> ShowS
showsPrec :: Int -> PerasKey -> ShowS
$cshow :: PerasKey -> String
show :: PerasKey -> String
$cshowList :: [PerasKey] -> ShowS
showList :: [PerasKey] -> ShowS
Show, (forall x. PerasKey -> Rep PerasKey x)
-> (forall x. Rep PerasKey x -> PerasKey) -> Generic PerasKey
forall x. Rep PerasKey x -> PerasKey
forall x. PerasKey -> Rep PerasKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasKey -> Rep PerasKey x
from :: forall x. PerasKey -> Rep PerasKey x
$cto :: forall x. Rep PerasKey x -> PerasKey
to :: forall x. Rep PerasKey x -> PerasKey
Generic, Context -> PerasKey -> IO (Maybe ThunkInfo)
Proxy PerasKey -> String
(Context -> PerasKey -> IO (Maybe ThunkInfo))
-> (Context -> PerasKey -> IO (Maybe ThunkInfo))
-> (Proxy PerasKey -> String)
-> NoThunks PerasKey
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasKey -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasKey -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasKey -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasKey -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasKey -> String
showTypeOf :: Proxy PerasKey -> String
NoThunks)

-- | Mocked-up Peras certificate validation routine
--
-- NOTE: this function will be replaced with the real implementation from
-- 'cardano-base' once it's ready.
validatePerasCert :: Nonce -> PerasKey -> PerasCert -> Bool
validatePerasCert :: Nonce -> PerasKey -> PerasCert -> Bool
validatePerasCert Nonce
_ PerasKey
_ PerasCert
_ = Bool
True