3
3
{-# LANGUAGE DeriveGeneric #-}
4
4
{-# LANGUAGE DerivingVia #-}
5
5
{-# LANGUAGE FlexibleContexts #-}
6
+ {-# LANGUAGE GADTs #-}
6
7
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
8
+ {-# LANGUAGE LambdaCase #-}
7
9
{-# LANGUAGE ScopedTypeVariables #-}
8
10
{-# LANGUAGE TypeApplications #-}
9
11
{-# LANGUAGE TypeFamilies #-}
@@ -26,9 +28,10 @@ module Ouroboros.Consensus.Protocol.Praos.Common (
26
28
import qualified Cardano.Crypto.KES.Class as KES
27
29
import Cardano.Crypto.VRF
28
30
import qualified Cardano.Crypto.VRF as VRF
31
+ import qualified Cardano.KESAgent.KES.Crypto as Agent
29
32
import Cardano.Ledger.BaseTypes (Nonce )
30
33
import qualified Cardano.Ledger.BaseTypes as SL
31
- import Cardano.Ledger.Keys (KeyHash , KeyRole (BlockIssuer ))
34
+ import Cardano.Ledger.Keys (DSIGN , KeyHash , KeyRole (BlockIssuer ))
32
35
import qualified Cardano.Ledger.Shelley.API as SL
33
36
import Cardano.Protocol.Crypto (Crypto , KES , VRF )
34
37
import qualified Cardano.Protocol.TPraos.OCert as OCert
@@ -40,6 +43,7 @@ import Data.Map.Strict (Map)
40
43
import Data.Ord (Down (Down ))
41
44
import Data.Word (Word64 )
42
45
import GHC.Generics (Generic )
46
+ import NoThunks.Class
43
47
import Ouroboros.Consensus.Protocol.Abstract
44
48
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
45
49
import Ouroboros.Consensus.Protocol.Praos.AgentClient
@@ -267,18 +271,25 @@ instance (NoThunks (SignKeyVRF (VRF c)), NoThunks (KES.UnsoundPureSignKeyKES (KE
267
271
268
272
-- | Defines a method for obtaining Praos credentials (opcert + KES signing
269
273
-- key).
270
- data PraosCredentialsSource c
271
- = -- | Pass an opcert and sign key directly. This uses
274
+ data PraosCredentialsSource c where
275
+ -- | Pass an opcert and sign key directly. This uses
272
276
-- 'KES.UnsoundPureSignKeyKES', which does not provide mlocking guarantees,
273
277
-- violating the rule that KES secrets must never be stored on disk, but
274
278
-- allows the sign key to be loaded from a local file. This method is
275
279
-- provided for backwards compatibility.
276
- PraosCredentialsUnsound (OCert. OCert c ) (KES. UnsoundPureSignKeyKES (KES c ))
277
- | -- | Connect to a KES agent listening on a service socket at the given path.
278
- PraosCredentialsAgent FilePath
279
- deriving (Generic )
280
+ PraosCredentialsUnsound :: OCert. OCert c -> KES. UnsoundPureSignKeyKES (KES c ) -> PraosCredentialsSource c
281
+ -- | Connect to a KES agent listening on a service socket at the given path.
282
+ PraosCredentialsAgent :: Agent. DSIGN (ACrypto c ) ~ DSIGN => FilePath -> PraosCredentialsSource c
283
+
284
+ instance (NoThunks (KES. UnsoundPureSignKeyKES (KES c )), Crypto c ) => NoThunks (PraosCredentialsSource c ) where
285
+ wNoThunks ctxt = \ case
286
+ PraosCredentialsUnsound oca k -> allNoThunks [
287
+ noThunks ctxt oca
288
+ , noThunks ctxt k
289
+ ]
290
+ PraosCredentialsAgent fp -> noThunks ctxt fp
280
291
281
- instance ( NoThunks ( KES. UnsoundPureSignKeyKES ( KES c )), Crypto c ) => NoThunks ( PraosCredentialsSource c )
292
+ showTypeOf _ = " PraosCredentialsSource"
282
293
283
294
instantiatePraosCredentials :: forall m c .
284
295
( KESAgentContext c m
0 commit comments