exportSigningGpgKey :: PSState -> IO (Maybe ByteString)
exportSigningGpgKey st = do
    mbKey <- runPSM st getSigningKey
    case mbKey of
        Just key | privIdentKeyBackend key == "gpg" -> do
            let kid = fromKeyID $ privIdentKeyID key
            ctx <- Gpg.ctxNew Nothing
            keys <- Gpg.getKeys ctx True
            candidates <- filterM (\k -> (== Just kid) <$> Gpg.keyFingerprint k) keys
            case candidates of
                (k:_) -> Just <$> Gpg.exportKeys ctx [k]
                _ -> return Nothing
        _ -> return Nothing
exportSigningGpgKey :: PSState -> IO (Maybe ByteString)
exportSigningGpgKey st = do
    mbKey <- runPSM st getSigningKey
    case mbKey of
        Just key | privIdentKeyBackend key == "gpg" -> do
            let kid = fromKeyID $ privIdentKeyID key
            ctx <- Gpg.ctxNew Nothing
            keys <- Gpg.getKeys ctx True
            candidates <- filterM (\k -> (== Just kid) <$> Gpg.keyFingerprint k) keys
            case candidates of
                (k:_) -> Just <$> Gpg.exportKeys ctx [k]
                _ -> return Nothing
        _ -> return Nothing
exportSigningGpgKey st = do
    mbKey <- runPSM st getSigningKey
    case mbKey of
        Just key | privIdentKeyBackend key == "gpg" -> do
            let kid = fromKeyID $ privIdentKeyID key
            ctx <- Gpg.ctxNew Nothing
            keys <- Gpg.getKeys ctx True
            candidates <- filterM (\k -> (== Just kid) <$> Gpg.keyFingerprint k) keys
            case candidates of
                (k:_) -> Just <$> Gpg.exportKeys ctx [k]
                _ -> return Nothing
        _ -> return Nothing