Skip to content

Feature: Import existing Nostr nsec into DID identity #262

@santyr

Description

@santyr

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:

  1. Use set-property to link the pubkey as metadata only (no signing capability), or
  2. 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:

  1. Decode the nsec (bech32) to raw private key bytes
  2. Derive the corresponding public key (npub + hex pubkey)
  3. Store the private key encrypted in the wallet under idInfo.nostr (or a new idInfo.nostrImported field to distinguish from derived keys)
  4. Update didDocumentData.nostr with the npub and pubkey
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions