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
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
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 in p.
void pairing_pp_clear(pairing_pp_t p)
Clear p. This should be called after p is no longer needed.
void pairing_pp_apply(element_t out, element_t in2, pairing_pp_t p)
Compute a pairing using in2 and the preprocessed information stored in p and store the output in out. The inputs to the pairing are the element previously used to initialize p and the element in2.
void element_pairing(element_t out, element_t in1, element_t in2)
Computes a pairing: out = e(in1, in2), where in1, in2, out must 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, in2) … e(in1[n-1], in2[n-1]). The arrays in1, in2 must have at least n elements belonging to the groups G1, G2 respectively, and out must belong to the group GT.