Mining your Vanity Pubkey

Mining your Vanity Pubkey

Tldr

  • Your Nostr identity may be the first ID you every own
  • You can create one that easier to backup using a 12-word mnemonic, and
  • You can create one that has a bit of branding to it, called a “vanity npub”
  • Many tools exist which you can use
  • I tried a few and settled on Rana by Negrunch
  • Now I am npub1r0d8...

The first ID you’ll ever own

The first step in setting up a Nostr profile is to get your keys. These keys are your identity. For almost everyone, this is the first ID you’ll have that you truly own. That is, this ID is yours because you say it is. That’s different from almost every other ID, which was issued to you by someone else, and is yours because they say it is.

Not only is it yours. It’s portable. You can use this ID to be yourself in any app that supports Nostr.

Consider the legacy internet—every app requires a separate account. That’s a separate login and password to remember. And worse than that, it’s a separate set of content you have to generate, and a separate following you have to create. Every time a new platform launches, you need to encourage your followers to join you on the new platform. At any time, any platform can deplatform you. If they do, you lose your content and your following, with no recourse.

On Nostr, it’s different. All your content and all your following is linked to your identity, and you take it with you everywhere. You build your content once, and it appears with you everywhere. You build one following once, and they follow you everywhere. If a platform deplatforms you, you don’t lose your following or content, you just take it all to another platform.

This may be the first ID you ever own, and if Nostr keeps on growing, it may be the last ID you’ll ever need.

Getting branded with a “vanity” npub

Every nostr user has an identity like this, and every user can be found and known by their public key, their “npub” or “pubkey”. By default, most people go by a pubkey that is completely random, like npub1asdfgh….

My view is, if you’re going to create your first-ever ID that is truly yours, you might as well make it special. It’s possible to create a pubkey that has a bit of branding to it.

The technical name for these is a “vanity npub”. You could call it a branded npub.

There are some good examples:

  • Snowden at npub1sn0wden...
  • Negrunch at npub1qqqqqqq...

These pubkeys have specific characters at the start (or at the end). It is better branding. It’s also helpful for defeating spammers who might choose to imitate you, as only you have the vanity npub.

Keys are generated at random. To get one with your specific branding on it, you need to set up your computer to generate keys at random until it finds one that suits your needs. Once set up your computer will generate keys by the millions–checking and discarding each one until it creates the one with your characters.

The more characters you want, the longer this process will take.

Nostrogen provides a helpful table for that:

  • 1 character = usually less than a 0.1 seconds
  • 2 characters = usually less than a 1 second
  • 3 characters = usually less than a 30 seconds
  • 4 characters = usually less than a 10 minutes
  • 5 characters = usually less than a 1 hour
  • 6+ characters = keep fire extinguisher handy

The good news is, for your npub to have nice branding, you don’t need a lot of characters.

For myself I only needed four “r0d8”.

Getting a mnemonic, for backup, and for lightning

Once you have your ID, you will want to use it different places and back it up securely. The problem with writing down your ID as an nsec is that it’s long and complicated to write, and too easy to misread and enter the wrong characters when you type it back into your device.

A better alternative exists. You can generate a 12-word mnemonic, and then use that to derive your nsec (documented in NIP-06). The mnemonic is much easier to read, easier to type into new apps, and easier to backup correctly.

If you generate your keys directly as npub and nsec you can never go “backward” to generate a mnemonic. But if you generate a mnemonic first, you can always generate an npub and nsec from it. Furthermore if you generate a mnemonic, you can (optionally) use that same mnemonic to generate your lightning wallet for making payments with.

For these reasons, my view is that using an identity with a mnemonic is best.

Once we have our 12-word mnemonic, we generate our keys (npub and nsec), and we’re ready to use anything in the Nostr ecosystem.

  • Where the app supports mnemonics you can use that
  • For everywhere else you can use your nsec
  • In either case you’ll be recognised everywhere you go by your vanity npub

How to mine a 12-word mnemonic with a branded vanity npub

You’ll need an application for mining. There are very many to choose from, which you can see on this awesome Nostr list by Aljaz

Some work in your web browser, like nostr.rest. Many others you can find on github and install. I tried many including nostr-pubminer, and nostr_vanity_npub, before settling on Rana.

To run these requires basic command line knowledge. I didn’t have that, so I fed the GitHub readme page to ChatGPT, and it walked me through getting everything set up.

Failing many times

Here’s what I did wrong so you don’t have to make the same mistakes.

  • You can only use bech32 characters in your npub, and may not be every character you want! The allowed character set is only 023456789acdefghjklmnpqrstuvwxyz. Importantly for me there is no “o” “b” or “i” which makes it impossible to generate “rod” or “bishop”! Only “r0d” and “8lsh0p” are possible.
  • Not every vanity npub miner tell you if you’re using valid characters. Nostr.rest and nostr-pubminer happily sat for hours using my CPU to look for a key that started with “rod” and failed to find one, as they must, because “rod” is not possible (only ”r0d” is possible).
  • Some miners will ask you “how many threads” would you like to use. It’s a question that relates to how much processor power you want to spend on the task. I didn't know the "correct" answer but found it didn’t matter at all what number I entered.
  • Some miners will generate npubs just fine, but can not generate the mnemonic. For my needs I needed one that could do both.

Success with Rana

In the end I succeed using Rana by Negrunch

You can find Rana here on Github with a very helpful readme.

In short the process is:

  • Install Rust (the programming language) and install Rana (the mining application)
  • Run a command to generate your npub.
  • For me that command was: “cargo run —release — -n=r0d8 -g 12”

That command breaks down as:

  • “cargo run” telling Rust to run the application
  • “-n=r0d8” look for an npub with a prefix of “r0d8”, and
  • “-g 12” including a 12 word mnemonic

And the outcome is:

  • A 12 word mnemonic
  • Private and public keys derived from that mnemonic
  • My branded vanity npub starting with npub1r0d8...

In summary

The first step in setting up a Nostr profile is to get your identity.

While it’s easy to get an identity made with random keys, if we think our Nostr IDs are going to mean something important in the future, then we may as well set ourselves up with keys that are easy to use, and branded.

That means

  • 12-word mnemonic backups (feature NIP-06)
  • Branded vanity npub

The mnemonic is easier to backup and also can be used to create a lightning wallet. The branding helps people know your npub is really you

To do this

  • You need an application for mining a vanity npub
  • There are many, and I had success with Rana which provided both the mnemonic and the vanity prefix, in one command line instruction.

Next

  • Please let me know if this kind of post is helpful or anything you’d like me to improve or expand upon!
  • For my next post I’ll show how to set up a self-custody lightning wallet to make payments on Nostr with Phoenixd and Albyhub