Skip to main content How do I generate the keys locally? : r/nostr
r/nostr icon
Go to nostr
•

How do I generate the keys locally?

I keep clicking around, but can't find how to properly start.

What I'd like is a CLI utility (preferably in Rust, or available in NixOS) that I could use to generate the key locally. Then I can put the public key in https://branle.netlify.app and sign my posts from CLI, I guess.

Could I maybe use my pgp on a yubikey?

Please excuse if this is not the best place to ask, and thank you.

PSA, Redditors: You don't need a business to have a website. All you need is yourself. And with Squarespace, you can easily create a website that reflects your personal brand, individuality, and identity–all by using its intuitive design, AI, and expressibility tools.
Thumbnail image: PSA, Redditors: You don't need a business to have a website. All you need is yourself. And with Squarespace, you can easily create a website that reflects your personal brand, individuality, and identity–all by using its intuitive design, AI, and expressibility tools.
Sort by:
Best
Open comment sort options

Nostril is a command line utility that allows you to generate pubkey/private key, as well as even sign events.

To generate your own #nostr private key on linux or command line, run:

$ openssl rand -hex 32

this creates a 256 bit random number, and prints it in hex format, which is taken by nostr clients. You can take this as private key, and then enter into a client, which would show you the public key.

openssl rand -hex 32

and how to convert to nsec format from that please ?

How safe is this method of key generation? what is the likelihood that somebody else hasn't allready made a table of pre-generated key pairs?

More replies

openssl rand -hex 32

lol is it that simple?

More replies

You could use python-nostr https://github.com/jeffthibault/python-nostr

and generate a keypair in a little python script

from nostr.key import PrivateKey

private_key = PrivateKey()

public_key = private_key.public_key

print(private_key)

print(public_key)

Thanks!

More replies