aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math/twists.c11
-rw-r--r--src/math/twists.h4
2 files changed, 12 insertions, 3 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
diff --git a/src/math/twists.h b/src/math/twists.h
index dcbdb31..d68bb27 100644
--- a/src/math/twists.h
+++ b/src/math/twists.h
@@ -15,8 +15,8 @@
void twist_rand_to(curve_t *to, const curve_t *of);
/**
- * @brief
- * @param what
+ * @brief Twists the <code>what</code> curve randomly, inplae.
+ * @param what The curve to be twisted, also the result.
*/
void twist_rand(curve_t *what);