aboutsummaryrefslogtreecommitdiff
path: root/src/math/equation.c
diff options
context:
space:
mode:
authorJ08nY2017-02-09 04:07:37 +0100
committerJ08nY2017-02-09 04:07:37 +0100
commit79b29481b1c4d13063dd8b6ee6a1d0d70a54faab (patch)
tree007da84bc4133c656f2f66df541f74c6b55bfb11 /src/math/equation.c
parent0b5d1cca9c78869c6cffa2932297c1d70ba142e2 (diff)
downloadecgen-79b29481b1c4d13063dd8b6ee6a1d0d70a54faab.tar.gz
ecgen-79b29481b1c4d13063dd8b6ee6a1d0d70a54faab.tar.zst
ecgen-79b29481b1c4d13063dd8b6ee6a1d0d70a54faab.zip
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, ...) {}