static void fp_from_hash(element_ptr n, void *data, int len) { mpz_t z; mpz_init(z); mpz_import(z, len, -1, 1, -1, 0, data); fp_set_mpz(n, z); mpz_clear(z); }
static void fp_from_hash(element_ptr a, void *data, int len) { mpz_t z; mpz_init(z); pbc_mpz_from_hash(z, a->field->order, (unsigned char*)data, len); fp_set_mpz(a, z); mpz_clear(z); }
static int fp_set_str(element_ptr e, const char *s, int base) { mpz_t z; mpz_init(z); int result = pbc_mpz_set_str(z, s, base); mpz_mod(z, z, e->field->order); fp_set_mpz(e, z); mpz_clear(z); return result; }
static int fp_from_bytes(element_t e, unsigned char *data) { int n; mpz_t z; mpz_init(z); n = e->field->fixed_length_in_bytes; mpz_import(z, n, 1, 1, 1, 0, data); fp_set_mpz(e, z); mpz_clear(z); return n; }