diff --git a/cardano-api/internal/Cardano/Api/Keys/Mnemonics.hs b/cardano-api/internal/Cardano/Api/Keys/Mnemonics.hs index 557a0dda16..49b7913bf5 100644 --- a/cardano-api/internal/Cardano/Api/Keys/Mnemonics.hs +++ b/cardano-api/internal/Cardano/Api/Keys/Mnemonics.hs @@ -14,12 +14,12 @@ where import Cardano.Api.Error (Error (..)) import Cardano.Api.Keys.Class (Key (..)) import Cardano.Api.Keys.Shelley (AsType, PaymentExtendedKey, - SigningKey (PaymentExtendedSigningKey, StakeExtendedSigningKey), - StakeExtendedKey) + SigningKey (..), + StakeExtendedKey, DRepExtendedKey, SigningKey(DRepExtendedSigningKey), CommitteeHotExtendedKey, CommitteeColdExtendedKey) import Cardano.Address.Derivation (Depth (..), DerivationType (..), HardDerivation (..), Index, XPrv, genMasterKeyFromMnemonic, indexFromWord32) -import Cardano.Address.Style.Shelley (Role (..), Shelley (..)) +import Cardano.Address.Style.Shelley (Role (..), Shelley (..), deriveDRepPrivateKey, deriveCCHotPrivateKey, deriveCCColdPrivateKey) import Cardano.Mnemonic (MkSomeMnemonic (mkSomeMnemonic), MkSomeMnemonicError (..), SomeMnemonic, entropyToMnemonic, genEntropy, mnemonicToText) @@ -101,6 +101,33 @@ instance ExtendedSigningKeyRole StakeExtendedKey Word32 where payKeyIx <- maybeToEither idx $ indexFromWord32 @(Index 'Soft 'PaymentK) idx return $ StakeExtendedSigningKey $ getKey $ deriveAddressPrivateKey accK Stake payKeyIx +instance ExtendedSigningKeyRole DRepExtendedKey () where + deriveSigningKeyFromAccount + :: AsType DRepExtendedKey + -> Shelley 'AccountK XPrv + -> () + -> Either Word32 (SigningKey DRepExtendedKey) + deriveSigningKeyFromAccount _ accK _ = + return $ DRepExtendedSigningKey $ getKey $ deriveDRepPrivateKey accK + +instance ExtendedSigningKeyRole CommitteeColdExtendedKey () where + deriveSigningKeyFromAccount + :: AsType CommitteeColdExtendedKey + -> Shelley 'AccountK XPrv + -> () + -> Either Word32 (SigningKey CommitteeColdExtendedKey) + deriveSigningKeyFromAccount _ accK _ = + return $ CommitteeColdExtendedSigningKey $ getKey $ deriveCCColdPrivateKey accK + +instance ExtendedSigningKeyRole CommitteeHotExtendedKey () where + deriveSigningKeyFromAccount + :: AsType CommitteeHotExtendedKey + -> Shelley 'AccountK XPrv + -> () + -> Either Word32 (SigningKey CommitteeHotExtendedKey) + deriveSigningKeyFromAccount _ accK _ = + return $ CommitteeHotExtendedSigningKey $ getKey $ deriveCCHotPrivateKey accK + -- | Generate a signing key from a mnemonic sentence. -- A derivation path is like a file path in a file system. It specifies the -- location of a key in the key tree. The path is a list of indices, one for each