Nostr Vanity Address Generator
CLI tool to generate vanity addresses for Nostr
If you have the Rust toolchain installed, you can install it easily with Cargo:
cargo install nostrgen --locked
Or you may download the latest release built by GitHub CI from the releases page, or clone the source and build from source (see below), then run the binary.
$ nostrgen --help
Usage: nostrgen [OPTIONS] --prefix <PREFIX>
Options:
-p, --prefix <PREFIX> The address prefix to match
-s, --suffix <SUFFIX> The address suffix to match (optional)
-c, --cores <CORES> Cpu cores to use (default: cpu_cores/2)
-h, --help Print help
$ nostrgen -p 7777
[#] Start searching with prefix npub17777 (difficulty est.: 1048576)
[!] Result:
secret_key: 3d81e7db2e250685b8246def93cb9d29b7a4c73139b4c0ec37e6df63f9a86e7b (hex)
secret_key: nsec18kq70kewy5rgtwpydhhe8jua9xm6f3e38x6vpmphum0k87dgdeashjjxyw
public_key: npub17777wunn2aq5megnxlnckcfhz2w4zejrvl4nnnha2lfl9lh9qzaqpr4jt4
$ nostrgen -p 000 -s 00 -c 10
[#] Start searching with prefix npub1000 and suffix 00 (difficulty est.: 33554432)
[+] Total 4331377 keys in 0.5 mins (144379.2 keys/s)
[!] Result:
secret_key: 4cb87474993b0693cd24eabb40a2affc54fd3fc31bb7cb18224456b49e81b2c4 (hex)
secret_key: nsec1fju8gaye8vrf8nfya2a5pg40l320607rrwmukxpzg3ttf85pktzqpxp28t
public_key: npub100007s69jra7w0gfulcreacudxdqwc60dqaskfre0fdkfa0cwe5su5pg00
You need to have Rust toolchain installed in your system, see rustup.rs for the install guide if you don't have it.
# Get the source code and build
$ git clone https://github.com/chawyehsu/nostr-vanity-address-generator
$ cd nostr-vanity-address-generator
$ cargo build --release
# Run the binary
$ ./target/release/nostrgen --help
Though multithreading has been supported, it depends on your hardware, CPU specifically and the prefix/suffix you are looking for. Longer prefixes/suffixes will take longer to find, the difficulty increases at an exponential rate. There should be room for performance improvements I believe, so PRs are welcome.
Nostr public key is encoded in bech32
format, which uses a character set excepting
b
, i
, o
and 1
, hence you won't be able to get an address with these characters.
For more information about Nostr's address format, you may read about Nostr's NIP-19 document.
Cryptographic programs require very high entropy for RNGs. This program currently
adpots thread_rng()
RNG to generate random values that used by the elliptic curve.
The RNG is from the rand
crate and is re-exported from the rust-secp256k1
crate. It's cryptographically secure and widely trusted by the community.
You may read more about RNGs for Rust in the The Rust Rand Book.
This program will neither store nor will steal your secret key, but please DON'T TRUST, VERIFY. Check out the code and build from source yourself, run it offline if you are concerned.
nostr-vanity-address-generator © Chawye Hsu. Released under the Apache-2.0 License.
Blog · GitHub @chawyehsu · Twitter @chawyehsu
Follow me on Nostr with address npub1chawye0ndev3wdzd0vf4nlm679nvfhm066jcculh8ux0xvg0svnsv0yqpl
Fun fact: I selected this address generated by the tool after accumulatively searching 55B+ keys. ;P