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

Mats Jerratsch [ARCHIVE] on Nostr: šŸ“… Original date posted:2015-10-27 šŸ“ Original message: >> 3) All packets from ...

šŸ“… Original date posted:2015-10-27
šŸ“ Original message:
>> 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 ?

Actually I think we do not need this field. Initially, the idea was to
provide replay protection. You keep track of totlen locally, and
compare it with the value the other party sends to you.

However, as we are using AES-CTR, we do not need to do that. We have a
dedicated counter in the IV that does keep track of all messages in
each direction respectively. If some attacker tries to replay the same
message towards us, we are unable to decrypt it, as the IV is not
correct (as it is assuming a different counter)
Author Public Key
npub1hz386xq4qszumlx5fsxa3kuxpaf8qvfrqqjg8zdl2l892hrcg55q6q5x8w