When encrypting a string through the Libsodium secret box feature, the ciphertext is 48 bytes longer than the plain text message ...
I am wondering why this is ... since the nonce is only 24 bytes.
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.
Sign up to join this communityWhen encrypting a string through the Libsodium secret box feature, the ciphertext is 48 bytes longer than the plain text message ...
I am wondering why this is ... since the nonce is only 24 bytes.
Notice that $\operatorname{secretbox}$ has a $16$-byte MAC too. For reference, I've included $\operatorname{box}$ too.
$$ \operatorname{secretbox} : \text{24 nonce} + \text{0 xsalsa} + \text{16 poly1305}\\ \operatorname{box} : \text{32 curve25519} + \text{24 nonce} + \text{0 xsalsa} + \text{16 poly1305} $$
However, the nonce is user-controlled and normally not included in the ciphertext overhead as it is usually never sent, often a protocol-level counter.
You say "secret box" but you mean the normal "box" which uses a public key. Your ciphertext is expanded with your $32$-byte ephemeral public key and the $16$-byte MAC.
Sealed boxes: public key (32 bytes) + MAC (16 bytes).
The nonce is deterministic, as a new key pair is created for every message.