105 lines
3.1 KiB
Markdown
105 lines
3.1 KiB
Markdown
# 🔐 NIP‑49 Key Encrypt/Decrypt & Conversion CLI
|
||
|
||
A tiny, no-fuss command-line tool to **encrypt**, **decrypt**, and **convert** Nostr keys — safely and offline.
|
||
|
||
Built for privacy-conscious users who want a secure and user-friendly way to handle their Nostr keys using [NIP‑49](https://github.com/nostr-protocol/nips/blob/master/49.md).
|
||
|
||
---
|
||
|
||
## ✨ Features
|
||
|
||
- 🔐 **Encrypt / Decrypt** your Nostr `nsec` keys using a password (NIP‑49)
|
||
- 🔁 **Convert** private key hex ↔ `nsec` and public key hex ↔ `npub`
|
||
- 🧭 Friendly CLI with step-by-step wizard prompts
|
||
- ⚙️ Pure Python. No compiling, no GUI — just run and go
|
||
- 🔒 Secure: works 100% offline — no network requests
|
||
|
||
---
|
||
|
||
## 🍎 macOS Setup
|
||
|
||
### ✅ 1. Install Python 3 (via Homebrew)
|
||
|
||
If you don’t already have Python 3:
|
||
|
||
```bash
|
||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||
brew install python
|
||
```
|
||
Confirm it’s working:
|
||
```bash
|
||
python3 --version
|
||
```
|
||
📦 Installation
|
||
```bash
|
||
📁 1. Clone the repo
|
||
git clone https://github.com/btcforplebs/nip49-decrypt.git
|
||
```
|
||
cd nip49-decrypt
|
||
### 🧪 2. Create and activate a virtual environment
|
||
```bash
|
||
python3 -m venv venv
|
||
source venv/bin/activate
|
||
```
|
||
### 📦 3. Install Python packages
|
||
```bash
|
||
pip install bech32 cryptography ecdsa pynacl
|
||
If pynacl fails, the script will fall back to cryptography for encryption.
|
||
```
|
||
### ✅ 4. Make it executable
|
||
```bash
|
||
chmod +x nip-49decrypt
|
||
```
|
||
▶️ Usage
|
||
From the project directory, run:
|
||
```bash
|
||
./nip-49decrypt
|
||
```
|
||
You’ll see a friendly menu:
|
||
```bash
|
||
Choose an action:
|
||
(d) Decrypt an encrypted key with password
|
||
(e) Encrypt a private key with password
|
||
(h) Convert private key hex to nsec
|
||
(p) Convert public key hex to npub
|
||
(q) Quit
|
||
```
|
||
### 🔐 Example: Decrypt a Key
|
||
Select (d)
|
||
Paste your ncryptsec string
|
||
Enter your password (input hidden)
|
||
View your decrypted raw private key and corresponding nsec
|
||
|
||
### 🛠️ Other Features
|
||
Convert raw hex → nsec
|
||
Choose (h) and enter your private key as 64-character hex.
|
||
Convert public key hex → npub
|
||
Choose (p) and paste a 66-character (compressed) or 130-character (uncompressed) public key in hex.
|
||
Encrypt nsec → ncryptsec
|
||
Choose (e) and paste your private key (hex or nsec). You’ll be prompted for a password, and the script will return a password-encrypted ncryptsec.
|
||
|
||
### 🧼 To Exit
|
||
Use (q) or press Ctrl + C at any time.
|
||
|
||
### 📁 Files
|
||
File Description
|
||
nip-49decrypt Main Python script
|
||
README.md This help file
|
||
venv/ Your virtual environment (optional)
|
||
|
||
### 🧠 FAQ
|
||
❓ Is this secure?
|
||
✅ Yes. This script never sends anything over the internet.
|
||
❓ Can I run it offline?
|
||
✅ 100%. Works without an internet connection.
|
||
|
||
❓ What if a Python package is missing?
|
||
🛠️ The script will detect it and print exact instructions for how to install it.
|
||
|
||
❓ Can I compile this to a single file?
|
||
Yes! You can use tools like pyinstaller to build a standalone binary.
|
||
|
||
### 🤝 Credits
|
||
Built with ❤️ by plebs, for plebs. Inspired by NIP‑49 and the Nostr community.
|
||
### 🛡️ License
|
||
MIT — Free for all. Fork, contribute, share. |