Skip to content

Commit

Permalink
Accept KES and VRF keys of different formats in Shelley readLeaderCre…
Browse files Browse the repository at this point in the history
…dentials
  • Loading branch information
intricate authored and newhoggy committed Mar 17, 2023
1 parent eec046a commit aca3138
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cardano-node/src/Cardano/Node/Protocol/Shelley.hs
Expand Up @@ -47,6 +47,7 @@ import Ouroboros.Consensus.Shelley.Node (Nonce (..), ProtocolParamsShe
import Cardano.Ledger.BaseTypes (ProtVer (..))
import qualified Cardano.Ledger.Shelley.Genesis as Shelley

import Cardano.Api.DeserialiseAnyOf (readFileTextEnvelope')
import Cardano.Api.Orphans ()
import Cardano.Api.Shelley hiding (FileError)

Expand Down Expand Up @@ -166,7 +167,7 @@ readLeaderCredentialsSingleton
shelleyKESFile = Just kesFile
} = do
vrfSKey <-
firstExceptT FileError (newExceptT $ readFileTextEnvelope (AsSigningKey AsVrfKey) vrfFile)
firstExceptT FileError (newExceptT $ readFileTextEnvelope' (AsSigningKey AsVrfKey) vrfFile)

(opCert, kesSKey) <- opCertKesKeyCheck kesFile opCertFile

Expand All @@ -188,9 +189,9 @@ opCertKesKeyCheck
-> ExceptT PraosLeaderCredentialsError IO (OperationalCertificate, SigningKey KesKey)
opCertKesKeyCheck kesFile certFile = do
opCert <-
firstExceptT FileError (newExceptT $ readFileTextEnvelope AsOperationalCertificate certFile)
firstExceptT FileError (newExceptT $ readFileTextEnvelope' AsOperationalCertificate certFile)
kesSKey <-
firstExceptT FileError (newExceptT $ readFileTextEnvelope (AsSigningKey AsKesKey) kesFile)
firstExceptT FileError (newExceptT $ readFileTextEnvelope' (AsSigningKey AsKesKey) kesFile)
let opCertSpecifiedKesKeyhash = verificationKeyHash $ getHotKey opCert
suppliedKesKeyHash = verificationKeyHash $ getVerificationKey kesSKey
-- Specified KES key in operational certificate should match the one
Expand Down Expand Up @@ -266,7 +267,7 @@ parseEnvelope ::
-> (TextEnvelope, String)
-> ExceptT PraosLeaderCredentialsError IO a
parseEnvelope as (te, loc) =
firstExceptT (FileError . Api.FileError loc) . hoistEither $
firstExceptT (FileError . Api.FileError loc . InputTextEnvelopeError) . hoistEither $
deserialiseFromTextEnvelope as te


Expand Down Expand Up @@ -318,7 +319,7 @@ instance Error GenesisValidationError where
data PraosLeaderCredentialsError =
CredentialsReadError !FilePath !IOException
| EnvelopeParseError !FilePath !String
| FileError !(Api.FileError TextEnvelopeError)
| FileError !(Api.FileError InputDecodeError)
--TODO: pick a less generic constructor than FileError

| OCertNotSpecified
Expand Down

0 comments on commit aca3138

Please sign in to comment.