Last active
March 15, 2023 20:52
-
-
Save luisschwab/9e96c71ad66fc32e3797b374789ed521 to your computer and use it in GitHub Desktop.
nostr key generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
''' | |
usage: | |
trusted: | |
./nostr-keygen.py (will generate a private key) | |
trustless: | |
./nostr-keygen.py <32 byte hex privkey> (will derive the pubkey) | |
./nostr-keygen.py "$(openssl rand -hex 32)" | |
''' | |
import sys | |
from nostr.key import PrivateKey | |
if len(sys.argv) > 1: | |
private_key = PrivateKey(bytes.fromhex(sys.argv[1])) | |
else: | |
private_key = PrivateKey() | |
public_key = private_key.public_key | |
print(f"PRIV:\n{private_key.bech32()}\n{private_key.hex()}\n") | |
print(f"PUB:\n{public_key.bech32()}\n{public_key.hex()}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment