#include "test_helpers.h"
#include "nmod.h"
#include "nmod_vec.h"
TEST_FUNCTION_START(nmod_vec_discrete_log_pohlig_hellman, state)
{
slong i, j, k;
for (i = 0; i < 20 * flint_test_multiplier(); i++)
{
nmod_discrete_log_pohlig_hellman_t L;
nmod_discrete_log_pohlig_hellman_init(L);
for (j = 0; j < 10; j++)
{
double score;
nmod_t fpctx;
ulong p;
p = n_randtest_prime(state, 1);
nmod_init(&fpctx, p);
score = nmod_discrete_log_pohlig_hellman_precompute_prime(L, p);
if (score > 10000)
{
continue;
}
for (k = 0; k < 10; k++)
{
ulong x;
ulong y, alpha = nmod_discrete_log_pohlig_hellman_primitive_root(L);
x = n_urandint(state, p - 1);
y = nmod_pow_ui(alpha, x, fpctx);
if (x != nmod_discrete_log_pohlig_hellman_run(L, y))
TEST_FUNCTION_FAIL("modulo %wu log base %wu of %wu should be %wu\n", p, alpha, y, x);
}
}
nmod_discrete_log_pohlig_hellman_clear(L);
}
TEST_FUNCTION_END(state);
}