This commit is contained in:
Logen
2025-09-08 20:00:29 -04:00
parent 6ac9ae4566
commit 3b32ca76b3
3 changed files with 3 additions and 20 deletions

View File

@@ -90,23 +90,6 @@ Both forms install the consolescript `nostrkeygen` into `./.venv/bin`.
> Keep your `nsec` secret in a secure, offline location. Anyone with that string can sign Nostr events or spend Nostrbased funds.
## 🔧 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) …
```
### Why the keygen algorithm matters
1. **Read file in binary** We need raw entropy; reading as text would truncate or encode the file in an unexpected way. Binary mode is the most faithful representation of the files content.

View File

@@ -71,8 +71,8 @@ def main():
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
print("Nsec:", nsec)
print("Npub:", npub)
print("nsec:", nsec)
print("npub:", npub)
if __name__ == "__main__":

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "nostr-keygen"
version = "0.1.0"
version = "0.1.1"
description = "Terminal tool to generate nostr npub/nsec from file entropy"
authors = [{name = "Your Name", email = "you@example.com"}]
readme = "README.md"