ElGamal: Generation of "g" value? I haven't been able to find a clear explanation on this (and I'm probably just confused in general).  I have the following parameters of ElGamal signatures:


$p$ = safe prime
$q = (p-1)/2$
$g$ = an element of $F_p$ with order $q$.
$r$ = random $1 &lt; r &lt; q $
$s$ = private key
$Y$ = public key, $Y = g^s$


My question is, is there an easy way to generate a $g$ value, or should I just generate a random value, then check that it is in the group?
If $q$ is prime (which is a common additional constraint) then the possible orders for a random $F_p$ between $2$ and $p-2$ inclusive is either $q$ or $2q$ so you can avoid having to check the order by picking one at random, squaring it and using the result.