Suppose I want to commit to a uniformly picked nonce of fixed length $n$ bits without revealing the nonce, so I use a secure hash function $H$ mapping messages to digests of length $d$ bits. Suppose $H$ promises a complexity of $\sim 2^d$ for a preimage attack, and $\sim 2^{d/2}$ for a collision attack. Suppose $n$ is publicly known.
Clearly, at least for the preimage attack, the above promise cannot gain you a complexity of more than $2^n$ for $n<d$, because then you can just try out all $2^n$ messages.
My question is: is it considered safe for practical purposes (say, for $H$ from the SHA-2 or SHA-3 family) to use $n=d$ for obtaining the full or almost full complexity of $H$, or should $n$ be even greater?