aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorJ08nY2017-03-09 13:18:15 +0100
committerJ08nY2017-03-09 13:18:15 +0100
commit8c65683537ea57a435a2f987f540bcc2ec5db678 (patch)
tree18d6e8893c885d98392d9a4cc9a9d98e67003f18 /src/math
parent7eff89c0095da4246a7b9c5a6654dc0d7692325e (diff)
downloadecgen-8c65683537ea57a435a2f987f540bcc2ec5db678.tar.gz
ecgen-8c65683537ea57a435a2f987f540bcc2ec5db678.tar.zst
ecgen-8c65683537ea57a435a2f987f540bcc2ec5db678.zip
Rename and reformat
Diffstat (limited to 'src/math')
-rw-r--r--src/math/arg.c1
-rw-r--r--src/math/arg.h2
-rw-r--r--src/math/curve.c16
-rw-r--r--src/math/curve.h6
-rw-r--r--src/math/equation.c34
-rw-r--r--src/math/equation.h24
-rw-r--r--src/math/field.c18
-rw-r--r--src/math/field.h4
-rw-r--r--src/math/gens.c4
-rw-r--r--src/math/gens.h4
-rw-r--r--src/math/order.c2
-rw-r--r--src/math/point.c8
-rw-r--r--src/math/point.h8
-rw-r--r--src/math/types.c2
-rw-r--r--src/math/types.h2
15 files changed, 67 insertions, 68 deletions
diff --git a/src/math/arg.c b/src/math/arg.c
index be3f92e..991eebb 100644
--- a/src/math/arg.c
+++ b/src/math/arg.c
@@ -4,7 +4,6 @@
*/
#include "arg.h"
-
arg_t *arg_new() {
arg_t *arg = pari_malloc(sizeof(arg_t));
if (!arg) {
diff --git a/src/math/arg.h b/src/math/arg.h
index 55e1b19..a7859dd 100644
--- a/src/math/arg.h
+++ b/src/math/arg.h
@@ -20,6 +20,6 @@ arg_t *arg_new();
* @brief
* @param arg
*/
-void arg_free (arg_t **arg);
+void arg_free(arg_t **arg);
#endif // ECGEN_ARG_H
diff --git a/src/math/curve.c b/src/math/curve.c
index 284cd39..5b609fa 100644
--- a/src/math/curve.c
+++ b/src/math/curve.c
@@ -41,7 +41,7 @@ void curve_free(curve_t **curve) {
}
}
-int curve_any(curve_t *curve, config_t *config, arg_t *args) {
+int curve_any(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
GEN v = gen_0;
switch (typ(curve->field)) {
@@ -64,9 +64,9 @@ int curve_any(curve_t *curve, config_t *config, arg_t *args) {
return 1;
}
-int curve_nonzero(curve_t *curve, config_t *config, arg_t *args) {
+int curve_nonzero(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
- curve_any(curve, config, args);
+ curve_any(curve, cfg, args);
if (gequal0(ell_get_disc(curve->curve))) {
avma = ltop;
return -3;
@@ -75,22 +75,22 @@ int curve_nonzero(curve_t *curve, config_t *config, arg_t *args) {
}
}
-int curve_seed_fp(curve_t *curve, config_t *config, arg_t *args) {
+int curve_seed_fp(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO implement
return INT_MIN;
}
-int curve_seed_f2m(curve_t *curve, config_t *config, arg_t *args) {
+int curve_seed_f2m(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO implement
return INT_MIN;
}
-int curve_seed(curve_t *curve, config_t *config, arg_t *args) {
+int curve_seed(curve_t *curve, config_t *cfg, arg_t *args) {
switch (typ(curve->field)) {
case t_INT:
- return curve_seed_fp(curve, config, args);
+ return curve_seed_fp(curve, cfg, args);
case t_FFELT:
- return curve_seed_f2m(curve, config, args);
+ return curve_seed_f2m(curve, cfg, args);
default:
pari_err_TYPE("curve_seed", curve->field);
return INT_MIN; /* NOT REACHABLE */
diff --git a/src/math/curve.h b/src/math/curve.h
index 3da391b..25e4f51 100644
--- a/src/math/curve.h
+++ b/src/math/curve.h
@@ -22,7 +22,7 @@
* @param args unused
* @return state diff
*/
-int curve_any(curve_t *curve, config_t *config, arg_t *args);
+int curve_any(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -34,7 +34,7 @@ int curve_any(curve_t *curve, config_t *config, arg_t *args);
* @param args unused
* @return state diff
*/
-int curve_nonzero(curve_t *curve, config_t *config, arg_t *args);
+int curve_nonzero(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -47,7 +47,7 @@ int curve_nonzero(curve_t *curve, config_t *config, arg_t *args);
* @param args unused
* @return state diff
*/
-int curve_seed(curve_t *curve, config_t *config, arg_t *args);
+int curve_seed(curve_t *curve, config_t *cfg, arg_t *args);
/**
* Serializes curve parameters into a t_VEC:
diff --git a/src/math/equation.c b/src/math/equation.c
index 45b849b..d676350 100644
--- a/src/math/equation.c
+++ b/src/math/equation.c
@@ -5,14 +5,14 @@
#include "equation.h"
#include "io/input.h"
-int a_random(curve_t *curve, config_t *config, arg_t *args) {
+int a_random(curve_t *curve, config_t *cfg, arg_t *args) {
curve->a = genrand(curve->field);
return 1;
}
-int a_input(curve_t *curve, config_t *config, arg_t *args) {
+int a_input(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
- GEN inp = input_int("a:", config->bits);
+ GEN inp = input_int("a:", cfg->bits);
if (gequalm1(inp)) {
avma = ltop;
return 0;
@@ -25,13 +25,13 @@ int a_input(curve_t *curve, config_t *config, arg_t *args) {
static GEN a = NULL;
static curve_t *curve_a = NULL;
-int a_once(curve_t *curve, config_t *config, arg_t *args) {
+int a_once(curve_t *curve, config_t *cfg, arg_t *args) {
if (a && curve_a == curve) {
curve->a = gcopy(a);
return 1;
}
- int inp = a_input(curve, config, args);
+ int inp = a_input(curve, cfg, args);
if (inp > 0) {
a = gclone(curve->a);
curve_a = curve;
@@ -41,29 +41,29 @@ int a_once(curve_t *curve, config_t *config, arg_t *args) {
}
}
-int a_zero(curve_t *curve, config_t *config, arg_t *args) {
+int a_zero(curve_t *curve, config_t *cfg, arg_t *args) {
curve->a = gen_0;
return 1;
}
-int a_one(curve_t *curve, config_t *config, arg_t *args) {
+int a_one(curve_t *curve, config_t *cfg, arg_t *args) {
curve->a = gen_1;
return 1;
}
-int a_seed(curve_t *curve, config_t *config, arg_t *args) {
+int a_seed(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO implement
return INT_MIN;
}
-int b_random(curve_t *curve, config_t *config, arg_t *args) {
+int b_random(curve_t *curve, config_t *cfg, arg_t *args) {
curve->b = genrand(curve->field);
return 1;
}
-int b_input(curve_t *curve, config_t *config, arg_t *args) {
+int b_input(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
- GEN inp = input_int("b:", config->bits);
+ GEN inp = input_int("b:", cfg->bits);
if (gequalm1(inp)) {
avma = ltop;
return 0;
@@ -74,15 +74,15 @@ int b_input(curve_t *curve, config_t *config, arg_t *args) {
}
static GEN b = NULL;
-static curve_t* curve_b = NULL;
+static curve_t *curve_b = NULL;
-int b_once(curve_t *curve, config_t *config, arg_t *args) {
+int b_once(curve_t *curve, config_t *cfg, arg_t *args) {
if (b && curve_b == curve) {
curve->b = gcopy(b);
return 1;
}
- int inp = b_input(curve, config, args);
+ int inp = b_input(curve, cfg, args);
if (inp > 0) {
b = gclone(curve->b);
curve_b = curve;
@@ -92,17 +92,17 @@ int b_once(curve_t *curve, config_t *config, arg_t *args) {
}
}
-int b_zero(curve_t *curve, config_t *config, arg_t *args) {
+int b_zero(curve_t *curve, config_t *cfg, arg_t *args) {
curve->b = gen_0;
return 1;
}
-int b_one(curve_t *curve, config_t *config, arg_t *args) {
+int b_one(curve_t *curve, config_t *cfg, arg_t *args) {
curve->b = gen_1;
return 1;
}
-int b_seed(curve_t *curve, config_t *config, arg_t *args) {
+int b_seed(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO implement
return INT_MIN;
}
diff --git a/src/math/equation.h b/src/math/equation.h
index 28ded06..03d87af 100644
--- a/src/math/equation.h
+++ b/src/math/equation.h
@@ -22,7 +22,7 @@
* @param args
* @return state diff
*/
-int a_random(curve_t *curve, config_t *config, arg_t *args);
+int a_random(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -33,7 +33,7 @@ int a_random(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int a_input(curve_t *curve, config_t *config, arg_t *args);
+int a_input(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -44,7 +44,7 @@ int a_input(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return
*/
-int a_once(curve_t *curve, config_t *config, arg_t *args);
+int a_once(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -55,7 +55,7 @@ int a_once(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int a_zero(curve_t *curve, config_t *config, arg_t *args);
+int a_zero(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -66,7 +66,7 @@ int a_zero(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int a_one(curve_t *curve, config_t *config, arg_t *args);
+int a_one(curve_t *curve, config_t *cfg, arg_t *args);
/**
* @brief
@@ -75,7 +75,7 @@ int a_one(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return
*/
-int a_seed(curve_t *curve, config_t *config, arg_t *args);
+int a_seed(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -87,7 +87,7 @@ int a_seed(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int b_random(curve_t *curve, config_t *config, arg_t *args);
+int b_random(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -98,7 +98,7 @@ int b_random(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int b_input(curve_t *curve, config_t *config, arg_t *args);
+int b_input(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -109,7 +109,7 @@ int b_input(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return
*/
-int b_once(curve_t *curve, config_t *config, arg_t *args);
+int b_once(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -120,7 +120,7 @@ int b_once(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int b_zero(curve_t *curve, config_t *config, arg_t *args);
+int b_zero(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -131,7 +131,7 @@ int b_zero(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int b_one(curve_t *curve, config_t *config, arg_t *args);
+int b_one(curve_t *curve, config_t *cfg, arg_t *args);
/**
* @brief
@@ -140,7 +140,7 @@ int b_one(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return
*/
-int b_seed(curve_t *curve, config_t *config, arg_t *args);
+int b_seed(curve_t *curve, config_t *cfg, arg_t *args);
/**
*
diff --git a/src/math/field.c b/src/math/field.c
index 2d6d358..08172bf 100644
--- a/src/math/field.c
+++ b/src/math/field.c
@@ -19,24 +19,24 @@ GEN field_binaryr(long bits) {
}
}
-int field_random(curve_t *curve, config_t *config, arg_t *args) {
- switch (config->field) {
+int field_random(curve_t *curve, config_t *cfg, arg_t *args) {
+ switch (cfg->field) {
case FIELD_PRIME:
- curve->field = field_primer(config->bits);
+ curve->field = field_primer(cfg->bits);
return 1;
case FIELD_BINARY:
- curve->field = field_binaryr(config->bits);
+ curve->field = field_binaryr(cfg->bits);
return 1;
default:
return INT_MIN; /* NOT REACHABLE */
}
}
-int field_input(curve_t *curve, config_t *config, arg_t *args) {
+int field_input(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
- switch (config->field) {
+ switch (cfg->field) {
case FIELD_PRIME: {
- GEN p = input_prime("p:", config->bits);
+ GEN p = input_prime("p:", cfg->bits);
if (equalii(p, gen_m1)) {
avma = ltop;
return 0;
@@ -67,8 +67,8 @@ int field_input(curve_t *curve, config_t *config, arg_t *args) {
return 0;
}
- GEN v = gtovec0(gen_0, config->bits + 1);
- gel(v, config->bits + 1) = gen_1;
+ GEN v = gtovec0(gen_0, cfg->bits + 1);
+ gel(v, cfg->bits + 1) = gen_1;
if (gsigne(e1) == 1) gel(v, itos(e1) + 1) = gen_1;
if (gsigne(e2) == 1) gel(v, itos(e2) + 1) = gen_1;
if (gsigne(e3) == 1) gel(v, itos(e3) + 1) = gen_1;
diff --git a/src/math/field.h b/src/math/field.h
index 0491a83..3ed300c 100644
--- a/src/math/field.h
+++ b/src/math/field.h
@@ -21,7 +21,7 @@
* @param args unused
* @return state diff
*/
-int field_random(curve_t *curve, config_t *config, arg_t *args);
+int field_random(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -34,7 +34,7 @@ int field_random(curve_t *curve, config_t *config, arg_t *args);
* @param args unused
* @return state diff
*/
-int field_input(curve_t *curve, config_t *config, arg_t *args);
+int field_input(curve_t *curve, config_t *cfg, arg_t *args);
/**
*
diff --git a/src/math/gens.c b/src/math/gens.c
index 93106b7..e535c62 100644
--- a/src/math/gens.c
+++ b/src/math/gens.c
@@ -22,13 +22,13 @@ int gens_put(curve_t *curve, GEN generators, long len) {
return 1;
}
-int gens_any(curve_t *curve, config_t *config, arg_t *args) {
+int gens_any(curve_t *curve, config_t *cfg, arg_t *args) {
GEN generators = ellff_get_gens(curve->curve);
long len = glength(generators);
return gens_put(curve, generators, len);
}
-int gens_one(curve_t *curve, config_t *config, arg_t *args) {
+int gens_one(curve_t *curve, config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
GEN generators = ellff_get_gens(curve->curve);
long len = glength(generators);
diff --git a/src/math/gens.h b/src/math/gens.h
index a1ae34f..ba22358 100644
--- a/src/math/gens.h
+++ b/src/math/gens.h
@@ -18,7 +18,7 @@
* @param args
* @return
*/
-int gens_any(curve_t *curve, config_t *config, arg_t *args);
+int gens_any(curve_t *curve, config_t *cfg, arg_t *args);
/**
* @brief
@@ -27,6 +27,6 @@ int gens_any(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return
*/
-int gens_one(curve_t *curve, config_t *config, arg_t *args);
+int gens_one(curve_t *curve, config_t *cfg, arg_t *args);
#endif // ECGEN_GENS_H
diff --git a/src/math/order.c b/src/math/order.c
index 83d7e0d..8902524 100644
--- a/src/math/order.c
+++ b/src/math/order.c
@@ -11,7 +11,7 @@ int order_any(curve_t *curve, config_t *cfg, arg_t *args) {
int order_smallfact(curve_t *curve, config_t *cfg, arg_t *args) {
if (!args) {
- fprintf(stderr, "No args to an arged function. points_random");
+ fprintf(stderr, "No args to an arged function. order_smallfact");
return INT_MIN;
}
pari_ulong smallfact = *(pari_ulong *)args->args;
diff --git a/src/math/point.c b/src/math/point.c
index 6368c60..fb2235e 100644
--- a/src/math/point.c
+++ b/src/math/point.c
@@ -61,7 +61,7 @@ void points_free_deep(point_t ***points, size_t npoints) {
}
}
-int point_random(curve_t *curve, config_t *config, arg_t *args) {
+int point_random(curve_t *curve, config_t *cfg, arg_t *args) {
points_free_deep(&curve->points, curve->npoints);
point_t *p = point_new();
@@ -74,7 +74,7 @@ int point_random(curve_t *curve, config_t *config, arg_t *args) {
return 1;
}
-int points_random(curve_t *curve, config_t *config, arg_t *args) {
+int points_random(curve_t *curve, config_t *cfg, arg_t *args) {
if (!args) {
fprintf(stderr, "No args to an arged function. points_random");
return INT_MIN;
@@ -110,7 +110,7 @@ int points_random(curve_t *curve, config_t *config, arg_t *args) {
}
*/
-int points_trial(curve_t *curve, config_t *config, arg_t *args) {
+int points_trial(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO stack code!!!
if (!args) {
fprintf(stderr, "No args to an arged function. points_trial");
@@ -149,7 +149,7 @@ int points_trial(curve_t *curve, config_t *config, arg_t *args) {
return 1;
}
-int points_prime(curve_t *curve, config_t *config, arg_t *args) {
+int points_prime(curve_t *curve, config_t *cfg, arg_t *args) {
// TODO stack code!!!
points_free_deep(&curve->points, curve->npoints);
diff --git a/src/math/point.h b/src/math/point.h
index 76f095a..4ced232 100644
--- a/src/math/point.h
+++ b/src/math/point.h
@@ -68,7 +68,7 @@ void points_free_deep(point_t ***points, size_t npoints);
* @param args unused
* @return state diff
*/
-int point_random(curve_t *curve, config_t *config, arg_t *args);
+int point_random(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -78,7 +78,7 @@ int point_random(curve_t *curve, config_t *config, arg_t *args);
* @param args size_t number of points to generate
* @return state diff
*/
-int points_random(curve_t *curve, config_t *config, arg_t *args);
+int points_random(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -96,7 +96,7 @@ int points_random(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int points_trial(curve_t *curve, config_t *config, arg_t *args);
+int points_trial(curve_t *curve, config_t *cfg, arg_t *args);
/**
* GENERATOR(gen_t)
@@ -110,6 +110,6 @@ int points_trial(curve_t *curve, config_t *config, arg_t *args);
* @param args
* @return state diff
*/
-int points_prime(curve_t *curve, config_t *config, arg_t *args);
+int points_prime(curve_t *curve, config_t *cfg, arg_t *args);
#endif // ECGEN_POINT_H
diff --git a/src/math/types.c b/src/math/types.c
index bf1bb5d..431c9c2 100644
--- a/src/math/types.c
+++ b/src/math/types.c
@@ -4,4 +4,4 @@
*/
#include "types.h"
-int gen_skip(curve_t *curve, config_t *config, arg_t *args) { return 1; }
+int gen_skip(curve_t *curve, config_t *cfg, arg_t *args) { return 1; }
diff --git a/src/math/types.h b/src/math/types.h
index 43ee7cf..38dadbe 100644
--- a/src/math/types.h
+++ b/src/math/types.h
@@ -58,6 +58,6 @@ typedef int (*gen_t)(curve_t *, config_t *, arg_t *);
* @param args
* @return
*/
-int gen_skip(curve_t *curve, config_t *config, arg_t *args);
+int gen_skip(curve_t *curve, config_t *cfg, arg_t *args);
#endif // ECGEN_TYPES_H