What is the purpose of encrypting the keyed hash? I’m assuming there’s something intelligent that an attacker might do with it if it were not encrypted, but I cannot figure out what that could be. Moreover, the efficiency implications creep up on you.

You don’t count on it to matter in your chat app till you begin letting customers attach files to messages and abruptly you are encrypting 10GB recordsdata instead of 10 byte messages. Then you begin dropping customers to apps that use faster encryption, or worse, no encryption. Chacha20-Poly1305 (keystream out of counter mode XOR plaintext for encryption, Carter-Wegman MAC). That implies that a hash is strong sufficient that you just need not monitor messages.
The nonce could presumably be stored as an inner counter, but that may require the encryption operation to change inside state, which might https://www.fileoasis.com/62607/screenshot-pedable-foot-pedal-software.html then require locking in order to be thread safe. That would introduce extra complexity than requiring the caller to provide the nonce. The nonce is also called an initialization vector (IV). The key and nonce/IV are used to encrypt the plaintext using AES-CTR. A keyed hash, GHASH, is then computed over the additional information and the cipher textual content. That hash is encrypted with AES too, and also you get an authentication tag.
Firstly, GHASH is replaced with POLYVAL, a hash that’s virtually precisely the same however reverses the order of some bytes as a outcome of it turns out that’s more environment friendly on most platforms. Secondly, somewhat than using the important thing and a nonce to initialize the AES-CTR encryption, a synthetic IV is computed from the nonce that the caller provides and an encrypted POLYVAL hash of the plaintext. Moreover, RNGs require internal state to stop giving the same random numbers twice, so on this context it is only a slower counter that may still introduce locking.
Once accomplished, a third group of good specialists tweak the algorithm in an incompatible method to gain 10% pace on particular platforms and forcing folks to tug in even more obscure code. The GHASH/GCM bit twiddling is so awful and sluggish and side-channel insecure to do in software, that most people simply blindly copy the obscure code full of clever optimization that smart specialists come up with 1. My level was I disagree in your sentence “one of the simplest ways to generate a novel nonce is as a hash of the enter message – in any other case you technically need to document each nonce you’ve ever used.” Then different sensible specialists 2 should reverse engineer stated intelligent methods (now broadly used everywhere), as a outcome of no clarification exists and it is not clear why they work within the first place.

If you imagine that to be the case then a CSRNG could be equally as robust of not stronger and fewer advanced. I would wager that using a cryptographically secure RNG is less more likely to produce the identical quantity twice, or on the very least equally as doubtless. If you could have a really sturdy hash, then the hash algorithm ought to act the same as an RNG.