Create a field in PBC Edited (I removed the emphasize on Integers):

My question is partly cryptography and partly programming, I would appreciate any help on any aspect of it :)

I want to use PBC library to do the following operations:


Create a finite group, with "my custom" order ($Z_q$).
Choose a random value $g$ from this group.
Compute $g^r$, where $r$ is a random integer.


I tried to make the above work but I could not figure out to relate a finite group of my choice to this notion of pairing-based cryptography with no avail!



EDIT: Some more info on my problem:

In its simplest form, what I want to do is to choose $g$, $r_1$, and $r_2$, compute $g^{r_1}$ and $g^{r_2}$. To confirm the computation, I will later compute $g^{r_1+r_2}$ and compare it with multiplication of the previous values.

How can I achieve this in PBC?
I point this out because a fair number of practicing cryptographers aren't aware: PBC is slow and outdated and a pain to work with. MIRCAL and RELIC are the two main alternatives.