# 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:

1. Create a finite group, with "my custom" order ($Z_q$).
2. Choose a random value $g$ from this group.
3. 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!

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?

-
The only cryptographic bilinear groups I'm aware of whose elements have a nice representation as integers are the Boneh-Franklin groups (page 19). $\:$ –  Ricky Demer Aug 22 '13 at 7:10
@RickyDemer tnx. Let's forget about integers for a moment Can you tell me what's the deal with this "pairing"? I have read some general description about it, But I cannot relate it to a finite group! –  Z0lenDer Aug 22 '13 at 7:44
Isn't the size of ints on your machine a bit small for cryptographic data ? –  minar Aug 22 '13 at 7:45
@minar Actually int is that important to me. What I meant was sort some sort of type that I can manipulate. Not a struct or ... –  Z0lenDer Aug 22 '13 at 7:46
@Z0lenDer 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. –  imichaelmiers Aug 22 '13 at 16:56

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.

-
do you have a link for MIRCAL? The link on the PBC page doesn't work. –  mikeazo Aug 31 '13 at 23:11
Thanks. RELIC actually did what I was looking for and it was very easy to work with. –  Z0lenDer Sep 1 '13 at 16:25

You can't use any custom order, you need to use one of the predefined parameters (using pbc_param_init_set_str or pbc_param_init_set_buf) or to generate parameters (but you can't fix a specific order); see the "Param generation" section in the manual.

There is no standard conversion from elements to integers, since in PBC elements are either elliptic curve points or elements in extension fields. You can use element_to_bytes and element_from_bytes to convert elements to byte arrays, though (which you can interpret as big numbers, if you wish, but doing arithmetic on them will not make sense).

-
Thank you. I edit the question to remove the emphasize on Integers. Can you point to a resource or if you describe to me how to map the concept of multiplication in a single group to operations of pairing? –  Z0lenDer Aug 22 '13 at 16:07