Learn

npub and nsec: your Nostr public and secret keys

On Nostr, npub and nsec are the two halves of your identity key pair, written in a readable form. The npub is the public key: you share it freely so others can follow you and check your signatures. The nsec is the secret key: it signs your messages and proves you are you, so anyone who gets it can post as you and take the identity over.

At a glance

npub
Your public key; share it so people can find and verify you
nsec
Your secret key; never share it, it signs as you
Relationship
Two halves of one key pair; the npub is derived from the nsec
If the nsec leaks
Whoever has it is you; there is no password reset to undo it
Comparison

The public half versus the secret half

npub (public)
nsec (secret)
Who sees it
Anyone; you hand it out
Only you, ever
What it does
Lets people find and verify you
Signs messages as you
If it gets out
No harm; it is meant to be public
Total compromise; they become you

What are npub and nsec?

On Nostr you do not have an account with a username and a password. You have a key pair: a secret key and a public key derived from it. To make those long strings of bytes easier to handle, they are written in a readable form with a prefix. The public key becomes your npub, starting with npub1. The secret key becomes your nsec, starting with nsec1. The prefix is the tell: if you ever see nsec1 somewhere it should not be, something has gone wrong.

The npub is your name on the network. You share it, people follow it, and they use it to check that a note really came from you. The nsec is the thing that signs those notes. It never needs to leave your control, and it never should.

Why is the nsec so dangerous to leak?

Because the nsec is not a password, it is the identity. A password protects an account that a company can reset for you. The nsec has no company behind it. Whoever holds it can sign as you, post as you, and drain any Lightning setup wired to the profile, and there is nothing to reverse it with. That is the cost of an identity nobody can take from you: nobody can give it back either.

So the rule is simple and strict. The npub is public by design and harmless to share. The nsec is treated like a Bitcoin secret: stored offline, backed up, and handed to a signer that keeps apps from ever touching the raw value. Guard the secret half and the open half can go anywhere it likes.

Do

  • Share the npub openly: in a profile, on a card, anywhere
  • Store the nsec the way you would a Bitcoin secret, offline and backed up
  • Use a signer extension so apps never see the raw nsec
  • Treat the nsec as a key, not a password: it cannot be rotated cheaply

Don't

  • Paste the nsec into a website or chat to 'log in'; that is the whole identity
  • Confuse the two: the npub starts npub1, the nsec starts nsec1
  • Keep the only copy of the nsec on one device with no backup
  • Assume a leak is recoverable; there is no support desk to reset it

Related terms

← All terms Reviewed: June 2026