ahdinosaur / secret-channel

🤫 A protocol for an authenticated and encrypted message stream
4 stars 0 forks source link

Big endian vs little endian #4

Closed ahdinosaur closed 9 months ago

ahdinosaur commented 9 months ago

Not sure whether to use big endian or little endian.

My understanding is most CPUs are LE (so LE is more efficient), but network protocols are "supposed to be" BE. https://developer.mozilla.org/en-US/docs/Glossary/Endianness

One idea is we use little endian for the incrementing nonce (used internally), and big endian for the content length (sent over the network). Little endian for the nonce helps make incrementing with libsodium easy, because libsodium provides a increment function which increments a little-endian buffer.