aboutsummaryrefslogtreecommitdiff
path: root/src/math/twists.c
diff options
context:
space:
mode:
authorJ08nY2018-01-19 23:34:17 +0100
committerJ08nY2018-01-19 23:34:17 +0100
commitcfdddb2a57ad77f485eb4be1a52efe5ffe19a220 (patch)
tree896cb662429b87781b97b49ea88bf3004bd77d61 /src/math/twists.c
parentcde38f8c4ed443af6d0074e3e5294029246c2774 (diff)
downloadecgen-cfdddb2a57ad77f485eb4be1a52efe5ffe19a220.tar.gz
ecgen-cfdddb2a57ad77f485eb4be1a52efe5ffe19a220.tar.zst
ecgen-cfdddb2a57ad77f485eb4be1a52efe5ffe19a220.zip
Diffstat (limited to 'src/math/twists.c')
-rw-r--r--src/math/twists.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/math/twists.c b/src/math/twists.c
index 3f1296d..043594f 100644
--- a/src/math/twists.c
+++ b/src/math/twists.c
@@ -13,16 +13,25 @@ void twist_rand_to(curve_t *to, const curve_t *of) {
if (typ(of->field) == t_INT) {
to->a = ell_get_a4(to->curve);
to->b = ell_get_a6(to->curve);
+ if (of->order != NULL) {
+ GEN q = addis(mulis(of->field, 2), 2);
+ to->order = subii(q, of->order);
+ obj_insert_shallow(to->curve, 1, to->order);
+ }
} else if (typ(of->field) == t_FFELT) {
to->a = ell_get_a2(to->curve);
to->b = ell_get_a6(to->curve);
+ if (of->order != NULL) {
+ GEN q = addis(mulis(int2n(degree(FF_mod(of->field))), 2), 2);
+ to->order = subii(q, of->order);
+ obj_insert_shallow(to->curve, 1, to->order);
+ }
}
}
void twist_rand(curve_t *what) {
twist_rand_to(what, what);
seed_free(&what->seed);
- what->order = NULL;
points_free_deep(&what->points, what->npoints);
points_free_deep(&what->generators, what->ngens);
} \ No newline at end of file