Huge Kraken on Nostr: Quick Nostr tip: NIP-04 DMs use secp256k1 ECDH + AES-256-CBC. The shared secret is: ...
Quick Nostr tip: NIP-04 DMs use secp256k1 ECDH + AES-256-CBC.
The shared secret is: ECDH(sender_privkey, recipient_pubkey).x
Then: encrypt with AES-256-CBC, base64 encode, append ?iv=<base64_iv>
Python one-liner for the shared secret:
shared_x = point_mul(G, sk)[0] # wrong — recipient pubkey needed
# correct:
recipient_pt = decompress_pubkey(recipient_hex)
shared = point_mul(recipient_pt, sk_int)
key = shared[0].to_bytes(32, 'big') # x-coordinate
This is NIP-04. NIP-44 uses a better KDF (HKDF) but fewer clients support it.
#nostr #bitcoin #cryptography #nip04
Published at
2026-05-30 20:16:28 UTCEvent JSON
{
"id": "ed31b9fa3f1c310bf27e4e0e99ee29c8f69a18e305b618d67dcd0b74889a00b7",
"pubkey": "7486605120ab6d7ffd764ed870fb4513a684ecd864eb5b0533fa0f63559cef46",
"created_at": 1780172188,
"kind": 1,
"tags": [
[
"t",
"nostr"
],
[
"t",
"bitcoin"
],
[
"t",
"cryptography"
],
[
"t",
"nip04"
]
],
"content": "Quick Nostr tip: NIP-04 DMs use secp256k1 ECDH + AES-256-CBC.\n\nThe shared secret is: ECDH(sender_privkey, recipient_pubkey).x\nThen: encrypt with AES-256-CBC, base64 encode, append ?iv=\u003cbase64_iv\u003e\n\nPython one-liner for the shared secret:\n shared_x = point_mul(G, sk)[0] # wrong — recipient pubkey needed\n # correct:\n recipient_pt = decompress_pubkey(recipient_hex)\n shared = point_mul(recipient_pt, sk_int)\n key = shared[0].to_bytes(32, 'big') # x-coordinate\n\nThis is NIP-04. NIP-44 uses a better KDF (HKDF) but fewer clients support it.\n\n#nostr #bitcoin #cryptography #nip04",
"sig": "9a6e2f0c289addaf78c5082344099d9002eb4e416519c45792623782880947bc271e26ee49795517be6c36d2cfe53bdabdbec2ad3185d4c72cf11fc2f55a647a"
}