The Nostr channel connects NullClaw to the Nostr protocol using NIP-17 (gift-wrapped DMs) and NIP-04 (legacy encrypted DMs) via theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nullclaw/nullclaw/llms.txt
Use this file to discover all available pages before exploring further.
nak CLI tool.
Features
- NIP-17 (Gift Wrap) — Modern private messaging with forward secrecy
- NIP-04 — Legacy encrypted DMs for backward compatibility
- Protocol Mirroring — Automatically replies using the same protocol the sender used
- Multi-Relay Support — Connect to multiple Nostr relays simultaneously
- Decentralized — No central server, censorship-resistant
- Key Management — Supports plaintext keys or remote signers (bunker://)
- Duplicate Suppression — Deduplicates messages across relays
Prerequisites
You must have thenak CLI tool installed:
Configuration
Add Nostr to yourconfig.json:
Configuration Options
Your Nostr private key in one of these formats:
- nsec-encoded key:
"nsec1..." - Hex key:
"abc123..." - Bunker URI:
"bunker://..." - Encrypted secret ID:
"secret:nostr_key"
"secret:nostr_key" and store the key in NullClaw’s secrets backend.Public key of the bot owner (you). Only this pubkey can send DMs to the bot.Formats:
- npub-encoded:
"npub1..." - Hex:
"abc123..."
List of Nostr relay URLs (wss:// WebSocket endpoints). Minimum 1, recommended 3-5 for redundancy.Popular relays:
wss://relay.damus.iowss://nos.lolwss://relay.nostr.bandwss://nostr.winewss://relay.snort.social
Path to the
nak binary. Use absolute path if not in $PATH.Account identifier for multi-account setups
Setup Guide
Generate or Import Keys
Generate new keys:Import existing keys:
If you already have a Nostr identity, export your private key from your client.
Store Private Key Securely
Option 1: Encrypted secret (recommended)Then use in config:Option 2: Direct in config (development only)
NIP-17 vs NIP-04
NIP-17 (Gift Wrap) — Recommended
Advantages:- Forward secrecy (ephemeral keys)
- Better metadata privacy
- Replay protection
- Modern standard
- Sender wraps message in ephemeral key encryption
- Message published with randomized timestamp
- Recipient unwraps using their private key
NIP-04 (Legacy Encrypted DMs)
Advantages:- Wider client support
- Simpler implementation
- Backward compatibility
- No forward secrecy
- Metadata leakage (timestamps, sender/recipient visible)
Protocol Mirroring
NullClaw automatically detects which protocol the sender used and replies with the same protocol:- Receive NIP-17 message → Reply with NIP-17
- Receive NIP-04 message → Reply with NIP-04
Key Management
Plaintext Keys (Development)
Encrypted Secrets (Production)
Remote Signer (Advanced)
Use Nostr Connect (NIP-46) with a remote signer:Relay Selection
Recommended Relay Sets
General purpose:Relay Count Considerations
- Minimum: 1 relay (single point of failure)
- Recommended: 3-5 relays (good redundancy)
- Maximum: 10 relays (diminishing returns, increased bandwidth)
Access Control
Unlike other channels, Nostr has built-in access control:- Only the
owner_pubkeycan send DMs to the bot - All DMs are end-to-end encrypted
- No additional allowlist needed
Duplicate Suppression
When connected to multiple relays, the same message may arrive multiple times. NullClaw automatically deduplicates based on the inner rumor ID (kind:14 event ID), ensuring each unique message is processed only once.Troubleshooting
nak Command Not Found
- Verify installation:
which nak - Check
$GOPATH/binis in$PATH: - Use absolute path in config:
Messages Not Received
- Verify owner_pubkey matches your actual pubkey
- Check relay connections:
nak req -k 1 <relay_url> - Ensure sender is using NIP-17 or NIP-04 DMs (not public notes)
- Review NullClaw logs:
nullclaw --log-level debug - Test relay connectivity:
websocat wss://relay.damus.io
Failed to Decrypt
- Verify private_key is correct
- Check key format (nsec vs hex)
- For encrypted secrets:
nullclaw secrets get nostr_key - Ensure sender encrypted message to correct pubkey
Relay Connection Errors
- Test relay manually:
nak req -k 1 wss://relay.damus.io - Try alternative relays from nostr.watch
- Check firewall/proxy settings
- Verify relay supports WebSocket secure (wss://)
Key Conversion Issues
Source Code
Implementation:src/channels/nostr.zig