Initial commit: basic keygen tool

This commit is contained in:
Logen
2025-09-08 17:51:35 -04:00
commit 56041b244d
4 changed files with 147 additions and 0 deletions

47
README.md Normal file
View File

@@ -0,0 +1,47 @@
# README.md
# nostr-keygen
A tiny commandline utility written in Python that generates an Nostr **npub** (public key) and **nsec** (private key) pair from a single file that you drop into the terminal.
## How it works
1. **Entropy** The contents of the file you provide are read in binary mode.
2. **Hash** The data is hashed with SHA256 to produce a 32byte seed.
3. **Key generation** The seed is fed to the secp256k1 curve to create an ECDSA private key.
4. **Bech32 encoding** The private key is encoded as `nsec`; the compressed public key is encoded as `npub`.
The utility is intentionally lightweight; it has no external configuration and works on any platform with Python3.8+.
## Installation
```bash
# Clone the repo
git clone https://github.com/yourname/nostr-keygen.git
cd nostr-keygen
# Create a virtualenv and install deps
python3 -m venv venv
source venv/bin/activate
pip install -e . # installs the program and its deps
```
After that you can run it with:
```bash
# Replace file.txt with the path to any file you want to use as entropy
nostr-keygen file.txt
```
## Using draganddrop in the terminal
On macOS (and most X11 terminals) you can simply drag a file into the terminal prompt. The terminal translates that to the files full path. For example:
```
$ nostr-keygen <dragged file>
```
This will invoke the program using the path of the dropped file.
## License
MIT