Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ runGenesisCreateTestNetDataCmd
skeyHotFile = File @(SigningKey ()) $ committeeDir </> "cc.hot.skey"
vkeyColdFile = File @(VerificationKey ()) $ committeeDir </> "cc.cold.vkey"
skeyColdFile = File @(SigningKey ()) $ committeeDir </> "cc.cold.skey"
hotArgs = CC.GovernanceCommitteeKeyGenHotCmdArgs eon vkeyHotFile skeyHotFile
coldArgs = CC.GovernanceCommitteeKeyGenColdCmdArgs eon vkeyColdFile skeyColdFile
hotArgs = CC.GovernanceCommitteeKeyGenHotCmdArgs eon desiredKeyOutputFormat vkeyHotFile skeyHotFile
coldArgs = CC.GovernanceCommitteeKeyGenColdCmdArgs eon desiredKeyOutputFormat vkeyColdFile skeyColdFile
liftIO $ createDirectoryIfMissing True committeeDir
void $
CC.runGovernanceCommitteeKeyGenHot hotArgs
Expand All @@ -337,7 +337,7 @@ runGenesisCreateTestNetDataCmd
let drepDir = drepsDir </> "drep" <> show index
vkeyFile = File @(VerificationKey ()) $ drepDir </> "drep.vkey"
skeyFile = File @(SigningKey ()) $ drepDir </> "drep.skey"
cmd = DRep.GovernanceDRepKeyGenCmdArgs eon vkeyFile skeyFile
cmd = DRep.GovernanceDRepKeyGenCmdArgs eon desiredKeyOutputFormat vkeyFile skeyFile
liftIO $ createDirectoryIfMissing True drepDir
fst <$> DRep.runGovernanceDRepKeyGenCmd cmd
Transient ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ import Cardano.Api
import Cardano.Api.Experimental qualified as Exp
import Cardano.Api.Ledger qualified as L

import Cardano.CLI.Type.Common (PotentiallyCheckedAnchor, ResignationMetadataUrl)
import Cardano.CLI.Type.Common
( FormatBech32
, FormatTextEnvelope
, PotentiallyCheckedAnchor
, ResignationMetadataUrl
)
import Cardano.CLI.Type.Key
import Cardano.CLI.Type.Key.VerificationKey

import Vary

data GovernanceCommitteeCmds era
= GovernanceCommitteeKeyGenColdCmd
(GovernanceCommitteeKeyGenColdCmdArgs era)
Expand All @@ -37,6 +44,7 @@ data GovernanceCommitteeCmds era
data GovernanceCommitteeKeyGenColdCmdArgs era
= GovernanceCommitteeKeyGenColdCmdArgs
{ era :: !(Exp.Era era)
, keyOutputFormat :: !(Vary [FormatBech32, FormatTextEnvelope])
, vkeyOutFile :: !(File (VerificationKey ()) Out)
, skeyOutFile :: !(File (SigningKey ()) Out)
}
Expand All @@ -45,6 +53,7 @@ data GovernanceCommitteeKeyGenColdCmdArgs era
data GovernanceCommitteeKeyGenHotCmdArgs era
= GovernanceCommitteeKeyGenHotCmdArgs
{ era :: !(Exp.Era era)
, keyOutputFormat :: !(Vary [FormatBech32, FormatTextEnvelope])
, vkeyOutFile :: !(File (VerificationKey ()) Out)
, skeyOutFile :: !(File (SigningKey ()) Out)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pGovernanceCommitteeKeyGenColdCmd = do
pCmd w =
fmap GovernanceCommitteeKeyGenColdCmd $
GovernanceCommitteeKeyGenColdCmdArgs w
<$> pColdVerificationKeyFile
<$> pKeyOutputFormat
<*> pColdVerificationKeyFile
<*> pColdSigningKeyFile

pGovernanceCommitteeKeyGenHotCmd
Expand All @@ -70,7 +71,8 @@ pGovernanceCommitteeKeyGenHotCmd = do
pCmd w =
fmap GovernanceCommitteeKeyGenHotCmd $
GovernanceCommitteeKeyGenHotCmdArgs w
<$> pVerificationKeyFileOut
<$> pKeyOutputFormat
<*> pVerificationKeyFileOut
<*> pSigningKeyFileOut

pGovernanceCommitteeKeyHashCmd
Expand Down
84 changes: 71 additions & 13 deletions cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ import Cardano.CLI.EraIndependent.Hash.Internal.Common (carryHashChecks)
import Cardano.CLI.EraIndependent.Key.Run qualified as Key
import Cardano.CLI.Orphan ()
import Cardano.CLI.Read (readVerificationKeySource)
import Cardano.CLI.Type.Common (PotentiallyCheckedAnchor (..))
import Cardano.CLI.Type.Common
( FormatBech32 (..)
, FormatTextEnvelope (..)
, PotentiallyCheckedAnchor (..)
)
import Cardano.CLI.Type.Key.VerificationKey

import Control.Monad (void)
import Data.ByteString (ByteString)
import Data.ByteString.Char8 qualified as BS
import Data.Function
import Vary qualified

runGovernanceCommitteeCmds
:: ()
Expand All @@ -63,16 +68,44 @@ runGovernanceCommitteeKeyGenCold
-> CIO e (VerificationKey CommitteeColdKey, SigningKey CommitteeColdKey)
runGovernanceCommitteeKeyGenCold
Cmd.GovernanceCommitteeKeyGenColdCmdArgs
{ Cmd.vkeyOutFile = vkeyPath
{ Cmd.keyOutputFormat
, Cmd.vkeyOutFile = vkeyPath
, Cmd.skeyOutFile = skeyPath
} = do
skey <- generateSigningKey AsCommitteeColdKey
let vkey = getVerificationKey skey

fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey)
fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just Key.ccColdVkeyDesc) vkey)
keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile skeyPath
$ serialiseToBech32 skey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile skeyPath $
textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey
)
$ Vary.exhaustiveCase
)

keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile vkeyPath
$ serialiseToBech32 vkey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile vkeyPath $
textEnvelopeToJSON (Just Key.ccColdVkeyDesc) vkey
)
$ Vary.exhaustiveCase
)

return (vkey, skey)

Expand All @@ -81,20 +114,45 @@ runGovernanceCommitteeKeyGenHot
-> CIO e (VerificationKey CommitteeHotKey, SigningKey CommitteeHotKey)
runGovernanceCommitteeKeyGenHot
Cmd.GovernanceCommitteeKeyGenHotCmdArgs
{ Cmd.era = _eon
{ Cmd.keyOutputFormat
, Cmd.vkeyOutFile = vkeyPath
, Cmd.skeyOutFile = skeyPath
} = do
skey <- generateSigningKey AsCommitteeHotKey

let vkey = getVerificationKey skey

fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile skeyPath $
textEnvelopeToJSON (Just Key.ccHotSkeyDesc) skey
fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile vkeyPath $
textEnvelopeToJSON (Just Key.ccHotVkeyDesc) vkey
keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile skeyPath
$ serialiseToBech32 skey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile skeyPath $
textEnvelopeToJSON (Just Key.ccHotSkeyDesc) skey
)
$ Vary.exhaustiveCase
)

keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile vkeyPath
$ serialiseToBech32 vkey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile vkeyPath $
textEnvelopeToJSON (Just Key.ccHotVkeyDesc) vkey
)
$ Vary.exhaustiveCase
)

return (vkey, skey)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data GovernanceDRepCmds era
data GovernanceDRepKeyGenCmdArgs era
= GovernanceDRepKeyGenCmdArgs
{ era :: !(Exp.Era era)
, keyOutputFormat :: !(Vary [FormatBech32, FormatTextEnvelope])
, vkeyFile :: !(File (VerificationKey ()) Out)
, skeyFile :: !(File (SigningKey ()) Out)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ pGovernanceDRepKeyGenCmd = do
$ Opt.info
( fmap GovernanceDRepKeyGenCmd $
GovernanceDRepKeyGenCmdArgs Exp.useEra
<$> pVerificationKeyFileOut
<$> pKeyOutputFormat
<*> pVerificationKeyFileOut
<*> pSigningKeyFileOut
)
$ Opt.progDesc "Generate Delegated Representative verification and signing keys."
Expand Down
38 changes: 33 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,43 @@ runGovernanceDRepKeyGenCmd
-> CIO e (VerificationKey DRepKey, SigningKey DRepKey)
runGovernanceDRepKeyGenCmd
Cmd.GovernanceDRepKeyGenCmdArgs
{ vkeyFile
{ keyOutputFormat
, vkeyFile
, skeyFile
} = do
(vkey, skey) <- generateKeyPair AsDRepKey
fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile skeyFile (textEnvelopeToJSON (Just Key.drepSkeyDesc) skey)

fromEitherIOCli @(FileError ()) $
writeLazyByteStringFile vkeyFile (textEnvelopeToJSON (Just Key.drepVkeyDesc) vkey)
keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile skeyFile
$ serialiseToBech32 skey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile skeyFile $
textEnvelopeToJSON (Just Key.drepSkeyDesc) skey
)
$ Vary.exhaustiveCase
)

