keybase / keybase/keybase-issues

Impossible to directly restore pgp private keys to Keybase local keyring following purge

Open
#2,771 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
899
Forks
40
PR merge metrics
No merged PRs in 30d

Description

After running the command `keybase pgp purge -p`, the Keybase local keyring is purged of all local PGP private keys. The private keys still exist in encrypted form on the Keybase server (assuming the user chose the option to upload the encrypted private key to the server originally), however there is no easy way to get those private keys back into the Keybase local keyring. The only way I found was to export the PGP private key in encrypted form directly from the Keybase website, save it as a `*.asc` file on my local machine, use the command `gpg --import -i ...` to import that private key file into my GPG local keyring, and finally run the command `keybase pgp select --import-only` to import the key from my GPG local keyring into my Keybase local keyring. This is a fairly convoluted workflow. There should be a way to pull the encrypted private key for any one of your PGP keys from the Keybase server and store it directly into your Keybase local keyring, all using one keybase command.

A similar use case for this type of requirement is if a user with multiple PGP keys on Keybase needs to use a key other than their "first" Keybase PGP key to decrypt something from a local machine other than the one on which the key was first created. Right now, the `keybase pgp decrypt` command can only decrypt messages which were encrypted using the first PGP key the user uploaded to Keybase, **unless the private key for the other PGP key(s) are stored in the Keybase local keyring**.

Let's say I create my very first PGP key "A" on machine 1, upload the encrypted private key for key "A" to the server, and then create a second PGP key "B" on machine 1 as well (and also upload its encrypted private key). I've also installed Keybase on my machine 2, however I haven't created any PGP keys from machine 2. Now let's say that someone encrypts a message for me using my public key "A". I want to decrypt the message, but I'm currently using my machine 2. Currently, the `keybase pgp decrypt` command will still work on machine 2 to decrypt a message encrypted using key "A", because key "A" is the first PGP key in my Keybase account. But now, let's say someone encrypts a message for me using my public key "B". If I'm on machine 2 and try to use the `keybase pgp decrypt` command, it will fail with an error saying that it couldn't find the right PGP private key to decrypt the message. However, if I follow the rather convoluted workflow to export the private key for key "B" from the Keybase website, import it into my local GPG keyring on machine 2, and then import it into my Keybase local keyring with `keybase pgp select --import-only`, **then** `keybase pgp decrypt` will work on machine 2 for messages encrypted for both key "A" and key "B".

A single Keybase command to pull any encrypted private PGP key from the Keybase server and store it in the Keybase local keyring would address the difficulties with both of the use cases I described above. Is such a command something you guys could implement?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the existing `keybase pgp purge -p`, `keybase pgp select --import-only`, and `keybase pgp decrypt` command paths. Define the server-to-local-keyring flow for selecting any uploaded encrypted private key, then verify that decryption works for keys beyond the first key.

Written by the indexing model from the issue text.

Assessment

Domain
cli, cryptography, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.