Summary
Add an import-nsec command to Keymaster that allows importing an existing Nostr private key (nsec) into a DID identity, rather than only supporting derived keys via add-nostr.
Motivation
Currently, add-nostr derives a Nostr keypair from the DID HD key. This means users who already have an established Nostr identity (with followers, reputation, NIP-05 verification, etc.) cannot use that identity with their Archon DID. They must either:
- Use
set-property to link the pubkey as metadata only (no signing capability), or
- Abandon their existing Nostr identity and use the Archon-derived one.
Neither option is ideal for users with established Nostr presences.
Proposed Solution
Add a new CLI command:
keymaster import-nsec <nsec> [id]
This would:
- Decode the
nsec (bech32) to raw private key bytes
- Derive the corresponding public key (
npub + hex pubkey)
- Store the private key encrypted in the wallet under
idInfo.nostr (or a new idInfo.nostrImported field to distinguish from derived keys)
- Update
didDocumentData.nostr with the npub and pubkey
- Allow
sign-nostr-event to use the imported key instead of the derived one
Security considerations
- The imported nsec should be encrypted at rest in the wallet (same protection as the mnemonic)
export-nsec should work for imported keys as well
- Clear documentation that imported keys are stored (vs derived keys which are never stored)
API surface
| Command |
Description |
import-nsec <nsec> [id] |
Import existing Nostr private key |
export-nsec [id] |
Already exists — should also return imported keys |
remove-nostr [id] |
Already exists — should clean up imported keys too |
Alternatives Considered
- Metadata-only linking: Works for discovery but not for signing Nostr events through Archon.
- NIP-46 remote signer: Would allow Archon to request signatures from an external signer, but adds complexity and requires the signer to be online.
Additional Context
This was identified during DID setup where a user wanted to link their existing Nostr identity (npub1...) to their Archon DID with full signing capability.
Summary
Add an
import-nseccommand to Keymaster that allows importing an existing Nostr private key (nsec) into a DID identity, rather than only supporting derived keys viaadd-nostr.Motivation
Currently,
add-nostrderives a Nostr keypair from the DID HD key. This means users who already have an established Nostr identity (with followers, reputation, NIP-05 verification, etc.) cannot use that identity with their Archon DID. They must either:set-propertyto link the pubkey as metadata only (no signing capability), orNeither option is ideal for users with established Nostr presences.
Proposed Solution
Add a new CLI command:
This would:
nsec(bech32) to raw private key bytesnpub+ hex pubkey)idInfo.nostr(or a newidInfo.nostrImportedfield to distinguish from derived keys)didDocumentData.nostrwith thenpubandpubkeysign-nostr-eventto use the imported key instead of the derived oneSecurity considerations
export-nsecshould work for imported keys as wellAPI surface
import-nsec <nsec> [id]export-nsec [id]remove-nostr [id]Alternatives Considered
Additional Context
This was identified during DID setup where a user wanted to link their existing Nostr identity (
npub1...) to their Archon DID with full signing capability.