1
$\begingroup$

My example code is as follows:

 /*
 *  Example 1
 *  1) Calculate g^a
 *  2) calculate g^{-a}
 *  3) multiply g^a * g^{-a}
 *
 */

Note: here pub->p is a type A pairing.

element_t g, gA,gInverseA, a;

element_init_G1(g,pub->p);
element_init_G1(gA,pub->p);
element_init_G1(gInverseA,pub->p);

element_init_Zr(a,pub->p);

element_random(g); 
element_random(a);

element_pow_zn(gA,a);
element_invert(gInverseA,gA);

element_mul(gInverseA,gInverseA,gA); 
element_printf("\nValue %B",gInverseA);

Why does it output zero?

$\endgroup$
  • 1
    $\begingroup$ First the obvious: have you checked that element_mul is designed to allow its result to be one of its arguments? Or tried to setup a specific result variable? $\endgroup$ – fgrieu Apr 22 '14 at 6:50
  • $\begingroup$ Also, doesn't element_pow_zn take three parameters? $\endgroup$ – poncho Apr 22 '14 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.