keyOutputFormat
& ( id
. Vary.on
( \FormatBech32 ->
fromEitherIOCli @(FileError ())
. writeTextFile vkeyFile
$ serialiseToBech32 vkey
)
. Vary.on
( \FormatTextEnvelope ->
fromEitherIOCli @(FileError ()) . writeLazyByteStringFile vkeyFile $
textEnvelopeToJSON (Just Key.drepVkeyDesc) vkey
)
$ Vary.exhaustiveCase
)

return (vkey, skey)

Expand Down
54 changes: 48 additions & 6 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -1502,12 +1502,21 @@ Usage: cardano-cli conway governance committee
Committee member commands.

Usage: cardano-cli conway governance committee key-gen-cold
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--cold-verification-key-file FILEPATH
--cold-signing-key-file FILEPATH

Create a cold key pair for a Constitutional Committee Member

Usage: cardano-cli conway governance committee key-gen-hot --verification-key-file FILEPATH
Usage: cardano-cli conway governance committee key-gen-hot
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Create a hot key pair for a Constitutional Committee Member
Expand Down Expand Up @@ -1561,7 +1570,12 @@ Usage: cardano-cli conway governance drep

DRep member commands.

Usage: cardano-cli conway governance drep key-gen --verification-key-file FILEPATH
Usage: cardano-cli conway governance drep key-gen
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Generate Delegated Representative verification and signing keys.
Expand Down Expand Up @@ -3906,12 +3920,21 @@ Usage: cardano-cli latest governance committee
Committee member commands.

Usage: cardano-cli latest governance committee key-gen-cold
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--cold-verification-key-file FILEPATH
--cold-signing-key-file FILEPATH

Create a cold key pair for a Constitutional Committee Member

Usage: cardano-cli latest governance committee key-gen-hot --verification-key-file FILEPATH
Usage: cardano-cli latest governance committee key-gen-hot
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Create a hot key pair for a Constitutional Committee Member
Expand Down Expand Up @@ -3965,7 +3988,12 @@ Usage: cardano-cli latest governance drep

DRep member commands.

Usage: cardano-cli latest governance drep key-gen --verification-key-file FILEPATH
Usage: cardano-cli latest governance drep key-gen
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Generate Delegated Representative verification and signing keys.
Expand Down Expand Up @@ -7289,12 +7317,21 @@ Usage: cardano-cli compatible conway governance committee
Committee member commands.

Usage: cardano-cli compatible conway governance committee key-gen-cold
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--cold-verification-key-file FILEPATH
--cold-signing-key-file FILEPATH

Create a cold key pair for a Constitutional Committee Member

Usage: cardano-cli compatible conway governance committee key-gen-hot --verification-key-file FILEPATH
Usage: cardano-cli compatible conway governance committee key-gen-hot
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Create a hot key pair for a Constitutional Committee Member
Expand Down Expand Up @@ -7348,7 +7385,12 @@ Usage: cardano-cli compatible conway governance drep

DRep member commands.

Usage: cardano-cli compatible conway governance drep key-gen --verification-key-file FILEPATH
Usage: cardano-cli compatible conway governance drep key-gen
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--verification-key-file FILEPATH
--signing-key-file FILEPATH

Generate Delegated Representative verification and signing keys.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
Usage: cardano-cli compatible conway governance committee key-gen-cold
[ --key-output-bech32
| --key-output-text-envelope
| --key-output-format STRING
]
--cold-verification-key-file FILEPATH
--cold-signing-key-file FILEPATH

Create a cold key pair for a Constitutional Committee Member

Available options:
--key-output-bech32 Format key output to BECH32.
--key-output-text-envelope
Format key output to TEXT_ENVELOPE (default).
--key-output-format STRING
Optional key output format. Accepted output formats
are "text-envelope" and "bech32". The
--key-output-format flag is deprecated and will be
removed in a future version.
--cold-verification-key-file FILEPATH
Filepath of the cold verification key.
--cold-signing-key-file FILEPATH
Expand Down
Loading
Loading