惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

nostr

为什么是 Nostr? - V2EX 总结: 2025 年, nostr 如今怎么样了 - V2EX nostr 和 qtox 之类的东西真的有人坚持用么? - V2EX Nostr Relay - V2EX nostter - V2EX V2EX 的 Social Settings 现在可以填入 nostr 用户名,并在个人主页上展示 - V2EX 有没有 ios 客户端推荐 - V2EX 一篇搭建基于闪电网络的付费 nostr relay 的教程 - V2EX 一个想法:可以把 nostr relays 当作一个巨型的公网上的消息队列基础架构来用? - V2EX Nostr-新一代的去中心化社交协议 - V2EX 用了几天 nostr/damus 浅聊一下使用逻辑(和 Twitter 有什么区别) - V2EX 一片简单的 Nostr 学习笔记 - V2EX 用自己的 Hexo 博客完成 nostr 的 NIP-05 认证 - V2EX nostr 不依赖于 p2p,那它是怎样实现去中心化的? - V2EX 这里好像没有什么 nostr 的消息 - V2EX Nostr 是否可行? - V2EX Nostr 这个 怎么架设有了解的吗? - V2EX 把玩 Damus(nostr)有感 - V2EX 去中心化社交协议: Nostr - V2EX
v2ex.com/go/nostr - V2EX
Livid · 2023-02-09 · via nostr

同意。nostr 基础协议浅显易懂,一小段代码即可实现。

```
import secp256k1
import hashlib
import json
import time
import websocket

privkey = secp256k1.PrivateKey() #这里随机生成一个私钥,可以改成固定的
pubkey_64hex = privkey.pubkey.serialize()[1:].hex()

content = "Hello"
created_at = int(time.time())
kind = 1
tags = []

event_data = json.dumps([0, pubkey_64hex, created_at, kind, tags, content], separators=(',', ':'), ensure_ascii=False).encode()

event_hash = hashlib.sha256(event_data).hexdigest()
sig = privkey.schnorr_sign(bytes.fromhex(event_hash), bip340tag=None, raw=True).hex()

event = {
"id": event_hash,
"pubkey": pubkey_64hex,
"created_at": created_at,
"kind": kind,
"tags": tags,
"content": content,
"sig": sig
}
send_buf = json.dumps(["EVENT", event])

print(f"Send: {send_buf}")
ws = websocket.create_connection("wss://xxxxxx") #这里填写 Relay 的地址
ws.send(send_buf)
response = ws.recv()
print(f"Response: {response}")
ws.close()
```