27 #include "mphell/mphell.h"
51 number_set_str(p,
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff", 16);
52 #if MPHELL_USE_AMNS == 1
54 #if MPHELL_USE_AMNS_32 == 0
55 amns_alloc_init_str(&AMNS,
"[0, 7, [-2, 0, 0, 0, 0, 0, 0, 1], 59, 8010427042960414838884725536003025378504357914088932113335334539926383793809451548018236227209625700052722361381087, [-8576931003528147, 12963241998501462, -11685779024318585, 12198217901242760, 5469056521909520, -16952339206744690, -7801587214757611], [936600828956320511, 17864700281010200544, 7457034104920941375, 4906978974859566336, 1521310033682434027, 11977106235113612084, 6613199331606154624], [-48661600919137196, -16406260014740521, -9043881017757559, -15840327204754192, -4503903233538141, -10931797952018020, 3933578076642458], [-10700965224081570, -31747207631521220, -21134995866173053, -3985617456248275, -932744058138743, -25427794319760237, -2489368063126092]]", p);
57 amns_alloc_init_str(&AMNS,
"[0, 18, [-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 26, 28816340648335589686749390875939188706868735452517709312097740458242732054770156839198296353641579295263032233716200, [-51353, 1463368, 1158979, 544183, -726450, 976213, 144497, -886193, -264198, 688818, 1070182, -170086, 864472, -144241, -360825, -510521, 1017098, -59072], [3993315613, 3730700630, 867896355, 1312786307, 471958917, 4205419201, 2925107995, 1257333470, 1009072108, 3882493844, 334530385, 923966745, 2062755457, 1054721524, 1062123069, 2491481070, 813468425, 1351925765], [1499105, 1805368, 3513276, 2380622, 4551927, 3187369, 3810913, 2129326, 3493684, 1909307, 1981401, 2013148, 1633911, 2996996, 2975679, 3661385, 2455278, 1909836], [5854047, 6627253, 2246346, 3861327, 2251173, 2334257, 1163302, 3551220, 4498564, 4312125, 4221299, 3184071, 2952719, 307544, 1633107, 2468475, 2132615, 2940733]]", p);
59 field_set_amns(k, AMNS);
81 field_elt_set_str(a,
"a3aeb56058fa59051926a1559fe934bf64545ee7dee231a8d65e7211702ac9bf9801cfdae54ad7a050e20e612d4c080", 16,
false, k, STACK_1);
83 ec_point_set_str(G,
"1541e4e6fec9431b561ad9d815306961cbda834477c2884b93bb5fb3a4c865d1638d6b1e1eb5d91afea443da57ec3c95",
"e55245714090febf2f55c3dee76267c5aa27edb22a95ffa0328adecc2690ffef38c5cb63423401492f8e75bd4753f0b6",
"1",
"a7c8a5c9364fb8f2142801d10e8321c885c9fe7b88a7c76eabc474f635b090ac8001e9efcfc308ff06960a29869ebf8",
false, 16, k, STACK_1);
84 number_set_str(h,
"15ad3c423d6df1572016199efaeee94ca5242a87a4", 16);
85 number_set_str(n,
"bcf569c46c00fa8b5f4c7d41b55e14295468dac4097918b25e24499", 16);
97 ec_create (E_jq,
"RandP384JQ", k, a, b, G, h, n,
JACOBI_QUARTIC,
PROJECTIVE, STACK_1);
99 printf(
"The Jacobi Quartic departing curve \nE_jq: \n");
ec_curve_print(E_jq, 16, STACK_1); printf(
"\n");
104 printf(
"random point, res_jq = ");
ec_point_print(res_jq, 16,
true, k, STACK_1); printf(
"\n");
111 printf(
"The Weierstrass curve isomorphic to E_jq \n");
118 printf(
"Weierstrass random point, res = ");
ec_point_print(res, 16,
true, k, STACK_1); printf(
"\n");
131 #if MPHELL_USE_AMNS == 1
void amns_free(amns_ptr *AMNS)
Free the amns system.
void amns_alloc_init_str(amns_ptr *AMNS, char *str, number p)
Allocate and initialise the amns system from the string generated by the Sage AMNS generator from htt...
void jacobi_quartic_point_to_weierstrass_point(ec_point_ptr dst, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Convert a point on a jacobi quartic elliptic curve to a point on a weierstrass elliptic curve.
void ec_curve_print(ec_curve_srcptr E, const uint8_t base, uint8_t stack)
Print a description of E.
void jacobi_quartic_to_weierstrass(ec_curve_ptr E_res, ec_curve_srcptr E, uint8_t stack)
Convert a jacobi quartic elliptic curve into a Weierstrass elliptic curve.
void ec_point_print(ec_point_srcptr P, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack)
Print a description of P.
void ec_create(ec_curve_ptr E, const char *id_curve, field_srcptr k, fe_srcptr a, fe_srcptr b, ec_point_srcptr G, number_srcptr h, number_srcptr n, const ec_type type, const ec_formula f, uint8_t stack)
Create an elliptic curve E, the curve must be allocated and initialised (ec_alloc & ec_init)
void ec_point_set_str(ec_point_ptr P, const char *str_x, const char *str_y, const char *str_z, const char *str_t, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack)
Set a point from its coordinates under string format.
void ec_free(ec_curve_ptr E)
Free the elliptic curve E.
void ec_init(ec_curve_ptr E, field_srcptr k)
Initialise a curve.
void ec_point_init(ec_point_ptr P, field_srcptr k)
Initialise an elliptic curve point.
void ec_point_free(ec_point_ptr P, field_srcptr k)
Free the point P.
void ec_point_alloc(ec_point_ptr P, field_srcptr k)
Allocate an elliptic curve point.
void ec_alloc(ec_curve_ptr E, field_srcptr k)
Allocate a curve.
void field_elt_free(fe_ptr *src, field_srcptr k)
Free space used by src.
void field_alloc(field_ptr k, const field_type type, const uint8_t size, field_ptr base)
Allocates space for the different fields of the structure pointed by k.
void field_elt_set_str(fe_ptr dst, const char *str, const uint8_t base, const bool isreduced, field_srcptr k, uint8_t stack)
Set dst to str, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void field_elt_init(fe_ptr dst, field_srcptr k)
Initialise the field element.
void field_elt_alloc(fe_ptr *dst, field_srcptr k)
Allocate space for a field element.
void field_free(field_ptr k)
Free the space of the field informations structure.
void field_create(field_ptr k, const char *id, uint8_t stack, const uint32_t n,...)
Initialize the different fields of the structure pointed by k.
field_t field[1]
Address of a field structure.
fp_elt * field_elt
Generic field element.
void free_mphell()
Free MPHELL memory, especially the big amount of temporary memory.
void init_mphell(const uint16_t security_strength, const random_type type, const entropy_type entropy)
Initialise MPHELL with security_strength bits of security (for random number only).
bool jacobi_quartic_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
void jacobi_quartic_point_random(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Create a random point P on the elliptic curve E.
void number_free(number *dst)
Free a number_ptr allocated on the RAM memory (malloc)
void number_set_str(number_ptr dst, const char *str, const uint8_t base)
Set dst to str.
void number_init(number *dst, const uint8_t n)
Allocate a number_ptr on the RAM memory (malloc)
uint8_t bits_to_nblock(const uint16_t nbits)
Return the number of blocks required to store a nbits number.
bool weierstrass_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
Define an elliptic curve.
Define an elliptic curve point.