Files
nostr-keygen/nostr_keygen.egg-info/PKG-INFO
2025-09-08 19:37:12 -04:00

129 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Metadata-Version: 2.4
Name: nostr-keygen
Version: 0.1.0
Summary: Terminal tool to generate nostr npub/nsec from file entropy
Author-email: Your Name <you@example.com>
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: ecdsa
Requires-Dist: bech32
# 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.
> **NOTE:** The instructions below work on **macOS** and **Linux**. If youre on Windows youll need a compatible terminal (e.g. WSL, GitBash, or PowerShell with Python).
## 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
### 1⃣ Install Python
- **macOS**: Use Homebrew
```bash
brew install python@3.12
```
(If you already have Python, skip this step.)
- **Linux (Ubuntu / Debianbased)**:
```bash
sudo apt-get update
sudo apt-get install python3 python3-venv
```
(Other distros may use `yum`, `dnf`, or your package manager of choice.)
- **Linux (Arch)**:
```bash
sudo pacman -S python
```
> **Tip** On macOS the `python3` binary is typically symlinked to `python`, but on many Linux systems youll need `python3` explicitly.
### 2⃣ Clone the repo
```bash
git clone https://github.com/yourgithubhandle/nostr-keygen.git
cd nostr-keygen
```
### 3⃣ Create a virtualenvironment (recommended)
```bash
python3 -m venv .venv # create a venv in the repo directory
source .venv/bin/activate # activate it (both on macOS and Linux)
```
> The virtualenvironment isolates the dependencies (`ecdsa`, `bech32`etc.) from the rest of your system.
### 4⃣ Install the tool in editable mode (development) or normally
- **Editable (work on the code as you edit it)**
```bash
pip install -e .
```
- **Normal installation**
```bash
pip install .
```
Both forms install the consolescript `nostrkeygen` into `./venv/bin`.
## 🚀 Run
```bash
# Drop any file onto the terminal prompt!
# macOS (most terminals) and many Linux terminals allow draganddrop.
nostr-keygen <filepath>
```
> Example: `nostr-keygen /tmp/randomfile.pdf`
---
### 📄 Quick test
```bash
# Create a tiny dummy file
printf "random entropy" > /tmp/dummy.bin
# Run the program
nostr-keygen /tmp/dummy.bin
```
You should see two lines outputted: an `nsec` string and an `npub` string.
## 📦 Packaging details
The project uses a `pyproject.toml` and the `[project.scripts]` entry to expose the `nostr-keygen` command. No additional packaging steps are needed for local use.
## 🔧 How the code works (quick dive)
```python
# main.py
import argparse, hashlib
from ecdsa import SigningKey, SECP256k1
from bech32 import bech32_encode, convertbits
NSEC_PREFIX, NPUB_PREFIX = "nsec", "npub"
def _to_bech32(data: bytes, hrp: str) -> str:
five_bits = convertbits(list(data), 8, 5, True)
return bech32_encode(hrp, five_bits)
# … (rest unchanged) …
```
## 📄 License
MIT.