diff options
| author | J08nY | 2018-07-09 21:22:53 +0200 |
|---|---|---|
| committer | J08nY | 2018-07-09 21:22:53 +0200 |
| commit | 1be7218990f93c442fa71a073ab16e862092b205 (patch) | |
| tree | 641c2aaa240cd9df5c19f32807ac38036471e127 /src/cm/supersingular.c | |
| parent | 0c97ff4a611c19efbd383f1a5ad63f3d26d3c627 (diff) | |
| download | ecgen-1be7218990f93c442fa71a073ab16e862092b205.tar.gz ecgen-1be7218990f93c442fa71a073ab16e862092b205.tar.zst ecgen-1be7218990f93c442fa71a073ab16e862092b205.zip | |
Use exhaustive generation of some params in CM generation.
Diffstat (limited to 'src/cm/supersingular.c')
| -rw-r--r-- | src/cm/supersingular.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cm/supersingular.c b/src/cm/supersingular.c new file mode 100644 index 0000000..a3cebfc --- /dev/null +++ b/src/cm/supersingular.c @@ -0,0 +1,45 @@ +/* + * ecgen, tool for generating Elliptic curve domain parameters + * Copyright (C) 2017-2018 J08nY + */ +#include "supersingular.h" + +GENERATOR(supersingular_gen_equation) { + if (equalis(curve->field, 2)) { + return -2; + } + if (mod4(curve->field) == 3) { + curve->a = mkintmod(subis(curve->field, 1), curve->field); + curve->b = mkintmod(stoi(0), curve->field); + return 1; + } + GEN q = stoi(3); + while (!(mod4(q) == 3 && kronecker(curve->field, q) == -1)) { + q = nextprime(addis(q, 1)); + } + + if (equalis(q, 3)) { + curve->a = mkintmod(stoi(0), curve->field); + curve->b = mkintmod(stoi(1), curve->field); + return 1; + } else { + GEN H = polclass(negi(q), 0, 0); + GEN r = FpX_roots(H, curve->field); + GEN root = gel(r, 1); + curve->a = mkintmod( + Fp_div(Fp_mul(stoi(27), root, curve->field), + Fp_mul(stoi(4), Fp_sub(stoi(1728), root, curve->field), + curve->field), + curve->field), + curve->field); + curve->b = gneg(curve->a); + return 1; + } +} + +GENERATOR(supersingular_gen_order) { + // copy field to order + curve->order = addis(curve->field, 1); + obj_insert(curve->curve, 1, curve->order); + return 1; +} |
