diff options
| author | J08nY | 2017-02-14 21:20:08 +0100 |
|---|---|---|
| committer | J08nY | 2017-02-14 21:20:08 +0100 |
| commit | 39c6155e0193ff69dcdf765e936487bfcf4f1b17 (patch) | |
| tree | 93230b214c64951ded6451f439f304ccca02b7e0 /src/exhaustive | |
| parent | 0c5ff628d52678bb44b9c595daf1289833d0e532 (diff) | |
| download | ecgen-39c6155e0193ff69dcdf765e936487bfcf4f1b17.tar.gz ecgen-39c6155e0193ff69dcdf765e936487bfcf4f1b17.tar.zst ecgen-39c6155e0193ff69dcdf765e936487bfcf4f1b17.zip | |
Added point generation:
- Prime order points for all prime divisors of curve order (all prime subgroups)
- Random points
- Minimal set of generators of the whole group (one or two points)
Diffstat (limited to 'src/exhaustive')
| -rw-r--r-- | src/exhaustive/exhaustive.c | 20 | ||||
| -rw-r--r-- | src/exhaustive/seed.c | 7 | ||||
| -rw-r--r-- | src/exhaustive/seed.h | 14 |
3 files changed, 38 insertions, 3 deletions
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index c5cdebd..00905c5 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -8,6 +8,7 @@ #include "math/equation.h" #include "math/field.h" #include "math/order.h" +#include "math/point.h" #include "seed.h" void exhaustive_init(gen_t generators[], config_t *config) { @@ -53,6 +54,8 @@ void exhaustive_init(gen_t generators[], config_t *config) { } else { generators[OFFSET_FIELD] = &field_input; } + + generators[OFFSET_POINTS] = &points_generators; } int exhaustive_gen(curve_t *curve, config_t *config, gen_t generators[], @@ -64,8 +67,21 @@ int exhaustive_gen(curve_t *curve, config_t *config, gen_t generators[], fprintf(stderr, "Error generating a curve. %i\n", state); return 0; } + if (config->verbose) { + if (diff > 0) { + fprintf(out, "+"); + } else if (diff < 0) { + fprintf(out, "-"); + } else { + fprintf(out, "."); + } + fflush(out); + } state += diff; } + + if (config->verbose) fprintf(out, "\n"); + return 1; } @@ -74,11 +90,11 @@ int exhaustive_do(config_t *cfg) { exhaustive_init(generators, cfg); curve_t *curve = curve_new(); - if (!exhaustive_gen(curve, cfg, generators, OFFSET_FIELD, OFFSET_POINTS)) { + if (!exhaustive_gen(curve, cfg, generators, OFFSET_FIELD, OFFSET_END)) { curve_free(&curve); return 1; } - output_csv(out, "%P#x", ';', curve_params(curve)); + output_csv(out, "%P#x", ',', curve_params(curve)); curve_free(&curve); return 0; }
\ No newline at end of file diff --git a/src/exhaustive/seed.c b/src/exhaustive/seed.c index 0656db5..9f6ec46 100644 --- a/src/exhaustive/seed.c +++ b/src/exhaustive/seed.c @@ -5,7 +5,7 @@ #include "seed.h" #include "io/input.h" -seed_t *seed_new() { +seed_t *seed_new(void) { seed_t *seed = pari_malloc(sizeof(seed_t)); if (!seed) { perror("Couldn't malloc."); @@ -15,6 +15,11 @@ seed_t *seed_new() { return seed; } +seed_t *seed_copy(seed_t *src, seed_t *dest) { + dest->seed = gcopy(src->seed); + return dest; +} + void seed_free(seed_t **seed) { if (*seed) { pari_free(*seed); diff --git a/src/exhaustive/seed.h b/src/exhaustive/seed.h index 7c96372..06857fc 100644 --- a/src/exhaustive/seed.h +++ b/src/exhaustive/seed.h @@ -10,6 +10,20 @@ /** * + * @return + */ +seed_t *seed_new(void); + +/** + * + * @param src + * @param dest + * @return + */ +seed_t *seed_copy(seed_t *src, seed_t *dest); + +/** + * * @param seed */ void seed_free(seed_t **seed); |
