If the IV is known to the attacker and it's only one file. The time
needed to crack it's the same if the attacker doesn't know the IV.
If the attacker doesn't know the nonce, they must brute force it as well as the key. Therefore, it takes longer to perform brute force.
This is simple to explain with XChaCha20-Poly1305 because HChaCha20 is used with the key and part of the nonce to derive a subkey. This subkey and the rest of the nonce are then used for encryption with ChaCha20-Poly1305. This is explained in the Internet Draft.
Furthermore, the ChaCha state looks like this:
cccccccc cccccccc cccccccc cccccccc
kkkkkkkk kkkkkkkk kkkkkkkk kkkkkkkk
kkkkkkkk kkkkkkkk kkkkkkkk kkkkkkkk
bbbbbbbb nnnnnnnn nnnnnnnn nnnnnnnn
c=constant k=key b=blockcount n=nonce
Thus, hiding a random nonce means a) the attacker doesn't know the key for ChaCha20-Poly1305 and b) they don't know 64 bits of the nonce for ChaCha20-Poly1305, essentially making that part of the state an extension of the secret key:
cccccccc cccccccc cccccccc cccccccc
kkkkkkkk kkkkkkkk kkkkkkkk kkkkkkkk
kkkkkkkk kkkkkkkk kkkkkkkk kkkkkkkk
bbbbbbbb nnnnnnnn kkkkkkkk kkkkkkkk
c=constant k=key b=blockcount n=nonce
Note the reason it's not 96 bits (the full nonce) is because XChaCha20-Poly1305 involves prepending 4 0x00
bytes. Otherwise, XChaCha20-Poly1305 would need to take a 224-bit nonce instead of 192-bit, which doesn't align with how XSalsa20 was done.
But if you use the same key for different files with different IV and
the attacker doesn't know them, he'd have to crack each file from
scratch if the IV isn't known.
This is a bit confusing. Assuming the protocol is openly available or able to be reverse engineered, it may be obvious that the same key is being used, which means only the nonce has to be brute forced. Otherwise, the attacker would likely end up trying different keys, meaning brute forcing the key and nonce, which is the same as the first part of your question.
Anyway, it's really doesn't matter. It's standard practice for the nonce to be public, and the security advantage from hiding the nonce isn't 'meaningful' because anything above 256-bit security is unnecessary. The two benefits are:
- Saving storage/bandwidth. However, this can also be achieved with a regular counter nonce from 0, which is much simpler.
- Limiting metadata. However, a random nonce does this well enough if this is a concern. For many, including existing standards, this isn't a concern.