diff options
| author | J08nY | 2025-03-23 17:06:57 +0100 |
|---|---|---|
| committer | J08nY | 2025-03-23 17:06:57 +0100 |
| commit | e7341fa4dfc03570eb97f0b4b6fad60af445a282 (patch) | |
| tree | d5d53af1d0556aa64cc0c19474f7c8d018f02188 | |
| parent | ea8200d09d93a7b45332cb897f80464a761e766f (diff) | |
| download | ecgen-e7341fa4dfc03570eb97f0b4b6fad60af445a282.tar.gz ecgen-e7341fa4dfc03570eb97f0b4b6fad60af445a282.tar.zst ecgen-e7341fa4dfc03570eb97f0b4b6fad60af445a282.zip | |
Have a bound on the CM walkdown, the discriminant grows too much otherwise.
Diffstat (limited to '')
| -rw-r--r-- | src/cm/cm_any.c | 18 | ||||
| -rw-r--r-- | src/math/subgroup.c | 6 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/cm/cm_any.c b/src/cm/cm_any.c index 368ce77..cd319ab 100644 --- a/src/cm/cm_any.c +++ b/src/cm/cm_any.c @@ -353,15 +353,9 @@ GENERATOR(cm_gen_curve_unique) { const char *order_s = (const char *)args->args; GEN order = strtoi(order_s); GEN e; - if (min_d && min_roots && min_curve == curve && - min_roots->used < min_roots->total) { - debug_log("Reusing roots."); - // We can just use the roots we have stored and take some out. - e = cm_construct_curve(order, min_d->d, min_d->p, min_roots, false); - } else if (min_d && min_curve == curve) { + if (min_d && min_curve == curve) { debug_log("Reusing min D = %Pi", min_d->d); - // We just have the discriminant but no roots (or they are used up), we - // need to continue + // We have some discriminant, cannot use the roots because the D with walkdown was too large. if (min_d->d && isclone(min_d->d)) { gunclone(min_d->d); } @@ -421,9 +415,17 @@ GENERATOR(cm_gen_curve_unique) { GEN power = gel(powers, i); debug_log("Walking down with %Pi %Pi", prime, power); GEN exp = mulis(power, 2); + debug_log("%Pi, %Pi", prime, exp); GEN mul = powii(prime, exp); + debug_log("%Pi", mul); d = mulii(d, mul); + debug_log("d %Pi", d); } + if (logint(d, gen_2) > 64) { + fprintf(err, "Discriminant too large."); + avma = ltop; + return -3; + } if (min_d->d && isclone(min_d->d)) { gunclone(min_d->d); } diff --git a/src/math/subgroup.c b/src/math/subgroup.c index fdf45a5..0b5c515 100644 --- a/src/math/subgroup.c +++ b/src/math/subgroup.c @@ -3,6 +3,7 @@ * Copyright (C) 2017-2018 J08nY */ #include "subgroup.h" +#include "io/output.h" /** * @brief All prime divisors of a given integer with multiplicity. @@ -46,6 +47,11 @@ static GEN subgroups_2n_factors(GEN factors, size_t min_bits) { long nprimes = glength(factors); if (nprimes == min_bits) return NULL; GEN amount = int2n(nprimes); + long abits = logint(amount, gen_2); + if (abits >= 64) { + fprintf(err, "Too many factors to generate points (%li bits).", abits); + return NULL; + } GEN groups = gtovec0(gen_0, itos(amount) - (min_bits * nprimes) - 1); size_t i = 0; |
