Skip to main content

did:nostr

Decentralized identifiers using Nostr keypairs. Your npub is your DID — no infrastructure required.

Overview

The did:nostr method maps Nostr public keys to W3C Decentralized Identifiers:

did:nostr:npub1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxl8lt

No registration. No resolver infrastructure. Your Nostr key is your identity.

How It Works

DID Format

did:nostr:<npub>

Where <npub> is a bech32-encoded Nostr public key.

Resolution

To resolve a did:nostr:

  1. Decode the npub to get the hex public key
  2. Query Nostr relays for kind 0 (profile) events from that pubkey
  3. Construct a DID Document from the profile data

DID Document

{
"@context": ["https://www.w3.org/ns/did/v1"],
"id": "did:nostr:npub1abc...",
"authentication": [{
"id": "did:nostr:npub1abc...#nostr-key",
"type": "SchnorrSecp256k1VerificationKey2019",
"controller": "did:nostr:npub1abc...",
"publicKeyHex": "abc123..."
}],
"service": [{
"id": "did:nostr:npub1abc...#nostr-relays",
"type": "NostrRelayList",
"serviceEndpoint": ["wss://relay.damus.io", "wss://relay.nostr.band"]
}]
}

Benefits

Featuredid:nostr
InfrastructureNone required
CostFree
PrivacyPseudonymous by default
RecoveryControl your nsec
InteropWorks with all Nostr clients

Usage

Generate a DID

# Generate Nostr keys
npx noskey generate
# npub1abc123...

# Your DID is:
# did:nostr:npub1abc123...

Authenticate

Use NIP-98 to authenticate HTTP requests with your DID:

const did = `did:nostr:${npub}`;
// Sign challenges with your nsec

Specification

  • Method name: nostr
  • Method-specific ID: bech32-encoded public key (npub)
  • Resolution: Query Nostr relays for profile events

See Also