diff options
| author | J08nY | 2017-04-07 02:45:32 +0200 |
|---|---|---|
| committer | J08nY | 2017-04-07 02:45:32 +0200 |
| commit | 7f4596f2735d6011f7413edd7211b8673ecb4a14 (patch) | |
| tree | d2c745ee2bb615933a9efde7476ef258319609db /src/math/equation.c | |
| parent | 59b338cf8734f89c04042f217fcccf8509c3a197 (diff) | |
| download | ecgen-7f4596f2735d6011f7413edd7211b8673ecb4a14.tar.gz ecgen-7f4596f2735d6011f7413edd7211b8673ecb4a14.tar.zst ecgen-7f4596f2735d6011f7413edd7211b8673ecb4a14.zip | |
Fix binary field curve generation, move config into config.h
Diffstat (limited to 'src/math/equation.c')
| -rw-r--r-- | src/math/equation.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/math/equation.c b/src/math/equation.c index d676350..d60a8cd 100644 --- a/src/math/equation.c +++ b/src/math/equation.c @@ -3,7 +3,9 @@ * Copyright (C) 2017 J08nY */ #include "equation.h" +#include "io/cli.h" #include "io/input.h" +#include "math/field.h" int a_random(curve_t *curve, config_t *cfg, arg_t *args) { curve->a = genrand(curve->field); @@ -17,8 +19,12 @@ int a_input(curve_t *curve, config_t *cfg, arg_t *args) { avma = ltop; return 0; } - curve->a = inp; - // TODO change a to a field element here?. a t_INTMOD or a t_FFELT. + GEN elem = field_ielement(curve->field, inp); + if (!elem) { + avma = ltop; + return 0; + } + curve->a = elem; return 1; } @@ -68,8 +74,12 @@ int b_input(curve_t *curve, config_t *cfg, arg_t *args) { avma = ltop; return 0; } - curve->b = inp; - // TODO change b to a field element here?. a t_INTMOD or a t_FFELT. + GEN elem = field_ielement(curve->field, inp); + if (!elem) { + avma = ltop; + return 0; + } + curve->b = elem; return 1; } |
