Nostr 是一个基于密钥对的去中心化通信协议—— 没有中央服务器,没有账号注册,只有密钥对和 Relay。 OpenClaw 支持 Nostr,让你的 AI 助手也加入去中心化网络。
Nostr 是什么?
传统聊天(Telegram/WhatsApp):
你 → 中心化服务器 → 对方
Nostr:
你(私钥签名)→ Relay 1
→ Relay 2 → 对方(通过公钥订阅)
→ Relay 3
没有账号,只有密钥对(私钥 = 身份)
没有公司,只有开放的 Relay 服务器
OpenClaw 的 Nostr AI 助手:
- AI Bot 有自己的 Nostr 密钥对(身份)
- 用户通过 NIP-04 加密私信与 Bot 对话
- 对话内容加密,只有持有私钥的双方能读取
安装 Nostr 插件
openclaw plugins install @openclaw/nostr生成或配置密钥对
Nostr 使用 nsec(私钥)/ npub(公钥)密钥对:
# 用 nostrtool 生成新密钥对
npx nostrtool generate
# 输出:
# Private key (nsec): nsec1xxxxxx...
# Public key (npub): npub1xxxxxx...
# 或用 nostr-tools
node -e "const {generatePrivateKey, getPublicKey, nip19} = require('nostr-tools');
const sk = generatePrivateKey();
console.log('nsec:', nip19.nsecEncode(sk));
console.log('npub:', nip19.npubEncode(getPublicKey(sk)));"配置 OpenClaw
{
"channels": {
"nostr": {
"enabled": true,
"privateKey": "nsec1xxxxxxxxxxxxxxxxxxxxxx",
"relays": [
"wss://relay.damus.io",
"wss://nos.lol",
"wss://relay.nostr.band",
"wss://nostr.mom"
],
"dmPolicy": "allowlist",
"allowedPubkeys": [
"npub1yourpubkey..."
]
}
}
}私钥也可以用 hex 格式:
{
"privateKey": "a1b2c3d4e5f6..."
}推荐 Relay 服务器
高可用公共 Relay:
wss://relay.damus.io - 最流行,稳定
wss://nos.lol - 速度快
wss://relay.nostr.band - 搜索功能好
wss://nostr.mom - 稳定
自托管 Relay(完全自主):
搭建 nostr-rs-relay 或 strfry,
完全掌控消息存储
配置多个 Relay 可以提升可靠性—— 任何一个 Relay 宕机,消息仍可通过其他 Relay 传递。
NIP-04 加密私信
OpenClaw 通过 NIP-04 协议接收加密私信:
用户操作(用 Damus/Amethyst 等 Nostr 客户端):
1. 找到 Bot 的 npub 公钥
2. 发送加密私信(DM)
3. Bot 解密后处理,加密后回复
加密细节:
- 消息用 ECDH(椭圆曲线 Diffie-Hellman)生成共享密钥
- 用 AES-256-CBC 加密消息内容
- 只有持有私钥的双方能解密
访问控制
allowedPubkeys:只允许特定 npub 公钥发起对话
{
"nostr": {
"dmPolicy": "allowlist",
"allowedPubkeys": [
"npub1alice...",
"npub1bob..."
]
}
}open 模式(任何人都能发消息):
{ "dmPolicy": "open" }⚠️ 在 open 模式下,任何 Nostr 用户都能给你的 Bot 发消息, 可能产生意外的 API 费用,建议限制在 allowlist 模式。
分享你的 Nostr Bot
配置完成后,把 Bot 的 npub 公钥分享给需要使用的人:
# 查看当前配置的公钥
openclaw status
# 或者从 nsec 派生 npub
npx nostrtool from-nsec nsec1xxxxx用户在 Damus、Amethyst、Snort 等 Nostr 客户端搜索这个 npub, 就能发起与 AI 的加密对话。
Nostr vs Signal:隐私对比
| 对比 | Nostr + OpenClaw | Signal |
|---|---|---|
| 去中心化 | ✅ 无中心服务器 | ❌ 依赖 Signal 服务器 |
| 端对端加密 | ✅ NIP-04 | ✅ Signal 协议 |
| 账号需求 | ❌ 只需密钥对(无注册) | ✅ 需要手机号 |
| 抗审查 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
| 易用性 | ⭐⭐⭐(需要 Nostr 客户端) | ⭐⭐⭐⭐⭐ |
Nostr 适合极致隐私和抗审查场景;Signal 适合日常隐私保护。
来源:OpenClaw 官方文档 - docs.openclaw.ai/channels/nostr