Why Nostr? What is Njump?
2023-02-03 10:37:39

wssh on Nostr: #nostr 的加密通信是如何实现的? 加密通信的依据是 ...

#nostr 的加密通信是如何实现的?

加密通信的依据是 NIP-04,相比于其他 NIP 标准,此标准给出了一份示例代码,加密通信也使用了 event 类型,但其 `content` 是 `<encrypted_text>?iv=<initialization_vector>` 的结构,而且其 `tags`必须包含 `["p", "<pubkey, as a hex string>"]` 以指明信息接受方。

加密密钥生成采用了经典的 ECDH 密钥交换,对于一个由非对称加密算法驱动的应用,这种技术选型无疑是正确的。

生成密钥后的加密算法使用了 aes-256-cbc

资料列表:
我在介绍 以太坊的 Discv5 协议时介绍了 ECDH 算法,可做参考:
https://blog.wssh.trade/posts/ethereum-p2p-discv5/#ecdh
NIP-04 文档:
https://github.com/nostr-protocol/nips/blob/master/04.md
Damus 相关源代码:
https://github.com/damus-io/damus/blob/master/damus/Nostr/NostrEvent.swift#L656
iris 的实现:
https://github.com/irislib/iris-messenger/blob/master/src/js/lib/nostr-tools/nip04.ts
Author Public Key
npub19qjyxn5a0xka32hfqpe5ppmaze0gv4p4zzrwh0gjazq6teflxlxqdhc8g0