That's great.
As a matter of fact, nosskey has it
I've implemented it as a prototype.
You may be able to use it as a reference.

GitHub
GitHub - ocknamo/nosskey: ⛔️ DEPRECATED: Nosskey challenges better ways to handle Nostr keys
⛔️ DEPRECATED: Nosskey challenges better ways to handle Nostr keys - ocknamo/nosskey