Why Nostr? What is Njump?
2023-06-09 12:44:57
in reply to

Pierre [ARCHIVE] on Nostr: 📅 Original date posted:2015-10-27 📝 Original message: A few more remarks: > 2) ...

📅 Original date posted:2015-10-27
📝 Original message:
A few more remarks:

> 2) ECDH is used to derive a shared secret. From this we generate
> the following transmission encoding parameters for each side:
> Session AES-128 key: SHA256(shared-secret || my-sessionpubkey || 0)
> Session HMAC key: SHA256(shared-secret || my-sessionpubkey || 1)
> IV for AES: SHA256(shared-secret || my-sessionpubkey || 2)
I suppose we use only the first 16 bytes for aes_key and aes_iv ?

> 3) All packets from then on are encrypted of form:
> /* HMAC, covering totlen and data */
> struct sha256 hmac;
> /* Total data transmitted (including this). */
> le64 totlen;
> /* Encrypted contents, rounded up to 16 byte boundary. */
> u8 data[];
Looking at your code it seems totlen is actually the size of the
unencrypted serialized protobuf message, not the total data
transmitted right ? If so, the comment is a bit misleading, and why
make totlen include the length of itself since it doesn't define the
encrypted message boundaries anyway ?
Also, why encode the length on 64 bits rather than 32 bits ?

Cheers,

Pierre
Author Public Key
npub1yz88535e0ydqye9q9x8l5cz9d3g6ervfjgyk5xm88zvktmxvstlsuy4pdt