aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exhaustive/brainpool.c8
-rw-r--r--src/exhaustive/exhaustive.c2
-rw-r--r--src/gen/gens.c11
-rw-r--r--src/misc/types.h1
4 files changed, 8 insertions, 14 deletions
diff --git a/src/exhaustive/brainpool.c b/src/exhaustive/brainpool.c
index 499522e..b36f54b 100644
--- a/src/exhaustive/brainpool.c
+++ b/src/exhaustive/brainpool.c
@@ -3,8 +3,8 @@
* Copyright (C) 2017 J08nY
*/
-#include <misc/types.h>
#include "brainpool.h"
+#include <misc/types.h>
#include "gen/gens.h"
#include "gen/point.h"
#include "gen/seed.h"
@@ -242,10 +242,12 @@ GENERATOR(brainpool_gen_gens) {
curve->ngens = 1;
point_t *G = point_new();
curve->generators[0] = G;
- G->point = gerepilecopy(ltop, ellmul(curve->curve, P, k));
+ G->point = ellmul(curve->curve, P, k);
G->order = ellorder(curve->curve, G->point, NULL);
G->cofactor = divii(curve->order, G->order);
-
+ seed->brainpool.mult = k;
+ gerepileall(ltop, 4, &G->point, &G->order, &G->cofactor,
+ &seed->brainpool.mult);
return 1;
}
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c
index c5e9ffc..a1d3832 100644
--- a/src/exhaustive/exhaustive.c
+++ b/src/exhaustive/exhaustive.c
@@ -286,7 +286,7 @@ int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup,
return 0;
}
- pari_sp stack_tops[OFFSET_END] = {0};
+ pari_sp stack_tops[OFFSET_END] = {avma};
int gen_tries[OFFSET_END] = {0};
int state = start_offset;
diff --git a/src/gen/gens.c b/src/gen/gens.c
index 04e7646..858ce93 100644
--- a/src/gen/gens.c
+++ b/src/gen/gens.c
@@ -49,16 +49,7 @@ CHECK(gens_check_anomalous) {
}
GEN gens_get_embedding(GEN prime, GEN order) {
- pari_sp ltop = avma;
- GEN degree = gen_0;
- GEN power = gen_1;
- GEN pm;
- do {
- degree = addii(degree, gen_1);
- power = mulii(power, prime);
- pm = subii(power, gen_1);
- } while (!dvdii(pm, order));
- return gerepilecopy(ltop, degree);
+ return Fp_order(prime, subis(order, 1), order);
}
CHECK(gens_check_embedding) {
diff --git a/src/misc/types.h b/src/misc/types.h
index 76f8510..fc84bed 100644
--- a/src/misc/types.h
+++ b/src/misc/types.h
@@ -49,6 +49,7 @@ typedef struct {
long v;
bits_t *seed_a;
bits_t *seed_b;
+ GEN mult;
} brainpool;
};
} seed_t;