aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2017-04-18 22:26:06 +0200
committerJ08nY2017-04-18 22:26:06 +0200
commitc9541b5fcc3d3a7b798ae1be2f5972ad2a5c3061 (patch)
tree0c891b0f259a6c0d0c13b0f3ddd434c5ed6d144c
parent368c1643ceb08f6a9e56e4635d0791c61c8fb4e8 (diff)
downloadecgen-c9541b5fcc3d3a7b798ae1be2f5972ad2a5c3061.tar.gz
ecgen-c9541b5fcc3d3a7b798ae1be2f5972ad2a5c3061.tar.zst
ecgen-c9541b5fcc3d3a7b798ae1be2f5972ad2a5c3061.zip
Load modular polynomial db in main thread
-rw-r--r--src/ecgen.c9
-rw-r--r--src/invalid/invalid.c4
-rw-r--r--src/invalid/invalid_thread.h2
-rw-r--r--src/math/types.h21
4 files changed, 31 insertions, 5 deletions
diff --git a/src/ecgen.c b/src/ecgen.c
index 9b1bd1d..3ccc750 100644
--- a/src/ecgen.c
+++ b/src/ecgen.c
@@ -45,10 +45,10 @@ static struct argp argp = {options, cli_parse, args_doc, doc, 0, cli_filter};
static config_t cfg;
bool init(void) {
- // Init PARI, 1GB stack, 1M primes
+ // init PARI, 1GB stack, 1M primes
pari_init(cfg.memory, 1000000);
- // Init PARI PRNG
+ // init PARI PRNG
if (!random_init()) return false;
// set datadir if specified
@@ -56,6 +56,11 @@ bool init(void) {
default0("datadir", cfg.datadir);
}
+ // init the modular polynomial db from seadata
+ pari_sp ltop = avma;
+ ellmodulareqn(2, -1, -1);
+ avma = ltop;
+
// open outfile
output_init(&cfg);
diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c
index 90e0edc..20a7063 100644
--- a/src/invalid/invalid.c
+++ b/src/invalid/invalid.c
@@ -2,10 +2,10 @@
* ecgen, tool for generating Elliptic curve domain parameters
* Copyright (C) 2017 J08nY
*/
-#include <io/config.h>
#include "invalid.h"
#include "exhaustive/exhaustive.h"
#include "invalid_thread.h"
+#include "io/config.h"
#include "io/output.h"
#include "math/curve.h"
#include "math/equation.h"
@@ -212,7 +212,7 @@ static size_t invalid_curves_threaded(curve_t *curve, config_t *cfg,
for (size_t i = 0; i < cfg->threads; ++i) {
pari_thread_alloc(&pari_threads[i], cfg->thread_memory,
- (GEN)&threads[i]);
+ (GEN)&threads[i]);
threads[i].pari_thread = &pari_threads[i];
threads[i].original_curve = curve;
diff --git a/src/invalid/invalid_thread.h b/src/invalid/invalid_thread.h
index 869018a..d8c1b76 100644
--- a/src/invalid/invalid_thread.h
+++ b/src/invalid/invalid_thread.h
@@ -15,7 +15,7 @@
typedef enum { STATE_FREE, STATE_GENERATING, STATE_GENERATED } state_e;
typedef struct {
- struct pari_thread* pari_thread;
+ struct pari_thread *pari_thread;
curve_t *original_curve;
size_t nprimes;
pari_ulong *primes;
diff --git a/src/math/types.h b/src/math/types.h
index 3d2476a..d6c0cca 100644
--- a/src/math/types.h
+++ b/src/math/types.h
@@ -12,14 +12,23 @@
#include "io/cli.h"
#include "io/config.h"
+/**
+ * @brief
+ */
typedef struct { GEN seed; } seed_t;
+/**
+ * @brief
+ */
typedef struct {
GEN point;
GEN order;
GEN cofactor;
} point_t;
+/**
+ * @brief
+ */
typedef struct {
seed_t *seed;
GEN field;
@@ -33,6 +42,9 @@ typedef struct {
size_t npoints;
} curve_t;
+/**
+ * @brief
+ */
typedef enum {
OFFSET_SEED,
OFFSET_FIELD,
@@ -45,13 +57,22 @@ typedef enum {
OFFSET_END
} offset_e;
+/**
+ * @brief
+ */
typedef struct {
const void *args;
size_t nargs;
} arg_t;
+/**
+ * @brief
+ */
typedef int (*gen_t)(curve_t *, const config_t *, arg_t *);
+/**
+ * @brief
+ */
typedef int (*unroll_t)(curve_t *, const config_t *, pari_sp, pari_sp);
/**