48 E->
id_curve=malloc(100*
sizeof(
char));
101 if((id_curve != NULL) && (id_curve[0] !=
'\0'))
122 number_set_str(tmp,
"fffffffffffffffffffffffffffffffeffffffffffffffff", 16);
134 ec_point_set_aff_str(E->
G,
"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
"07192b95ffc8da78631011ed6b24cdd573f977a11e794811",
false, 16,
WEIERSTRASS, k, stack);
135 number_set_str(E->
n,
"ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16);
136 number_set_str(E->
h,
"000000000000000000000000000000000000000000000001", 16);
147 number_set_str(tmp,
"ffffffffffffffffffffffffffffffff000000000000000000000001", 16);
159 ec_point_set_aff_str(E->
G,
"b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
"bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34",
false, 16,
WEIERSTRASS, k, stack);
160 number_set_str(E->
n,
"ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d", 16);
161 number_set_str(E->
h,
"00000000000000000000000000000000000000000000000000000001", 16);
172 number_set_str(tmp,
"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", 16);
182 field_elt_set_str(E->a,
"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", 16,
false, (
field_t*)k, stack);
183 field_elt_set_str(E->
b,
"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16,
false, (
field_t*)k, stack);
184 ec_point_set_aff_str(E->
G,
"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5",
false, 16,
WEIERSTRASS, k, stack);
185 number_set_str(E->
n,
"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 16);
186 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000001", 16);
197 number_set_str(tmp,
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff", 16);
207 field_elt_set_str(E->a,
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc", 16,
false, (
field_t*)k, stack);
208 field_elt_set_str(E->
b,
"b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef", 16,
false, (
field_t*)k, stack);
209 ec_point_set_aff_str(E->
G,
"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760aB7",
"3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5F",
false, 16,
WEIERSTRASS, k, stack);
210 number_set_str(E->
n,
"ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973", 16);
211 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 16);
222 number_set_str(tmp,
"000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16);
232 field_elt_set_str(E->a,
"000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc", 16,
false, (
field_t*)k, stack);
233 field_elt_set_str(E->
b,
"00000051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", 16,
false, (
field_t*)k, stack);
234 ec_point_set_aff_str(E->
G,
"000000c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66",
"0000011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",
false, 16,
WEIERSTRASS, k, stack);
235 number_set_str(E->
n,
"000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409", 16);
236 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 16);
247 number_set_str(tmp,
"E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16);
264 strcpy(E->
id_curve,
"brainpool_p160r1");
272 number_set_str(tmp,
"C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16);
284 ec_point_set_aff_str(E->
G,
"C0A0647EAAB6A48753B033C56CB0F0900A2F5C4853375FD6",
"14B690866ABD5BB88B5F4828C1490002E6773FA2FA299B8F",
false, 16,
WEIERSTRASS, k, stack);
285 number_set_str(E->
n,
"C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16);
286 number_set_str(E->
h,
"000000000000000000000000000000000000000000000001", 16);
289 strcpy(E->
id_curve,
"brainpool_p192r1");
297 number_set_str(tmp,
"D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16);
309 ec_point_set_aff_str(E->
G,
"D9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D",
"58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD",
false, 16,
WEIERSTRASS, k, stack);
310 number_set_str(E->
n,
"D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16);
311 number_set_str(E->
h,
"00000000000000000000000000000000000000000000000000000001", 16);
314 strcpy(E->
id_curve,
"brainpool_p224r1");
322 number_set_str(tmp,
"A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16);
332 field_elt_set_str(E->a,
"7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9", 16,
false, (
field_t*)k, stack);
333 field_elt_set_str(E->
b,
"26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6", 16,
false, (
field_t*)k, stack);
334 ec_point_set_aff_str(E->
G,
"8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262",
"547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997",
false, 16,
WEIERSTRASS, k, stack);
335 number_set_str(E->
n,
"A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7", 16);
336 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000001", 16);
339 strcpy(E->
id_curve,
"brainpool_p256r1");
347 number_set_str(tmp,
"D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27", 16);
357 field_elt_set_str(E->a,
"3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F492F375A97D860EB4", 16,
false, (
field_t*)k, stack);
358 field_elt_set_str(E->
b,
"520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD884539816F5EB4AC8FB1F1A6", 16,
false, (
field_t*)k, stack);
359 ec_point_set_aff_str(E->
G,
"43BD7E9AFB53D8B85289BCC48EE5BFE6F20137D10A087EB6E7871E2A10A599C710AF8D0D39E20611",
"14FDD05545EC1CC8AB4093247F77275E0743FFED117182EAA9C77877AAAC6AC7D35245D1692E8EE1",
false, 16,
WEIERSTRASS, k, stack);
360 number_set_str(E->
n,
"D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311", 16);
361 number_set_str(E->
h,
"00000000000000000000000000000000000000000000000000000000000000000000000000000001", 16);
364 strcpy(E->
id_curve,
"brainpool_p320r1");
372 number_set_str(tmp,
"8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53", 16);
382 field_elt_set_str(E->a,
"7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503AD4EB04A8C7DD22CE2826", 16,
false, (
field_t*)k, stack);
383 field_elt_set_str(E->
b,
"4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DBC9943AB78696FA504C11", 16,
false, (
field_t*)k, stack);
384 ec_point_set_aff_str(E->
G,
"1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D646AAEF87B2E247D4AF1E",
"8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E4646217791811142820341263C5315",
false, 16,
WEIERSTRASS, k, stack);
385 number_set_str(E->
n,
"8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565", 16);
386 number_set_str(E->
h,
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 16);
389 strcpy(E->
id_curve,
"brainpool_p384r1");
397 number_set_str(tmp,
"AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3", 16);
407 field_elt_set_str(E->a,
"7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA", 16,
false, (
field_t*)k, stack);
408 field_elt_set_str(E->
b,
"3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723", 16,
false, (
field_t*)k, stack);
409 ec_point_set_aff_str(E->
G,
"81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822",
"7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892",
false, 16,
WEIERSTRASS, k, stack);
410 number_set_str(E->
n,
"AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069", 16);
411 number_set_str(E->
h,
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 16);
414 strcpy(E->
id_curve,
"brainpool_p512r1");
422 number_set_str(tmp,
"F1FD178C0B3AD58F10126DE8CE42435B3961ADBCABC8CA6DE8FCF353D86E9C03", 16);
432 field_elt_set_str(E->a,
"F1FD178C0B3AD58F10126DE8CE42435B3961ADBCABC8CA6DE8FCF353D86E9C00", 16,
false, (
field_t*)k, stack);
433 field_elt_set_str(E->
b,
"EE353FCA5428A9300D4ABA754A44C00FDFEC0C9AE4B1A1803075ED967B7BB73F", 16,
false, (
field_t*)k, stack);
434 ec_point_set_aff_str(E->
G,
"B6B3D4C356C139EB31183D4749D423958C27D2DCAF98B70164C97A2DD98F5CFF",
"6142E0F7C8B204911F9271F0F3ECEF8C2701C307E8E4C9E183115A1554062CFB",
false, 16,
WEIERSTRASS, k, stack);
435 number_set_str(E->
n,
"F1FD178C0B3AD58F10126DE8CE42435B53DC67E140D2BF941FFDD459C6D655E1", 16);
436 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000001", 16);
447 number_set_str(tmp,
"b09f075797da89f57ec8c0265b014c5ba37bcb84208a4c4d83199a31d17cb1af", 16);
457 field_elt_set_str(E->a,
"1468727718e87fae1d94287a36205fa0e3b70bbaad31a097c1ffa5a5db263683", 16,
false, (
field_t*)k, stack);
458 ec_point_set_str(E->
G,
"7e99fa90a889802939e8704d3cc8abc5c0c879540dea85075eabfb6c73d515c5",
"5d5db0901ca66a952304e220fcf6581c55fb7fb7986522096911c09d1e76de9b",
"86eccefd9aa9174b1e61505ba174452525f7fd2989304574b298978e79690c20",
"77d5d37af2ee21e362a68ec5e277b40538434a020c6d1a3c885b6eb8fec53dd3",
false, 16, k, stack);
459 number_set_str(E->
n,
"2c27c1d5e5f6a27d5fb2300996c0531746f66dec9a2e0bd13eabeafa863611f7", 16);
460 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000004", 16);
471 number_set_str(tmp,
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed", 16);
481 field_elt_set_str(E->a,
"0000000000000000000000000000000000000000000000000000000000000001", 16,
false, (
field_t*)k, stack);
482 field_elt_set_str(E->
b,
"2dfc9311d490018c7338bf8688861767ff8ff5b2bebe27548a14b235eca6874a", 16,
false, (
field_t*)k, stack);
483 ec_point_set_aff_str(E->
G,
"159a6849e44c3c7f061b3d570fc4ed5b5d14c8ba4253df49cc7edf80f533ad9b",
"6666666666666666666666666666666666666666666666666666666666666658",
false, 16,
EDWARDS, k, stack);
484 number_set_str(E->
n,
"1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed", 16);
485 number_set_str(E->
h,
"0000000000000000000000000000000000000000000000000000000000000008", 16);
505 ec_create(E, id_curve, k, a, b, NULL, NULL, NULL, type, f, stack);
511 ec_create(E, id_curve, k, a, b, NULL, NULL, NULL, type, f, stack);
516 ec_create(E, id_curve, k, a, b, NULL, NULL, NULL, type, f, stack);
729 const char *str_z,
const char *str_t,
const bool is_reduced,
760 const bool is_reduced,
const uint8_t base,
const ec_type type,
915 *str = (
char*)malloc(strlen(
"JACOBI QUARTIC") + 1);
916 strcpy(*str,
"JACOBI QUARTIC");
920 *str = (
char*)malloc(strlen(
"EDWARDS") + 1);
921 strcpy(*str,
"EDWARDS");
925 *str = (
char*)malloc(strlen(
"WEIERSTRASS") + 1);
926 strcpy(*str,
"WEIERSTRASS");
936 char *a_str, *b_str, *G_str, *h_str, *n_str, *k_str, *type_str, *disc_str, *D_str;
957 *str = (
char*)malloc(strlen(a_str) + strlen(k_str) +
958 strlen(h_str) + strlen(n_str) + strlen(G_str) +
959 strlen(type_str) + strlen(disc_str) + 100);
961 sprintf(*str,
"id:%s\ntype:%s\nK:%s\nA:%s\nG:%s\nh:%s\nn:%s\ndisc:%s\n",
962 E->
id_curve, type_str, k_str, a_str, G_str, h_str, n_str, disc_str);
984 *str = (
char*)malloc(strlen(a_str) + strlen(b_str) + strlen(k_str) +
985 strlen(h_str) + strlen(n_str) + strlen(G_str) +
986 strlen(type_str) + strlen(disc_str) + 100);
988 sprintf(*str,
"id:%s\ntype:%s\nK:%s\nA:%s\nD:%s\nG:%s\nh:%s\nn:%s\ndisc:%s\n",
989 E->
id_curve, type_str, k_str, a_str, b_str, G_str, h_str, n_str, disc_str);
1013 *str = (
char*)malloc(strlen(a_str) + strlen(b_str) + strlen(k_str) +
1014 strlen(n_str) + strlen(n_str) + strlen(G_str) + strlen(type_str) +
1015 strlen(D_str) + strlen(disc_str) + 100);
1017 sprintf(*str,
"id:%s\ntype:%s\nK:%s\nA:%s\nB:%s\nG:%s\nh:%s\nn:%s\ndisc:%s\nD:%s",
1018 E->
id_curve, type_str, k_str, a_str, b_str, G_str, h_str, n_str, disc_str,
1040 printf(
"%s\n", str);
1048 char *x_str, *y_str, *z_str, *t_str;
1054 *str = (
char*)malloc(strlen(x_str) + strlen(y_str) + strlen(z_str) +
1055 strlen(t_str) + 20);
1056 sprintf(*str,
"[%s,\n%s,\n%s,\n%s]", x_str, y_str, z_str, t_str);
1068 printf(
"%s\n", str);
1149 MPHELL_ASSERT(E->
f==
EXTENDED_EDWARDS,
"\nOnly Extended Edwards coordinates are supported \n");
1155 MPHELL_ASSERT(E->
f==
PROJECTIVE,
"\nOnly Projective coordinates are supported \n");
1172 MPHELL_ASSERT(E->
f==
EXTENDED_EDWARDS,
"\nOnly Extended Edwards coordinates are supported \n");
1178 MPHELL_ASSERT(E->
f==
PROJECTIVE,
"\nOnly Projective coordinates are supported \n");
1259 mphell_error(
"ec_point_mul_unified, the only available coordinate system is EXTENDED_EDWARDS for unified multiplication over Edwards curves \n");
1277 mphell_error(
"ec_point_mul_unified, the only available coordinates are PROJECTIVE and JACOBIAN\n");
1283 mphell_error(
"ec_point_mul_unified, the only available curves are WEIERSTRASS, JACOBI_QUARTIC and EDWARDS\n");
1400 MPHELL_ASSERT(str[beg]==
'1',
"Sliding window error, str[beg]!=1\n");
1401 MPHELL_ASSERT(str[end]==
'1',
"Sliding window error, str[end]!=1\n");
1405 for (i = end-1; i >= beg; i--)
1409 res+=((uint16_t)1<<j);
1431 for (i = end; i >= beg; i--)
1435 res+=((uint16_t)1<<j);
1500 for(i = 0; i <= pr; i++)
1508 for(i = 1; i <= pr; i++)
1531 while(n_str[s]==
'0')
1537 for(h=1; h<=s-i+1; h++)
1551 for(i = 0; i <= pr; i++)
1564 int16_t e = win_size;
1589 while(n_str[s]==
'0')
1595 for(h=1; h<=s-i+1; h++)
1612 number_srcptr n2,
ec_point * tab_P2,
1617 int16_t i, s, h, l, i1, i2, a, b;
1618 int16_t e = win_size;
1639 if (n1_str[i1]==
'0')
1651 while(n1_str[s]==
'0')
1657 for(h=1; h<=s-i1+1; h++)
1677 if (n2_str[i2]==
'0')
1689 while(n2_str[s]==
'0')
1695 for(h=1; h<=s-i2+1; h++)
1716 if ((n1_str[i+i1]==
'0') && (n2_str[i+i2]==
'0'))
1728 while((n1_str[s+i1]==
'0') && (n2_str[s+i2]==
'0'))
1734 for(h=1; h<=s-i+1; h++)
1802 mphell_error(
"ec_point_mul, the only available coordinates are PROJECTIVE and JACOBIAN\n");
1808 mphell_error(
"ec_point_mul, the only available curves are WEIERSTRASS, JACOBI_QUARTIC and EDWARDS\n");
1930 mphell_error(
"ERROR: jacobi_quartic_to_weierstrass\n");
1940 strcpy(E_res->
id_curve,
"no_name");
2117 mphell_error(
"ERROR: weierstrass_to_jacobi_quartic\n");
2127 strcpy(E_res->
id_curve,
"no_name");
2232 strcpy(E_res->
id_curve,
"no_name");
2351 MPHELL_ASSERT(
field_elt_issquare(e, k, stack),
"This curve do not seem to be isomorphic to an edwards curve \n We do not have 3*alpha^2 + a = beta^2 \n");
2377 MPHELL_ASSERT(
field_elt_issquare(e, k, stack),
"This curve do not seem to be isomorphic to an edwards curve \n We do not have 3*alpha^2 + a = beta^2 \n");
2411 strcpy(E_res->
id_curve,
"no_name");
2463 MPHELL_ASSERT(
field_elt_issquare(e, k, stack),
"This curve do not seem to be isomorphic to an edwards curve \n We do not have 3*alpha^2 + a = beta^2 \n");
2484 MPHELL_ASSERT(
field_elt_issquare(e, k, stack),
"This curve do not seem to be isomorphic to an edwards curve \n We do not have 3*alpha^2 + a = beta^2 \n");
bool ec_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
bool edwards_verify_random_generation(ec_curve E, const char *seed, uint8_t stack)
Test if E if generated from the seed "seed".
void weierstrass_point_neg(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E)
Set P3 to -P1.
bool number_iszero(number_srcptr src)
Test if src is zero.
void ec_point_set(ec_point_ptr P, fe_srcptr x, fe_srcptr y, fe_srcptr z, fe_srcptr t, field_srcptr k)
Set a point from its coordinates.
bool weierstrass_verify_random_generation(ec_curve E, const char *seed, uint8_t stack)
Test if E if generated from the seed "seed".
fp_elt * field_elt
Generic field element.
void ec_random(ec_curve_ptr E, const char *id_curve, char *seed_res, field_srcptr k, const ec_type type, const ec_formula f, uint8_t stack)
Create a random elliptic curve E, not cryptographically secure (not tested to be)....
void ec_point_set_neutral(ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
Set dst to the neutral element.
bool edwards_point_is_neutral(ec_point_srcptr P, ec_curve_srcptr E)
Test if P is the neutral element.
static bool field_elt_iszero(fe_srcptr src, field_srcptr k)
Test if src is zero.
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 field_elt_free(fe_ptr *src, field_srcptr k)
Free space used by src.
static void field_elt_mul(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k, uint8_t stack)
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used ...
void ec_point_dbl_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to 2*P1, using unified formulae (protection against SPA)
void weierstrass_point_set_aff_str(ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack)
Set dest to the affine point (str_x,str_y)
void ec_type_str(char **str, const ec_type type)
Allocate *str and write in it the type of E.
void edwards_point_neg(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E)
Compute the opposite of a point of the the Edwards elliptic curve E.
uint16_t number_log2(number_srcptr src)
Calculate log2(src), which is the binary size of src.
void mphell_error(char *expr)
Write in stderr, filename, line and expr, free mphell.
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 edwards_point_random(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Set P to a random point on E.
void weierstrass_Zmontgomery_Kim(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Perform the Montgomery ladder, taken from Kim et al's 2017 work, compute P3=[n]P1 it has the drawback...
void edwards_point_add_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Compute the unified addition of 2 points P1 and P2 of the Edwards elliptic curve E,...
void number_to_bit_string(char *str, number_srcptr src)
Converts src (must be positive) to a bit string.
Define an elliptic curve point.
void weierstrass_to_edwards(ec_curve_ptr E_res, ec_curve_srcptr E, const uint8_t n, fe_ptr alpha, fe_ptr beta, uint8_t stack)
Convert the Weierstrass elliptic curve E to the one of the corresponding Edwards elliptic curve accor...
void ec_point_alloc(ec_point_ptr P, field_srcptr k)
Allocate an elliptic curve point.
static void field_elt_inc(fe_ptr dst, fe_srcptr src, field_srcptr k)
Set dst <- src + 1.
void edwards_to_weierstrass(ec_curve_ptr E_res, ec_curve_srcptr E, uint8_t stack)
Convert the Edwards elliptic curve E to the corresponding Weierstrass elliptic curve E_res.
void ec_point_neg(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E)
Set P3 to -P1.
void number_set_ui(number_ptr dst, const block src)
Set dst to src.
void ec_init(ec_curve_ptr E, field_srcptr k)
Initialise a curve.
void edwards_point_get_y_affine(field_elt y, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->y to its affine representation.
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 weierstrass_point_random(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Set P to a random point on E.
void jacobi_quartic_point_set_neutral(ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
Set dst to the neutral element: (0,1,0,1).
uint8_t bits_to_nblock(const uint16_t nbits)
Return the number of blocks required to store a nbits number.
void field_elt_sqrt(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
Set dst <- src^(1/2)
void field_elt_alloc(fe_ptr *dst, field_srcptr k)
Allocate space for a field element.
int16_t binary_to_indice(char *str, int16_t beg, int16_t end)
Compute the indice for the sliding window multiplication.
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 edwards_point_set_aff_str(ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack)
Set dest to the affine point twisted Edwards coordinates point (str_x,str_y,1,str_x str_y)
void ec_point_get_y_affine(field_elt y, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->y to its affine representation.
void weierstrass_compute_disc(ec_curve E, uint8_t stack)
Set the discriminant of E: disc = -16(4a^3 + 27b^2)
void ec_point_init(ec_point_ptr P, field_srcptr k)
Initialise an elliptic curve point.
void field_elt_div(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k, uint8_t stack)
Set dst <- src1 / src2.
void ec_point_add(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 + P2, using dedicated formulae (not protected against SPA, but faster)
void ec_compute_disc(ec_curve_ptr E, uint8_t stack)
Set the discriminant of E.
void jacobi_quartic_point_get_y_affine(field_elt y, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->y to its affine representation.
bool jacobi_quartic_point_are_equal(ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Test if P1 and P2 are equal on E.
bool field_elt_isone(fe_srcptr src, field_srcptr k)
Test if src is one.
void number_free(number *dst)
Free a number_ptr allocated on the RAM memory (malloc)
bool jacobi_quartic_point_is_neutral(ec_point_srcptr P, ec_curve_srcptr E)
Test if P is the neutral element.
void ec_use_curve(ec_curve_ptr E, field_ptr k, const ec_known_curve id_curve, const ec_formula f, uint8_t stack)
Create the elliptic curve (and the associated base field) id_curve, the curve and the field must me a...
void weierstrass_point_add_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 + P2, using unified formulae (protection against SPA)
void ec_point_free(ec_point_ptr P, field_srcptr k)
Free the point P.
void ec_point_str(char **str, ec_point_srcptr P, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack)
Allocate *str and write in it the description of P.
void ec_free(ec_curve_ptr E)
Free the elliptic curve E.
void weierstrass_point_set_neutral(ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
Set dst to the neutral element: (0,1,0) for projective coordinates and (1,1,0) for jacobian coordinat...
static void ec_point_relax_pool_elt(ec_point_ptr P, field_ptr k, uint8_t stack)
Relax an initialised point from the pool.
bool weierstrass_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
void weierstrass_point_get_x_affine(field_elt x, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->x to its affine representation.
void weierstrass_point_get_y_affine(field_elt y, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->y to its affine representation.
void field_elt_set_one(fe_ptr dst, field_srcptr k)
Set dst to one (or its Montgomery form if Montgomery arithmetic is used)
bool ec_point_is_neutral(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P is the neutral element.
Declaration of ECC functions.
void field_elt_copy(fe_ptr dst, fe_srcptr src, field_srcptr k)
Copy src into dst, src and dst must belong to the same field.
void weierstrass_point_set_aff(ec_point_ptr P, fe_srcptr x, fe_srcptr y, field_srcptr k)
Set dest to the affine point (x, y)
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.
void weierstrass_point_to_edwards_point(ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, const uint8_t n, fe_ptr alpha, fe_ptr beta, uint8_t stack)
Convert the point of the Weierstrass elliptic curve E to the elliptic curve of one of the correspondi...
bool weierstrass_point_is_neutral(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P is the neutral element.
void weierstrass_point_to_jacobi_quartic_point(ec_point_ptr dst, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Convert a point on a weierstrass elliptic curve to a point on a jacobi quartic elliptic curve.
void ec_point_set_aff_str(ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, const ec_type type, field_srcptr k, uint8_t stack)
Set a point from its affine coordinates under string format.
void field_get_size(number_ptr c, field_srcptr k)
Get the size of the field "k".
static void ec_point_get_pool_elt(ec_point_ptr P, field_ptr k, uint8_t stack)
Get an initialised point from the pool.
void weierstrass_point_of_order_2(ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
Set dst to one of the point of order 2 of the curve E assuming that at least one exist.
void ec_point_add_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 + P2, using unified formulae (protection against SPA)
void field_elt_str(char **str, fe_srcptr src, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack)
Converts src to string format in base specified by base.
void edwards_point_get_x_affine(field_elt x, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->x to its affine representation.
void jacobi_quartic_point_dbl_dedicated(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to 2*P1, using dedicated formulae (not protected against SPA, but faster)
void edwards_point_add_dedicated(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Compute the addition of 2 points P1 and P2 of the Edwards elliptic curve E (not protected against SPA...
bool field_elt_issquare(fe_srcptr src, field_srcptr k, uint8_t stack)
Test if src is a square using the Lengendre symbol.
void ec_point_dbl(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to 2*P1, using dedicated formulae (not protected against SPA, but faster)
void jacobi_quartic_point_set_aff_str(ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack)
Set dest to the affine point (str_x,str_y)
bool weierstrass_point_are_equal(ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Test if P1 and P2 are equal on E (BUT do not test if they belong to the curve)
void field_elt_lift(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical fp (or its co...
void number_copy(number_ptr dst, number_srcptr src)
Copy src into dst.
void ec_point_mul_naive(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also avail...
void ec_alloc(ec_curve_ptr E, field_srcptr k)
Allocate a curve.
void edwards_point_set_aff(ec_point_ptr P, fe_srcptr x, fe_srcptr y, field_srcptr k, uint8_t stack)
Set dest to the extended twisted Edwards coordinates point (x,y,1,xy)
void field_elt_clear(fe_ptr *src, field_srcptr k)
Clear space used by src (remove the action of field_elt_init but let the one of field_elt_alloc)
void ec_copy(ec_curve_ptr E_res, ec_curve_srcptr E)
Copy E into E_res which has been previously allocated, beware: the same field is used,...
const fp_elt * fe_srcptr
Pointer on a field element, the field element cannot be modified through this pointer.
void ec_set_fast_unified_coordinates(ec_curve_ptr E)
Set the fastest unified coordinates system.
void jacobi_quartic_compute_disc(ec_curve E, uint8_t stack)
Set the discriminant of E: disc = (2^8).(a^2 - 1)^2.
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.
bool ec_point_are_equal(ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Test if P1 and P2 are equal on E.
void ec_point_sub_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 - P2, using unified formulae (protection against SPA)
void edwards_point_to_weierstrass_point(ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Convert the Edwards point P of the elliptic curve E to the corresponding Weierstrass elliptic curve p...
int8_t field_elt_cmp(fe_srcptr src1, fe_srcptr src2, field_srcptr k)
Compare src1 and src2.
void edwards_curve_random_generation(fe_ptr d, char *seed_res, field_srcptr k, uint8_t stack)
Generate a 160 bits seed and coefficients a and b defining a Weiestrass elliptic curve....
void edwards_compute_disc(ec_curve E, uint8_t stack)
Set the discriminant of E: disc = a.d.(a-d)^4.
void number_tmp_free(number *t, const uint8_t size, uint8_t stack)
Free a temporary number.
void jacobi_quartic_point_norm(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert a point in extented projective coordinate (X,Y,T,Z) to an affine point (x,...
void jacobi_quartic_point_set_aff(ec_point_ptr P, fe_srcptr x, fe_srcptr y, field_srcptr k, uint8_t stack)
Set dest to the affine point (x,y)
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.
enum ec_algo_enum ec_formula
Define the type of coordinate.
fp_elt * fe_ptr
Pointer on a field element.
void field_elt_inv(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
Set dst <- src^(-1)
void ec_point_mul(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using Montgomery for Weierstrass elliptic curve, and naive method for other elliptic...
bool jacobi_quartic_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
int16_t binary_to_indice_new(char *str, int16_t beg, int16_t end)
Compute the indice for the sliding window multiplication.
bool edwards_belongs(ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
Test if P belongs to E.
void weierstrass_points_of_order_2(ec_point_ptr dst1, ec_point_ptr dst2, ec_point_ptr dst3, ec_curve_srcptr E, uint8_t stack)
Set dst1, dst2, dst3 to the points of order 2 of the curve E assuming they are different otherwise th...
void field_elt_init(fe_ptr dst, field_srcptr k)
Initialise the field element.
void field_str(char **str, field_srcptr k, const uint8_t base, uint8_t stack)
Converts k to string format in base specified by base.
void ec_point_copy(ec_point_ptr P3, ec_point_srcptr P, field_srcptr k)
Copy P into P3.
void ec_point_2mul_with_precomp(ec_point_ptr P3, number_srcptr n1, ec_point *tab_P1, number_srcptr n2, ec_point *tab_P2, int16_t win_size, ec_curve_srcptr E, uint8_t stack)
Set P3 to n1 * P1 + n2 * P2 using 2 precomputated array.
void jacobi_quartic_curve_random_generation(fe_ptr a, char *seed_res, field_srcptr k, uint8_t stack)
Generate a 160 bits seed and coefficients a and b defining a Weiestrass elliptic curve....
void ec_curve_print(ec_curve_srcptr E, const uint8_t base, uint8_t stack)
Print a description of E.
enum ec_type_enum ec_type
Define the type of curve.
void number_set_str(number_ptr dst, const char *str, const uint8_t base)
Set dst to str.
void number_tmp_alloc(number *t, const uint8_t size, uint8_t stack)
Allocate a temporary number.
static void field_elt_neg(fe_ptr dst, fe_srcptr src, field_srcptr k)
Set dst <- (-src)
void weierstrass_to_jacobi_quartic(ec_curve_ptr E_res, ec_curve_srcptr E, const bool determined, fe_ptr teta, uint8_t stack)
Convert a Weierstrass elliptic curve into a jacobi quartic elliptic curve.
void number_init(number *dst, const uint8_t n)
Allocate a number_ptr on the RAM memory (malloc)
void weierstrass_point_norm(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Set P in affine coordinates.
void weierstrass_point_dbl_dedicated(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to 2 * P1, using dedicated formulae (not protected against SPA, but faster)
void ec_point_clear(ec_point_ptr P, field_srcptr k)
Clear the point P (remove the action of ec_point_init, but let the one of ec_point_alloc)
void ec_point_random(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Create a random point P on the elliptic curve E.
void ec_point_mul_with_precomp(ec_point_ptr P3, number_srcptr n, ec_point *tab_P1, int16_t win_size, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also avail...
Define an elliptic curve.
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...
static void field_elt_sqr(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
Set dst <- src^2.
bool jacobi_quartic_verify_random_generation(ec_curve E, const char *seed, uint8_t stack)
Test if E if generated from the seed "seed".
void ec_point_set_aff(ec_point_ptr P, fe_srcptr x, fe_srcptr y, const ec_type type, field_srcptr k, uint8_t stack)
Set a point from its affine coordinates.
enum ec_known_curve_enum ec_known_curve
Define the hardcoded curves.
void ec_curve_str(char **str, ec_curve_srcptr E, const uint8_t base, uint8_t stack)
Allocate *str and write in it the description of E.
void field_elt_set_ui(fe_ptr dst, const block src, const bool isreduced, field_srcptr k, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void jacobi_quartic_point_add_unified(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 + P2 using extended projective coordinate (T=(X^2)/Z), and unified formulae (protection ...
void ec_point_mul_sliding_window(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also avail...
void edwards_point_norm(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Set P in affine coordinates.
void jacobi_quartic_point_neg(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E)
Set P3 to -P1.
void edwards_point_dbl_dedicated(ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Compute the double of a point of the Edwards elliptic curve E (not protected against SPA,...
static void field_elt_sub(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k)
Set dst <- src1 - src2.
static void field_elt_dec(fe_ptr dst, fe_srcptr src, field_srcptr k)
Set dst <- src - 1.
void ec_clear(ec_curve_ptr E)
Clear the elliptic curve E (remove the action of ec_init, but let the one of ec_alloc)
void ec_point_mul_naive_unified(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also avail...
static void field_elt_relax_pool_elt(field_elt *dst, field_ptr k, uint8_t stack)
Relax an initialised field element from the pool.
void ec_point_lift(ec_point_ptr P, field_srcptr k, uint8_t stack)
Lift the coordinates from Montgomery basis to classical arithmetic.
bool ec_verify_random_generation(ec_curve_ptr E, const char *seed, uint8_t stack)
Test if E if generated from the seed "seed", using algorithm A.3.4.2 from ANS X9.62-1998....
static void field_elt_add(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k)
Set dst <- src1 + src2.
void ec_point_sub(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 - P2, using dedicated formulae (not protected against SPA, but faster)
void ec_set_fast_dedicated_coordinates(ec_curve_ptr E)
Set the fastest dedicated coordinates system.
static void field_elt_get_pool_elt(field_elt *dst, field_ptr k, uint8_t stack)
Get an initialised field element from the pool.
void number_str(char **str, number_srcptr src, const uint8_t base)
Converts src to string format in base specified by base.
void weierstrass_point_add_dedicated(ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Set P3 to P1 + P2, using dedicated formulae (not protected against SPA, but faster)
void weierstrass_curve_random_generation(fe_ptr a, fe_ptr b, char *seed_res, field_srcptr k, uint8_t stack)
Generate a 160 bits seed and coefficients a and b defining a Weiestrass elliptic curve....
void edwards_point_set_neutral(ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
Set dst to the neutral element: (0,1,0,1) for extended twisted Edwards coordinates.
bool edwards_point_are_equal(ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
Test if P1 and P2 are equal on E (BUT do not test if the points belongs to the curve )
void ec_point_norm(ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert a point in projective or jacobian coordinate to an affine point (x,y)
void jacobi_quartic_point_get_x_affine(field_elt x, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->x to its affine representation.
void ec_point_get_x_affine(field_elt x, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
Convert P->x to its affine representation.
void ec_test_spec(ec_curve_ptr E, uint8_t stack)
Set the E->ec_spec1 to true if E->a = -3 mod p, false otherwise.
void ec_point_mul_unified(ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
Set P3 to n * P1 using Montgomery for Weierstrass elliptic curve, and naive method for other elliptic...