I know this has been asked before, but it's still unclear whether this is an OK practice. The advice seems to never do this unless you have to, but I can think of some examples where this could be useful.

For example, a program that supports encryption and signing like GPG could support generating Ed25519 keys and then use them for encryption (by converting them to Curve25519 keys) and signing (leaving them as Ed25519 keys). This would mean that only Ed25519 keys would have to be generated, preferable from the user input perspective since handling multiple key types could get confusing.

  • 2
    $\begingroup$ Like this one? Can curve25519 keys be used with ed25519 keys?. $\endgroup$ – kelalaka Jan 31 at 14:44
  • 3
    $\begingroup$ Does this answer your question? Why Curve25519 for encryption but Ed25519 for signatures? $\endgroup$ – mentallurg Jan 31 at 16:43
  • $\begingroup$ GPG is NOT a good example of how to write secure software. That it can be used securely is more due to luck than design. $\endgroup$ – SAI Peregrinus Jan 31 at 19:20
  • $\begingroup$ Even for algorithms that can use the same key for encryption and signing, namely RSA, PGP and GPG best practice and all crypto best practice for decades has been NOT to do that. If you think there is good reason to use the same key for multiple purposes that usually should (or must) be managed differently and thus can't be the same key, that might be a good question to ask. $\endgroup$ – dave_thompson_085 Feb 1 at 0:23
  • $\begingroup$ Beware that code requests are not on topic on SO, better word your question in such a way that you are looking for a solution, not code. $\endgroup$ – Maarten Bodewes Feb 1 at 1:07