Understanding Nostr’s NIP-05: Mapping Keys to DNS-based Internet Identifiers

NIP-5
Savanna Sailor Avatar

Nostr, a decentralized messaging protocol, has introduced a unique way to map its keys to DNS-based internet identifiers through NIP-05. This implementation offers a seamless way to reference public keys with more human-readable identifiers, making it easier for users to interact within the Nostr ecosystem.

What is NIP-05?

NIP-05 is a Nostr Improvement Proposal that allows events of kind 0 (metadata) to specify a key named “nip05” with an internet identifier, which is similar to an email address, as its value. This identifier is then split into a local part and a domain. For instance, if the identifier is “bob@plebID.com“, “bob” is the local part, and “plebID.com” is the domain.

How Does It Work?

When a client encounters an event with a “nip05” key, it makes a GET request to a specific URL: https://<domain>/.well-known/nostr.json?name=<local-part>. The response should be a JSON document with a “names” key that maps names to hex-formatted public keys. If the public key matches the one from the metadata event, the client confirms that the public key can indeed be referenced by its identifier.

Example: If a client sees an event like:

jsonCopy code

{ "pubkey": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9", "kind": 0, "content": "{\"name\": \"bob\", \"nip05\": \"bob@plebID.com\"}" }

It will request https://plebid.com/.well-known/nostr.json?name=bob and expect a response similar to:

jsonCopy code

{ "names": { "bob": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9" } }

Key Takeaways:

  1. Clients Must Follow Public Keys: Even after determining that “bob@plebid.com” has a specific public key, the client should primarily reference the public key and not the NIP-05 address.
  2. Hex Format for Public Keys: Public keys should always be returned in hex format.
  3. User Discovery: Clients can use NIP-05 to allow users to search for other profiles using their internet identifiers.
  4. Domain as Identifier: Clients can treat identifiers like “_@domain” as the root identifier and display it as just the domain. For instance, “_@plebid.com” can be shown as “plebID.com”.
  5. Security Constraints: The /.well-known/nostr.json endpoint should not return any HTTP redirects, and fetchers must ignore any redirects from this endpoint.

NIP-05 is a significant step towards making Nostr more user-friendly by allowing more intuitive identifiers for public keys. As the protocol continues to evolve, such improvements will likely make decentralized messaging more accessible to a broader audience.

Source: GitHub – nostr-protocol/nips