aboutsummaryrefslogtreecommitdiff
path: root/src/math/equation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/equation.c')
-rw-r--r--src/math/equation.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/math/equation.c b/src/math/equation.c
new file mode 100644
index 0000000..571ee71
--- /dev/null
+++ b/src/math/equation.c
@@ -0,0 +1,58 @@
+/*
+ * ecgen, tool for generating Elliptic curve domain parameters
+ * Copyright (C) 2017 J08nY
+ */
+#include <io/input.h>
+#include "equation.h"
+
+int eq_random(curve_t *curve, config_t *config, ...) {
+ int r = a_random(curve, config) + b_random(curve, config);
+ if (r == 2) {
+ return r;
+ }
+ return -1;
+}
+
+int a_random(curve_t *curve, config_t *config, ...) {
+ curve->a = genrand(curve->field);
+ return 1;
+}
+
+int a_input(curve_t *curve, config_t *config, ...) {
+ curve->a = fread_int(in, "a: ", config->bits, '\n');
+ return 1;
+}
+
+int a_zero(curve_t *curve, config_t *config, ...) {
+ curve->a = gen_0;
+ return 1;
+}
+
+int a_one(curve_t *curve, config_t *config, ...) {
+ curve->a = gen_1;
+ return 1;
+}
+
+int a_seed(curve_t *curve, config_t *config, ...) {}
+
+int b_random(curve_t *curve, config_t *config, ...) {
+ curve->b = genrand(curve->field);
+ return 1;
+}
+
+int b_input(curve_t *curve, config_t *config, ...) {
+ curve->b = fread_int(in, "a: ", config->bits, '\n');
+ return 1;
+}
+
+int b_zero(curve_t *curve, config_t *config, ...) {
+ curve->b = gen_0;
+ return 1;
+}
+
+int b_one(curve_t *curve, config_t *config, ...) {
+ curve->b = gen_1;
+ return 1;
+}
+
+int b_seed(curve_t *curve, config_t *config, ...) {}