Modular Arithmetic and prime numbers With respect to the maths behind the Diffie Hellman Key exchange algorithm.  
Why does:
(ga mod p)b mod p = gab mod p
It might be fairly obvious, but what basic maths guarantees this? Why does the first modulo p expression disappear from the LHS in the expression on the RHS.
Apologies if it's not the right forum to ask it in. Maybe I should try the Information security stack Exchange forum instead.

It  reflects the definition of multiplication modulo $p$:
$$x\bmod p\cdot y\bmod p\begin{array}[b]{c}\text{def}\\[-1.5ex]{}={}\end{array}xy\bmod p$$
