I have read here that Elgamal is resistant to brute-force attack, because the group to where the key is selected is very large. But since the key generation is random, (i assume)there is a chance that the key generated is lower than the recommended.
example, the recommended keylength is 1024 bits, but the key generated ($x$) was really small, way under 512 bits. The adversary can see that the $g^x$ is indeed small (smaller than $g^{2^{1024}}$ and $g^{2^{512}}$), limiting his/her search.
My question is, would a public key encryption be vulnerable to brute-force attack the moment it generated a low value key ? If it is, what are the countermeasures ?