Can I always derive a key pair from password+salt with libsodium? I'm using libsodium to create public/secret key pairs from a password and salt combination by using crypto_pwhash_scryptsalsa208sha256 to generate a seed and passing that seed to crypto_box_seed_keypair.

Is it safe to recreate the key pair using the password+salt every time I need to use it so I don't have to store the keys (encrypted or not) anywhere in the system?

I would store the salt, and ask for the password again every time it is needed.
Is it safe to recreate the key pair using the password+salt every time I need to use it so I don't have to store the keys (encrypted or not) anywhere in the system?


The problem with that is that your public key then effectively becomes a password hash, meaning anyone who sees it will be able to mount a dictionary attack on your password to generate the private key that corresponds to it. They will need access to the salt for the attack, of course, so in that case your salt effectively becomes a secret.

So there is not really a great difference to storing an encrypted (random) private key vs. storing a (random) salt that allows deriving the private key. However, when deriving the key directly from the password you should use a strong random number as a salt, not something unique but guessable, like a timestamp or an email address.