Due to a number of recently asked questions about Diffie-Hellman, I was thinking this morning: must $g$ in Diffie-Hellman be a generator?
Recall the mathematics of Diffie-Hellman:
Given public parameters $p$ (a large prime) and $g$ (always referred to as a generator of $\mathbb{Z}^*_p$).
- Alice chooses $a$ at random and sends $A \gets g^a \mod{p}$ to Bob.
- Bob chooses $b$ at random and sends $B \gets g^b \mod{p}$ to Alice.
- Alice computes $S \gets B^a \mod{p}$
- Bob computes $S \gets A^b \mod{p}$
From the math above, I don't see anything that would require $g$ to be a generator, so the math should work even if $g$ is not a generator.
As far as security goes, clearly having $g$ be a generator is best as $|g|$ (or the order of $g$) will be greatest when $g$ is indeed a generator. Is that the only reason for choosing $g$ to be a generator?