Skip to content

Commit

Permalink
Fix #311 - Add Cold Committee Key text envelope
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Oct 2, 2023
1 parent 1a140f5 commit fbe17fb
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ data SomeSigningWitness
| AGenesisDelegateExtendedSigningWitness (SigningKey GenesisDelegateExtendedKey)
| AGenesisUTxOSigningWitness (SigningKey GenesisUTxOKey)
| ADRepSigningWitness (SigningKey DRepKey)
| ACommitteeSigningWitness (SigningKey CommitteeColdKey)


-- | Data required for constructing a Shelley bootstrap witness.
Expand Down Expand Up @@ -652,6 +653,7 @@ categoriseSomeSigningWitness swsk =
AGenesisDelegateExtendedSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisDelegateExtendedKey sk)
AGenesisUTxOSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisUTxOKey sk)
ADRepSigningWitness sk -> AShelleyKeyWitness (WitnessPaymentKey $ castDrep sk)
ACommitteeSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeColdKey sk)

-- TODO: Conway era - Add constrctor for SigningKey DrepKey to ShelleyWitnessSigningKey
castDrep :: SigningKey DRepKey -> SigningKey PaymentKey
Expand Down Expand Up @@ -704,6 +706,7 @@ readWitnessSigningData (KeyWitnessSigningData skFile mbByronAddr) = do
, FromSomeType (AsSigningKey AsGenesisDelegateExtendedKey ) AGenesisDelegateExtendedSigningWitness
, FromSomeType (AsSigningKey AsGenesisUTxOKey ) AGenesisUTxOSigningWitness
, FromSomeType (AsSigningKey AsDRepKey ) ADRepSigningWitness
, FromSomeType (AsSigningKey AsCommitteeColdKey ) ACommitteeSigningWitness
]

bech32FileTypes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,40 @@ hprop_golden_shelleyTx = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
-- Check the newly created files have not deviated from the
-- golden files
checkTxCddlFormat referenceTx transactionFile


hprop_golden_checkIfConstitutionalCommitteeKeyCanSign :: Property
hprop_golden_checkIfConstitutionalCommitteeKeyCanSign = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
-- Reference keys
let referenceTx = "test/cardano-cli-golden/files/golden/conway/tx"

-- Key filepaths
paymentSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey"
-- constitutional committee signing key
paymentSignKey2 <- noteInputFile "test/cardano-cli-golden/files/golden/conway/cold1-cc.skey"
transactionFile <- noteTempFile tempDir "tx-file"
transactionBodyFile <- noteTempFile tempDir "tx-body-file"

-- Create transaction body
void $ execCardanoCLI
[ "conway", "transaction", "build-raw"
, "--tx-in", "f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d#0"
, "--tx-out", "addr_test1qpmxr8d8jcl25kyz2tz9a9sxv7jxglhddyf475045y8j3zxjcg9vquzkljyfn3rasfwwlkwu7hhm59gzxmsyxf3w9dps8832xh+1199989833223"
, "--tx-out", "addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4+10000000"
, "--fee", "166777"
, "--out-file", transactionBodyFile
]

-- Sign transaction
void $ execCardanoCLI
[ "transaction", "sign"
, "--tx-body-file", transactionBodyFile
, "--signing-key-file", paymentSignKey
, "--signing-key-file", paymentSignKey2
, "--testnet-magic", "42"
, "--out-file", transactionFile
]

-- Check the newly created files have not deviated from the
-- golden files
checkTxCddlFormat referenceTx transactionFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "ConstitutionalCommitteeColdSigningKey_ed25519",
"description": "Constitutional Committee Cold Signing Key",
"cborHex": "5820f213c36a77aea6174875b778d8cc60b4c5a3f47eb3a75c11effe64d2b7ce34db"
}
5 changes: 5 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/conway/tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "Witnessed Tx ConwayEra",
"description": "Ledger Cddl Format",
"cborHex": "84a30081825820f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d000182a20058390076619da7963eaa588252c45e960667a4647eed69135f51f5a10f2888d2c20ac07056fc8899c47d825cefd9dcf5efba150236e043262e2b43011b0000011764f7be07a200581d604088059bbeb6add02eecd0c6a2a52c06910f2a6b4ba0029e9fe6ed13011a00989680021a00028b79a100828258208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea4234275840963b5af8b899f154f35cb9effe40474035dad7f403fe5b1a7e70690f69971683b7c99da2fab04e02a28a765815eab76b9c4c8f0cd5b407a8e1cd7e214478560f825820ccb96e5d87424375c30b5d1539be8beca496bd87f48d8a4111145c92575dc22458403531dba28f0eafdd77363efc135ec56ec2e118506b61a26c6f8089aa17402532afc2bd16d92009263b749d49cfe0b97289ba73293e1c18af0c1605cadbe5270cf5f6"
}

0 comments on commit fbe17fb

Please sign in to comment.