The function `pairing_apply`

can be called to apply a bilinear map. The order
of the inputs is important. The first, which holds the output, must be from the
group GT. The second must be from G1, the third from G2, and the fourth must be
the `pairing_t`

variable that relates them.

In some applications, the programmer may know that many pairings with the same
G1 input will be computed. If so, preprocessing should be used to avoid
repeating many calculations saving time in the long run. A variable of type
`pairing_pp_t`

should be declared, initialized with the fixed G1 element, and
then used to compute pairings:

pairing_pp_t pp; pairing_pp_init(pp, x, pairing); // x is some element of G1 pairing_pp_apply(r1, y1, pp); // r1 = e(x, y1) pairing_pp_apply(r2, y2, pp); // r2 = e(x, y2) pairing_pp_clear(pp); // don't need pp anymore

Never mix and match G1, G2, and GT groups from different pairings.

void **pairing_pp_init**(*pairing_pp_t p*, *element_t in1*, *pairing_t pairing*)

Get ready to perform a pairing whose first input is

in1, and store the results of time-saving precomputation inp.

void **pairing_pp_clear**(*pairing_pp_t p*)

Clear

p. This should be called afterpis no longer needed.

void **pairing_pp_apply**(*element_t out*, *element_t in2*, *pairing_pp_t p*)

Compute a pairing using

in2and the preprocessed information stored inpand store the output inout. The inputs to the pairing are the element previously used to initializepand the elementin2.

void **element_pairing**(*element_t out*, *element_t in1*, *element_t in2*)

Computes a pairing:

out=e(in1,in2), wherein1,in2,outmust be in the groups G1, G2, GT.

void **element_prod_pairing**(*element_t out*, *element_t in1[]*, *element_t in2[]*, *int n*)

Computes the product of pairings, that is

out=e(in1[0],in2[0]) …e(in1[n-1],in2[n-1]). The arraysin1,in2must have at leastnelements belonging to the groups G1, G2 respectively, andoutmust belong to the group GT.