hackergrrl / chacha-stream

Encryption and decryption streams of libsodium's chacha20 implementation.
6 stars 0 forks source link

Should this use a length-prefixed nonce instead of fixed length? #1

Open gmaclennan opened 4 years ago

gmaclennan commented 4 years ago

Is sodium.crypto_stream_chacha20_NONCEBYTES guaranteed to stay constant? Would it be worth passing the nonce as length-prefixed so that the receiver does not need to know the length of the nonce in advance? It seems like the length shouldn't change, but wondering if length-prefixed makes sense since nonces are length-prefixed in hypercore-protocol.

hackergrrl commented 4 years ago

If the length changes, things will break anyways, because the other side will try to use a nonce that's wrong for its local version of sodium. :(