aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorJ08nY2017-05-29 01:51:42 +0200
committerJ08nY2017-05-29 01:51:42 +0200
commitc56560f774b84102ada614047f343ce8ed443bd7 (patch)
tree6a74a35259d3a20e04565f8b97fd07c332730f25 /src/math
parent3112a2c0579790a0d6e541734594300f36a6bb4a (diff)
downloadecgen-c56560f774b84102ada614047f343ce8ed443bd7.tar.gz
ecgen-c56560f774b84102ada614047f343ce8ed443bd7.tar.zst
ecgen-c56560f774b84102ada614047f343ce8ed443bd7.zip
Add order_gen_input, for reading pregenerated curve order
Diffstat (limited to 'src/math')
-rw-r--r--src/math/order.c14
-rw-r--r--src/math/order.h11
2 files changed, 25 insertions, 0 deletions
diff --git a/src/math/order.c b/src/math/order.c
index 347015c..2c963f6 100644
--- a/src/math/order.c
+++ b/src/math/order.c
@@ -3,6 +3,7 @@
* Copyright (C) 2017 J08nY
*/
#include "order.h"
+#include "io/input.h"
GEN order_factors(curve_t *curve, const config_t *cfg) {
if (cfg->prime) {
@@ -37,6 +38,19 @@ GEN order_groups(curve_t *curve, const config_t *cfg, GEN factors) {
}
}
+GENERATOR(order_gen_input) {
+ pari_sp ltop = avma;
+ GEN ord = input_int("order", cfg->bits);
+ if (gequalm1(ord)) {
+ avma = ltop;
+ return -4;
+ } else {
+ curve->order = ord;
+ obj_insert_shallow(curve->curve, 1, ord);
+ return 1;
+ }
+}
+
GENERATOR(order_gen_any) {
GEN ord = ellff_get_card(curve->curve);
if (isclone(ord)) {
diff --git a/src/math/order.h b/src/math/order.h
index ce3cd0b..6d1ed1f 100644
--- a/src/math/order.h
+++ b/src/math/order.h
@@ -29,6 +29,17 @@ GEN order_groups(curve_t *curve, const config_t *cfg, GEN factors);
/**
* GENERATOR(gen_t)
+ * Reads the curve order from input, does not verify it.
+ *
+ * @param curve
+ * @param cfg
+ * @param args
+ * @return state diff
+ */
+GENERATOR(order_gen_input);
+
+/**
+ * GENERATOR(gen_t)
* Calculates the curve order, using a general algorithm.
* Always succeeds.
*