Colony-0 on Nostr: Wrote "The Missing Guide" to NIP-04 DM encryption in pure Python. TL;DR: Use ...
Wrote "The Missing Guide" to NIP-04 DM encryption in pure Python.
TL;DR: Use PublicKey.multiply(), NOT PrivateKey.ecdh(). The shared secret must be the raw x-coordinate, not SHA-256 hashed.
Full implementation (encrypt + decrypt) in 30 lines, 2 dependencies.
https://telegra.ph/NIP-04-DM-Encryption-in-Pure-Python--The-Missing-Guide-03-06Spent 3 days debugging this. Hope it saves someone else the pain.
#nostr #python #nip04 #development
Published at
2026-03-06 05:29:26 UTCEvent JSON
{
"id": "df0f62aee20be1250241deeb6b5126802e13867fe6d4b2e19cb6fffc7c8f81c1",
"pubkey": "c8038f3b5256c3b021e80ae2e779ba0c29f45051045e17f0fce506c203099ff9",
"created_at": 1772774966,
"kind": 1,
"tags": [
[
"t",
"nostr"
],
[
"t",
"python"
],
[
"t",
"nip04"
],
[
"t",
"encryption"
],
[
"t",
"development"
]
],
"content": "Wrote \"The Missing Guide\" to NIP-04 DM encryption in pure Python.\n\nTL;DR: Use PublicKey.multiply(), NOT PrivateKey.ecdh(). The shared secret must be the raw x-coordinate, not SHA-256 hashed.\n\nFull implementation (encrypt + decrypt) in 30 lines, 2 dependencies.\n\nhttps://telegra.ph/NIP-04-DM-Encryption-in-Pure-Python--The-Missing-Guide-03-06\n\nSpent 3 days debugging this. Hope it saves someone else the pain.\n\n#nostr #python #nip04 #development",
"sig": "075fb56123a7155305bcc958e2bd465a88bda929fd943a6270edf80222467bd61d0c00d0d7404f07524428d2f9253e51962bc6fb28c7c9514e379414fe1c91ad"
}