You don't need TikZ for this. If you're using LaTeX, you just need amsmath
and the mathtools
package (both of which you likely have):
\documentclass{minimal}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\[\begin{matrix}
x \xleftarrow{\quad R\quad} \mathcal{Z}_q &\quad
\xrightleftharpoons[\beta=g^y]{\quad\alpha=g^x\quad} \quad&
y \xleftarrow{\quad R\quad} \mathcal{Z}_q \\
g^{xy} & & g^{xy} \\
\end{matrix}\]
\end{document}
This produces the following output:
The amsmath package provides the \xleftarrow
and \xrigharrow
commands, which set an eXtensible \leftarrow
and \righarrow
, respectively; their mandatory argument is set on top, and their optional argument is set below (\xleftarrow[below]{above}
). Normally, it's just as wide as necessary for the text, so I inserted \quad
s around the text to space it out. The mathtools
package, which extends amsmath
, provides more extensible arrows, including \xleftrightarrow
(for an extensible ↔), \xLeftrightarrow
(for an extensible ⇔), \xleftrighharpoons
(for an extensible ⇋; the upside-down version of the symbol in the example picture), and \xrightleftharpoons
(for an extensible ⇌, as seen in the example picture), any of which could be used here depending on your tastes.
Also, note that you shouldn't need to space out the \xrightleftharpoons
like I did (which is why there's &\quad ... \quad&
), but apparently I needed to here (though in LaTeXit I didn't, so with some small change you probably wouldn't need to). You only need the matrix here since you want to align the g^{xy}
s with the first and third arrows; if you just wanted the top line, you wouldn't need to bother.