With pairing-based cryptography we have two cyclic groups (\(G_1\) and \(G_2\)), and which are of an order of a prime number (\(n\)). A pairing on \((G_1,G_2,G_T)\) defines the function \(e:G_1 \times G_2 \rightarrow G_T\), and where \(g_1\) is a generator for \(G_1\) and \(g_2\) is a generator for \(G_2\).
If \(U\) is a point on \(G_1\), and \(V\) is a point on \(G_2\), we get:
\(e(aU,V) = e(U,aV)\)
The shared key for Alice is \(e(id_a,P_b)\) and for Bob it is \(e(id_b,P_a)\).