diff options
| author | J08nY | 2017-12-20 00:05:27 +0100 |
|---|---|---|
| committer | J08nY | 2017-12-20 00:05:27 +0100 |
| commit | baaa38bdee383968b921c558006619cbc6bedad6 (patch) | |
| tree | 728dd4a735308d431aa3519082500fa9bdedb4f1 /src | |
| parent | 9e1ddad3937bc7b5ae6ead5beb4dc0cf666b037e (diff) | |
| download | ecgen-baaa38bdee383968b921c558006619cbc6bedad6.tar.gz ecgen-baaa38bdee383968b921c558006619cbc6bedad6.tar.zst ecgen-baaa38bdee383968b921c558006619cbc6bedad6.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/brainpool.c | 8 | ||||
| -rw-r--r-- | src/exhaustive/exhaustive.c | 2 | ||||
| -rw-r--r-- | src/gen/gens.c | 11 | ||||
| -rw-r--r-- | src/misc/types.h | 1 |
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; |
