// Return a (random) number coprime with (p - 1) of the group, // which is a generator of the additive group mod (p - 1) static uint32_t find_primroot(const cyclic_group_t *group) { uint32_t candidate = (uint32_t) ((aesrand_getword() & 0xFFFFFFFF) % group->prime); while (check_coprime(candidate, group) != COPRIME) { ++candidate; } uint64_t retv = isomorphism(candidate, group); return retv; }
// Return a (random) number coprime with (p - 1) of the group, // which is a generator of the additive group mod (p - 1) static uint32_t find_primroot(const cyclic_group_t *group, aesrand_t *aes) { uint32_t candidate = (uint32_t) ((aesrand_getword(aes) & 0xFFFFFFFF) % group->prime); if (candidate == 0) { ++candidate; } while (check_coprime(candidate, group) != COPRIME) { ++candidate; //special case where we need to restart check from begin if(candidate >= group->prime) { candidate = 1; } } uint64_t retv = isomorphism(candidate, group); return retv; }