Calculate shared key having A public Key and B private Key (Diffie Hellman)
$\text{B}_\text{private}$ is $\text{b}$ and $\text{B}_\text{public}$ is $\text{g}^\text{b} \bmod p$.

So $\text{B}$ can compute $(\text{A}_\text{public})^b \bmod p = \text{g}^{\text{ab}} \bmod p$