Skip to content

Commit

Permalink
Merge pull request #556 from IntersectMBO/smelc/add-drep-extended-key…
Browse files Browse the repository at this point in the history
…-signing-support

Support signing with drep extended key
  • Loading branch information
smelc authored Jan 19, 2024
2 parents 24dd2e1 + 7b0c13b commit 838609b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ data SomeSigningWitness
| AGenesisDelegateExtendedSigningWitness (SigningKey GenesisDelegateExtendedKey)
| AGenesisUTxOSigningWitness (SigningKey GenesisUTxOKey)
| ADRepSigningWitness (SigningKey DRepKey)
| ADRepExtendedSigningWitness (SigningKey DRepExtendedKey)
| ACommitteeColdSigningWitness (SigningKey CommitteeColdKey)
| ACommitteeHotSigningWitness (SigningKey CommitteeHotKey)
deriving Show
Expand Down Expand Up @@ -673,14 +674,11 @@ categoriseSomeSigningWitness swsk =
AGenesisDelegateSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisDelegateKey sk)
AGenesisDelegateExtendedSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisDelegateExtendedKey sk)
AGenesisUTxOSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisUTxOKey sk)
ADRepSigningWitness sk -> AShelleyKeyWitness (WitnessPaymentKey $ castDrep sk)
ADRepSigningWitness sk -> AShelleyKeyWitness (WitnessDRepKey sk)
ADRepExtendedSigningWitness sk -> AShelleyKeyWitness (WitnessDRepExtendedKey sk)
ACommitteeColdSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeColdKey sk)
ACommitteeHotSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeHotKey sk)

-- TODO: Conway era - Add constrctor for SigningKey DrepKey to ShelleyWitnessSigningKey
castDrep :: SigningKey DRepKey -> SigningKey PaymentKey
castDrep (DRepSigningKey sk) = PaymentSigningKey sk

data ReadWitnessSigningDataError
= ReadWitnessSigningDataSigningKeyDecodeError !(FileError InputDecodeError)
| ReadWitnessSigningDataScriptError !(FileError JsonDecodeError)
Expand Down Expand Up @@ -727,6 +725,7 @@ readWitnessSigningData (KeyWitnessSigningData skFile mbByronAddr) = do
, FromSomeType (AsSigningKey AsGenesisDelegateExtendedKey ) AGenesisDelegateExtendedSigningWitness
, FromSomeType (AsSigningKey AsGenesisUTxOKey ) AGenesisUTxOSigningWitness
, FromSomeType (AsSigningKey AsDRepKey ) ADRepSigningWitness
, FromSomeType (AsSigningKey AsDRepExtendedKey ) ADRepExtendedSigningWitness
, FromSomeType (AsSigningKey AsCommitteeColdKey ) ACommitteeColdSigningWitness
, FromSomeType (AsSigningKey AsCommitteeHotKey ) ACommitteeHotSigningWitness
]
Expand Down
18 changes: 18 additions & 0 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ hprop_golden_governance_drep_id_hex =

H.diffFileVsGoldenFile idFile idGold

hprop_golden_governance_drep_extended_key_signing :: Property
hprop_golden_governance_drep_extended_key_signing =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
skeyFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/drep/extended-key-signing/drep.skey"
txBody <- noteInputFile "test/cardano-cli-golden/files/input/governance/drep/extended-key-signing/tx.body"

outGold <- H.note "test/cardano-cli-golden/files/golden/governance/drep/extended-key-signing/tx.signed"
outFile <- H.noteTempFile tempDir "outFile"

void $ execCardanoCLI
[ "conway", "transaction", "sign"
, "--tx-body-file", txBody
, "--signing-key-file", skeyFile
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile outGold

hprop_golden_governance_drep_retirement_certificate_vkey_file :: Property
hprop_golden_governance_drep_retirement_certificate_vkey_file =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "Witnessed Tx ConwayEra",
"description": "Ledger Cddl Format",
"cborHex": "84a50081825820829e3fd4847f53f0291370fc900b24cc7c7cc4f69676bbed9ca6e281dae9d60a00018182581d6063a11787740d8c90b6d335eefb8bb2f9e23066a3340e8c89d31ed74e1a002b2d03021a000299bd031a010f14d904d901028184108200581c8f4fefcf28017a57b41517a67d56ef4c0dc04181a11d35178dd53f4c1a001e8480f6a10081825820b18eacea2003b68e39137545e9d42ce5bca133ca0334d6a75aa9cb1fd02be7ec5840051079704c9d41192356287965e189d9fe7f693693a72a454f34e6f1c27c5523fe4c8b841931a6d7bb0f59d09b0dcc406834f990845e115a7329ef4285d38208f5f6"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "DRepExtendedSigningKey_ed25519_bip32",
"description": "Delegate Representative Signing Key",
"cborHex": "588048b9578fe1a8fde546fcf5c134a7928b5213f3c2d49766becea5e3078a96354fb3ab263592401d61853957110a688cac3137649efba52994153fb6fd6b29c585b18eacea2003b68e39137545e9d42ce5bca133ca0334d6a75aa9cb1fd02be7ec90e91f5357e2c68949f0f09717c5b9809b6a74d5f87ea35383c82841f2357564"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "Unwitnessed Tx ConwayEra",
"description": "Ledger Cddl Format",
"cborHex": "84a50081825820829e3fd4847f53f0291370fc900b24cc7c7cc4f69676bbed9ca6e281dae9d60a00018182581d6063a11787740d8c90b6d335eefb8bb2f9e23066a3340e8c89d31ed74e1a002b2d03021a000299bd031a010f14d904d901028184108200581c8f4fefcf28017a57b41517a67d56ef4c0dc04181a11d35178dd53f4c1a001e8480f6a0f5f6"
}

0 comments on commit 838609b

Please sign in to comment.