Exponentiation and multiexponentiation functions. If it is known in advance that a particular element will be exponentiated several times in the future, time can be saved in the long run by first calling the preprocessing function:
element_pp_t g_pp; element_pp_init(g_pp, g); element_pp_pow(h, pow1, g_pp); // h = g^pow1 element_pp_pow(h, pow2, g_pp); // h = g^pow2 element_pp_pow(h, pow3, g_pp); // h = g^pow3 element_pp_clear(g_pp);
void element_pow_mpz(element_t x, element_t a, mpz_t n)
Set x = an, that is a times a times … times a where there are n a's.
void element_pow_zn(element_t x, element_t a, element_t n)
Set x = an, where n is an element of a ring ZN for some N (typically the order of the algebraic structure x lies in).
void element_pow2_mpz(element_t x, element_t a1, mpz_t n1, element_t a2, mpz_t n2)
Sets x = a1n1 a2n2, and is generally faster than performing two separate exponentiations.
void element_pow2_zn(element_t x, element_t a1, element_t n1, element_t a2, element_t n2)
Also sets x = a1n1 a2n2, but n1, n2 must be elements of a ring Zn for some integer n.
void element_pow3_mpz(element_t x, element_t a1, mpz_t n1, element_t a2, mpz_t n2, element_t a3, mpz_t n3)
Sets x = a1n1 a2n2 a3n3, generally faster than performing three separate exponentiations.
void element_pow3_zn(element_t x, element_t a1, element_t n1, element_t a2, element_t n2, element_t a3, element_t n3)
Also sets x = a1n1 a2n2 a3n3, but n1, n2, n3 must be elements of a ring Zn for some integer n.
void element_pp_init(element_pp_t p, element_t in)
Prepare to exponentiate an element in, and store preprocessing information in p.
void element_pp_clear(element_pp_t p)
Clear p. Should be called after p is no longer needed.
void element_pp_pow(element_t out, mpz_t power, element_pp_t p)
Raise in to power and store the result in out, where in is a previously preprocessed element, that is, the second argument passed to a previous element_pp_init call.
void element_pp_pow_zn(element_t out, element_t power, element_pp_t p)
Same except power is an element of Zn for some integer n.
void element_dlog_brute_force(element_t x, element_t g, element_t h)
Computes x such that gx = h by brute force, where x lies in a field where
element_set_mpz()
makes sense.
void element_dlog_pollard_rho(element_t x, element_t g, element_t h)
Computes x such that gx = h using Pollard rho method, where x lies in a field where
element_set_mpz()
makes sense.