aboutsummaryrefslogtreecommitdiff
path: root/src/invalid
diff options
context:
space:
mode:
authorJ08nY2017-04-10 23:47:46 +0200
committerJ08nY2017-04-10 23:56:03 +0200
commit2cf2eec873cb11f2f0767aac41da0f56dbd27cb9 (patch)
tree9b9a52548ccc7c9e54c500e4b587560ce18a017c /src/invalid
parentc1de68ff1e47dfbb1b85671e4fadcce1c49c8967 (diff)
downloadecgen-2cf2eec873cb11f2f0767aac41da0f56dbd27cb9.tar.gz
ecgen-2cf2eec873cb11f2f0767aac41da0f56dbd27cb9.tar.zst
ecgen-2cf2eec873cb11f2f0767aac41da0f56dbd27cb9.zip
Added unroll functions, to generalize going back in exhaustive generation
Diffstat (limited to 'src/invalid')
-rw-r--r--src/invalid/invalid.c10
-rw-r--r--src/invalid/invalid_thread.c11
-rw-r--r--src/invalid/invalid_thread.h1
3 files changed, 13 insertions, 9 deletions
diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c
index e01a49c..e6715b7 100644
--- a/src/invalid/invalid.c
+++ b/src/invalid/invalid.c
@@ -101,7 +101,7 @@ static size_t invalid_curves(curve_t *curve, config_t *cfg, pari_ulong *primes,
while (ncurves < nprimes) {
pari_sp btop = avma;
// generate a curve with random b
- exhaustive_gen(invalid, cfg, invalid_gen, NULL, OFFSET_B,
+ exhaustive_gen(invalid, cfg, invalid_gen, NULL, NULL, OFFSET_B,
OFFSET_GENERATORS);
// does some small prime from our array divide the curve order?
@@ -140,7 +140,7 @@ static size_t invalid_curves(curve_t *curve, config_t *cfg, pari_ulong *primes,
// generate prime order points, this is expensive (order needs to be
// factorised, so only do it if we want the curve)
- exhaustive_gen(invalid, cfg, invalid_gen, invalid_argss,
+ exhaustive_gen(invalid, cfg, invalid_gen, invalid_argss, NULL,
OFFSET_GENERATORS, OFFSET_END);
size_t count = 0;
@@ -269,14 +269,16 @@ int invalid_do(config_t *cfg) {
gen_t gen[OFFSET_END];
arg_t *argss[OFFSET_END];
+ unroll_t unrolls[OFFSET_END];
invalid_original_ginit(gen, cfg);
+ exhaustive_uinit(unrolls, cfg);
// create the curve to invalidate
// Either from input or random with -
curve_t *curve = curve_new();
// actually generate the curve
- if (!exhaustive_gen_retry(curve, cfg, gen, argss, OFFSET_FIELD,
- OFFSET_POINTS, 1)) {
+ if (!exhaustive_gen(curve, cfg, gen, argss, NULL, OFFSET_FIELD,
+ OFFSET_POINTS)) {
curve_free(&curve);
return 1;
}
diff --git a/src/invalid/invalid_thread.c b/src/invalid/invalid_thread.c
index 2f61ffa..a06bafa 100644
--- a/src/invalid/invalid_thread.c
+++ b/src/invalid/invalid_thread.c
@@ -22,8 +22,8 @@ void *invalid_thread(void *arg) {
while (*thread->generated < thread->nprimes) {
pari_sp btop = avma;
- exhaustive_gen(invalid, thread->cfg, thread->gens, NULL, OFFSET_B,
- OFFSET_GENERATORS);
+ exhaustive_gen(invalid, thread->cfg, thread->gens, NULL,
+ thread->unrolls, OFFSET_B, OFFSET_GENERATORS);
size_t ndivides = 0;
for (size_t i = thread->nprimes; i-- > 0;) {
if (dvdis(invalid->order, thread->primes[i])) {
@@ -53,7 +53,8 @@ void *invalid_thread(void *arg) {
arg_t prime_divisors = {primes, nprimes};
invalid_argss[OFFSET_POINTS] = &prime_divisors;
exhaustive_gen(invalid, thread->cfg, thread->gens,
- invalid_argss, OFFSET_GENERATORS, OFFSET_END);
+ invalid_argss, thread->unrolls,
+ OFFSET_GENERATORS, OFFSET_END);
pthread_mutex_lock(thread->mutex_state);
size_t count = 0;
@@ -77,11 +78,11 @@ void *invalid_thread(void *arg) {
invalid->field = gcopy(thread->original_curve->field);
invalid->a = gcopy(thread->original_curve->a);
} else {
- obj_free(invalid->curve); // necessary to free the ellinit
+ curve_unroll(invalid, thread->cfg, avma, btop);
avma = btop;
}
} else {
- obj_free(invalid->curve); // necessary to free the ellinit
+ curve_unroll(invalid, thread->cfg, avma, btop);
avma = btop;
}
}
diff --git a/src/invalid/invalid_thread.h b/src/invalid/invalid_thread.h
index bc30d04..4486961 100644
--- a/src/invalid/invalid_thread.h
+++ b/src/invalid/invalid_thread.h
@@ -25,6 +25,7 @@ typedef struct {
pthread_cond_t *cond_generated;
config_t *cfg;
gen_t *gens;
+ unroll_t *unrolls;
} thread_t;
/**