Skip to content

Commit

Permalink
committee key-hash: support extended CC keys
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Apr 15, 2024
1 parent d7b8539 commit 9c6fbff
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ runGovernanceCommitteeKeyGenHot

data SomeCommitteeKey
= ACommitteeHotKey (VerificationKey CommitteeHotKey)
| ACommitteeHotExtendedKey (VerificationKey CommitteeHotExtendedKey)
| ACommitteeColdKey (VerificationKey CommitteeColdKey)
| ACommitteeColdExtendedKey (VerificationKey CommitteeColdExtendedKey)

runGovernanceCommitteeKeyHash :: ()
=> Cmd.GovernanceCommitteeKeyHashCmdArgs era
Expand All @@ -94,15 +96,19 @@ runGovernanceCommitteeKeyHash
case vkeySource of
AnyVerificationKeySourceOfText vkText -> do
let asTypes =
[ FromSomeType (AsVerificationKey AsCommitteeHotKey ) ACommitteeHotKey
, FromSomeType (AsVerificationKey AsCommitteeColdKey) ACommitteeColdKey
[ FromSomeType (AsVerificationKey AsCommitteeHotKey) ACommitteeHotKey
, FromSomeType (AsVerificationKey AsCommitteeHotExtendedKey) ACommitteeHotExtendedKey
, FromSomeType (AsVerificationKey AsCommitteeColdKey) ACommitteeColdKey
, FromSomeType (AsVerificationKey AsCommitteeColdExtendedKey) ACommitteeColdExtendedKey
]
pure (deserialiseAnyOfFromBech32 asTypes (unAnyVerificationKeyText vkText))
& onLeft (left . GovernanceCommitteeCmdKeyDecodeError . InputBech32DecodeError)
AnyVerificationKeySourceOfFile vkeyPath -> do
let asTypes =
[ FromSomeType (AsVerificationKey AsCommitteeHotKey ) ACommitteeHotKey
, FromSomeType (AsVerificationKey AsCommitteeColdKey) ACommitteeColdKey
[ FromSomeType (AsVerificationKey AsCommitteeHotKey) ACommitteeHotKey
, FromSomeType (AsVerificationKey AsCommitteeHotExtendedKey) ACommitteeHotExtendedKey
, FromSomeType (AsVerificationKey AsCommitteeColdKey) ACommitteeColdKey
, FromSomeType (AsVerificationKey AsCommitteeColdExtendedKey) ACommitteeColdExtendedKey
]
readFileTextEnvelopeAnyOf asTypes vkeyPath
& firstExceptT GovernanceCommitteeCmdTextEnvReadFileError . newExceptT
Expand All @@ -112,8 +118,10 @@ runGovernanceCommitteeKeyHash
where
renderKeyHash :: SomeCommitteeKey -> ByteString
renderKeyHash = \case
ACommitteeHotKey vk -> renderVerificationKeyHash vk
ACommitteeColdKey vk -> renderVerificationKeyHash vk
ACommitteeHotKey vk -> renderVerificationKeyHash vk
ACommitteeHotExtendedKey vk -> renderVerificationKeyHash vk
ACommitteeColdKey vk -> renderVerificationKeyHash vk
ACommitteeColdExtendedKey vk -> renderVerificationKeyHash vk

renderVerificationKeyHash :: Key keyrole => VerificationKey keyrole -> ByteString
renderVerificationKeyHash = serialiseToRawBytesHex
Expand Down

0 comments on commit 9c6fbff

Please sign in to comment.