diff options
| author | J08nY | 2018-07-02 17:51:20 +0200 |
|---|---|---|
| committer | J08nY | 2018-07-02 17:51:20 +0200 |
| commit | f2b30a0bdbc46c3c7651ea0efb657d99a7369447 (patch) | |
| tree | 916674d706f29a581710e29bf15b9c024752e0b5 /src | |
| parent | d46c72438faa02a905b1f14d218ee5bb42b6e28a (diff) | |
| download | ecgen-f2b30a0bdbc46c3c7651ea0efb657d99a7369447.tar.gz ecgen-f2b30a0bdbc46c3c7651ea0efb657d99a7369447.tar.zst ecgen-f2b30a0bdbc46c3c7651ea0efb657d99a7369447.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/gen/point.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gen/point.c b/src/gen/point.c index 98422db..7d3ba90 100644 --- a/src/gen/point.c +++ b/src/gen/point.c @@ -3,6 +3,7 @@ * Copyright (C) 2017-2018 J08nY */ #include "point.h" +#include <obj/obj.h> #include "exhaustive/arg.h" #include "math/subgroup.h" #include "obj/point.h" @@ -44,11 +45,17 @@ GENERATOR(points_gen_random) { subgroup->points = points_new(npoints_per_gen[i]); for (size_t j = 0; j < npoints_per_gen[i]; ++j) { - GEN mul = random_range(gen_0, subgroup->generator->order); - GEN p = ellmul(curve->curve, subgroup->generator->point, mul); point_t *point = point_new(); - point->point = p; - point->order = ellorder(curve->curve, p, NULL); + // Handle the special case of subgroup of order 2. + if (equalis(subgroup->generator->order, 2)) { + point->point = gcopy(subgroup->generator->point); + point->order = stoi(2); + } else { + GEN mul = random_range(gen_1, subgroup->generator->order); + GEN p = ellmul(curve->curve, subgroup->generator->point, mul); + point->point = p; + point->order = ellorder(curve->curve, p, NULL); + } subgroup->points[j] = point; } } |
