62 for(i=0; i<POOL_SIZE_FIELD; i++)
66 #if MPHELL_USE_MULTITHREADING == 1 68 for(i=0; i<POOL_SIZE_FIELD; i++)
84 if((
id != NULL) && (
id[0] !=
'\0'))
87 if(strcmp(
id,
"p192r1")==0)
91 else if(strcmp(
id,
"p224r1")==0)
95 else if(strcmp(
id,
"p256r1")==0)
99 else if(strcmp(
id,
"p384r1")==0)
103 else if(strcmp(
id,
"p521r1")==0)
114 strcpy(k->
id,
"NO_ID");
122 p = va_arg(va, number_t *);
131 non_residue = va_arg(va, fp_elt *);
140 non_residue = va_arg(va, fp_elt *);
150 for(i=0; i<POOL_SIZE_FIELD; i++)
154 #if MPHELL_USE_MULTITHREADING == 1 156 for(i=0; i<POOL_SIZE_FIELD; i++)
206 for(i=0; i<POOL_SIZE_FIELD; i++)
210 #if MPHELL_USE_MULTITHREADING == 1 212 for(i=0; i<POOL_SIZE_FIELD; i++)
282 *dst = (fp_elt *)malloc(
sizeof(fp_elt));
287 *dst = (fp_elt *)malloc(
sizeof(
fp2_elt));
292 *dst = (fp_elt *)malloc(
sizeof(
fp3_elt));
419 number_t *n1, *n2, *n3;
423 n1 = va_arg(va, number_t *);
430 n1 = va_arg(va, number_t *);
435 n1 = va_arg(va, number_t *);
436 n2 = va_arg(va, number_t *);
444 n1 = va_arg(va, number_t *);
449 n1 = va_arg(va, number_t *);
450 n2 = va_arg(va, number_t *);
451 n3 = va_arg(va, number_t *);
464 fp_elt *n1, *n2, *n3;
468 n1 = va_arg(va, fp_elt *);
475 n1 = va_arg(va, fp_elt *);
480 n1 = va_arg(va, fp_elt *);
481 n2 = va_arg(va, fp_elt *);
489 n1 = va_arg(va, fp_elt *);
494 n1 = va_arg(va, fp_elt *);
495 n2 = va_arg(va, fp_elt *);
496 n3 = va_arg(va, fp_elt *);
582 mphell_error(
"pos must be 1 or 2 to get first or second part of the FP2 element\n");
600 mphell_error(
"pos must be 1, 2 or 3 to get first, second or third part of the FP3 element\n");
626 mphell_error(
"pos must be 1 or 2 to get first or second part of the FP2 element\n");
644 mphell_error(
"pos must be 1, 2 or 3 to get first, second or third part of the FP3 element\n");
653 char *def, *param_str = NULL;
657 def =
"Prime field :\n";
661 def =
"Quadractic extension of prime field :\n";
665 def =
"Cubic extension of prime field :\n";
669 if(param_str != NULL)
671 *str = (
char*)malloc(strlen(def) + strlen(param_str) + 2);
672 sprintf(*str,
"%s%s", def, param_str);
710 *str = (
char*)malloc(strlen(v_str)+1);
738 res =
fp_elt_cmp((fp_elt_srcptr)(*src1), (fp_elt_srcptr)(*src2), k->
param);
759 res =
fp_elt_cmp((fp_elt_srcptr)(*src1), (fp_elt_srcptr)(*src2), k->
param);
818 if((res1==0) && (res2 ==0))
831 if((res1==0) && (res2 ==0))
1028 is not a square in k");
1049 : src is not a cube in k");
1093 fp_elt_inv((fp_elt_ptr)(*dst), (fp_elt_srcptr)(*src), k->
param, stack);
1112 fp_elt_inv((fp_elt_ptr)(*dst), (fp_elt_srcptr)(*src), k->
param, stack);
1198 fp_elt_div((fp_elt_ptr)(*dst), (fp_elt_srcptr)(*src1), (fp_elt_srcptr)(*src2), k->
param, stack);
1217 fp_elt_div((fp_elt_ptr)(*dst), (fp_elt_srcptr)(*src1), (fp_elt_srcptr)(*src2), k->
param, stack);
void fp3_get_characteristic(number_ptr c, const fp3_param param)
Get the characteristic of the cubic extension field "param".
void fp2_elt_set_one(fp2_elt_ptr dst, const fp2_param param)
Set dst to one (or its Montgomery form if Montgomery arithmetic is used)
void fp2_elt_alloc(fp2_elt *dst, const fp2_param param)
Allocate space for a quadratic extension field element.
void field_elt_unity_nth_root(fe_ptr dst, const block n, field_ptr k, uint8_t stack)
Set dst to a non trivial n-th root of unity if it exists (ie n divides order(k)-1),...
int8_t fp_elt_cmp(fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param)
Compare src1 and src2 in Fp.
int8_t field_elt_cmp_fp_elt(fe_srcptr src1, fe_srcptr src2, field_srcptr k)
Compare src1 and src2.
void fp3_elt_alloc(fp3_elt *dst, const fp3_param param)
Allocate space for a cubic extension field element.
void fp2_alloc(fp2_param param, const fp_param base)
Allocate space for the quadratic extension field informations structure.
void fp2_elt_sqrt(fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack)
Set dst <- src^(1/2), using Tonelli–Shanks algorithm.
void fp2_elt_clear(fp2_elt *src)
Clear space used by src (remove the action of fp2_elt_init but less the one of fp2_elt_alloc)
void fp2_elt_copy(fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param)
Copy src into dst, src and dst must belong to the same FP2.
void field_elt_free(fe_ptr *src, field_srcptr k)
Free space used by src.
void fp3_elt_pow_number(fp3_elt_ptr dst, fp3_elt_srcptr src, number_srcptr n, const fp3_param param, uint8_t stack)
Set dst <- src^n.
Declaration of field functions.
void fp_elt_pow_number(fp_elt_ptr dst, fp_elt_srcptr src, number_srcptr n, const fp_param param, uint8_t stack)
Set dst <- src^n.
void fp2_elt_lift(fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack)
If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical FP2.
void fp3_elt_random(fp3_elt_ptr dst, const fp3_param param, uint8_t stack)
Set dst to a random element of FP3, the random process is chosen at the MHELL initialisation.
void fp_elt_set_ui(fp_elt_ptr dst, const block src, const bool isreduced, const fp_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
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 fp3_elt_init(fp3_elt_ptr dst, const fp3_param param)
Initialise a cubic extension field element.
void fp2_elt_unity_nth_root(fp2_elt_ptr dst, const block n, const fp2_param param, uint8_t stack)
Set dst to a non trivial n-th root of unity if it exists (ie n divides q-1), 1 otherwise.
void fp_elt_free(fp_elt *src)
Free space used by src.
void fp2_elt_pow_ui(fp2_elt_ptr dst, fp2_elt_srcptr src, const block n, const fp2_param param, uint8_t stack)
Set dst <- src^n.
void field_elt_inv_fp_elt(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
Set dst <- src^(-1)
void fp2_create(fp2_param param, const fp_param base, fp_elt_srcptr non_residue, uint8_t stack)
Create a quadratic extension of the field base.
void fp3_elt_set_one(fp3_elt_ptr dst, const fp3_param param)
Set dst to one (or its Montgomery form if Montgomery arithmetic is used)
int8_t fp3_elt_cmp_fp_elt(fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param)
Compare src1 and src2 in FP3.
void fp2_free(fp2_param param)
Free the space of the quadratic extension field informations structure.
void fp_elt_clear(fp_elt *src)
Clear space used by src (remove the action of fp_elt_init but let the one of fp_elt_alloc)
field_elt pool_1[POOL_SIZE_FIELD]
void fp3_elt_pow_ui(fp3_elt_ptr dst, fp3_elt_srcptr src, const block n, const fp3_param param, uint8_t stack)
Set dst <- src^n.
enum fp_id_e fp_id
Identifier for known field, use by IPPCP to accelerate the field arithmetic.
bool fp3_elt_isone(fp3_elt_srcptr src, const fp3_param param)
Test if src is one.
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.
void fp_elt_pow_ui(fp_elt_ptr dst, fp_elt_srcptr src, const block n, const fp_param param, uint8_t stack)
Set dst <- src^n.
void fp2_elt_set_ui(fp2_elt_ptr dst, const uint64_t src, const bool isreduced, const fp2_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void field_elt_div(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k, uint8_t stack)
Set dst <- src1 / src2.
void fp3_elt_set(fp3_elt_ptr dst, number_srcptr src1, number_srcptr src2, number_srcptr src3, const bool isreduced, const fp3_param param, uint8_t stack)
Set dst to src1 + src2*x + src3*x^2, if Montgomery arithmetic is used, is_reduced == false -> transfo...
void field_elt_div_fp_elt(fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k, uint8_t stack)
Set dst <- src1 / src2.
void fp2_elt_set(fp2_elt_ptr dst, number_srcptr src1, number_srcptr src2, const bool isreduced, const fp2_param param, uint8_t stack)
Set dst to src1 + src2*x, if Montgomery arithmetic is used, is_reduced == false -> transform dst into...
void fp3_elt_inv_fp_elt(fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param, uint8_t stack)
Set dst <- src^(-1)
void fp3_elt_div(fp3_elt_ptr dst, fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param, uint8_t stack)
Set dst <- src1 / src2.
int8_t fp3_elt_ispower_number(fp3_elt_srcptr src, number_srcptr n, const fp3_param param, uint8_t stack)
Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VA...
bool field_elt_isone(fe_srcptr src, field_srcptr k)
Test if src is one.
void field_elt_cube_root(fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack)
Set dst <- src^(1/3)
void fp3_get_size(number_ptr c, const fp3_param param)
Get the size of the cubic extension field "param".
void fp3_elt_str(char **str, fp3_elt_srcptr src, const uint8_t base, const bool lift, const fp3_param param, uint8_t stack)
Converts src to string format in base specified by base.
void fp2_elt_str(char **str, fp2_elt_srcptr src, const uint8_t base, const bool lift, const fp2_param param, uint8_t stack)
Converts src to string format in base specified by base.
int8_t fp2_elt_ispower_ui(fp2_elt_srcptr src, const block n, const fp2_param param, uint8_t stack)
Test if src is a n-power in FP2, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VA...
void fp2_copy(fp2_param param_res, const fp2_param param)
Copy the quadratic extension field structure param into param_res.
void fp2_elt_random(fp2_elt_ptr dst, const fp2_param param, uint8_t stack)
Set dst to a random element of FP2, the random process is chosen at the MHELL initialisation.
void fp_create(fp_param param, number_srcptr p, fp_id id, uint8_t stack)
Create a prime field of characteristic p.
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 field_isequal(field_srcptr k1, field_srcptr k2)
Test if k1 and k2 are equals.
bool field_find_nonpower_number(fe_ptr dst, number_srcptr n, field_ptr k, uint8_t stack)
Look for a random non n-power element in k.
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 fp2_elt_cube_root(fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack)
Set dst <- src^(1/3)
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 fp_elt_copy(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
Copy src into dst, src and dst must belong to the same Fp.
void field_elt_get_number(number_ptr dst, fe_srcptr src, uint8_t pos, 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 fp_get_characteristic(number_ptr c, const fp_param param)
Get the characteristic of the prime field "param".
void fp3_free(fp3_param param)
Free the space of the cubic extension field informations structure.
bool fp2_elt_isone(fp2_elt_srcptr src, const fp2_param param)
Test if src is one.
void fp3_elt_unity_nth_root(fp3_elt_ptr dst, const block n, const fp3_param param, uint8_t stack)
Set dst to a non trivial n-th root of unity if it exists (ie n divides q-1), 1 otherwise.
void fp_free(fp_param param)
Free the space of the prime field informations structure.
void fp3_str(char **str, const fp3_param param, const uint8_t base, uint8_t stack)
Converts fp2_param param to string format in base specified by base.
void field_elt_set_fp_elts(fe_ptr dst, field_srcptr k, const uint32_t n,...)
Set dst to src(s)
void fp2_elt_inv(fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack)
Set dst <- src^(-1)
void fp3_elt_sqrt(fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
Set dst <- src^(1/2), using Tonelli–Shanks algorithm.
void fp_str(char **str, const fp_param param, const uint8_t base, uint8_t stack)
Converts fp_param param to string format in base specified by base.
int8_t fp_elt_ispower_number(fp_elt_srcptr src, number_srcptr n, const fp_param param, uint8_t stack)
Test if src is a n-power in Fp.
void fp_elt_set_number(fp_elt_ptr dst, number_srcptr src, const bool isreduced, const fp_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void field_get_size(number_ptr c, field_srcptr k)
Get the size of the field "k".
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.
bool fp_elt_isone(fp_elt_srcptr src, const fp_param param)
Test if src is one.
void fp_elt_get_number(number_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical number (in FP...
bool field_elt_issquare(fe_srcptr src, field_srcptr k, uint8_t stack)
Test if src is a square using the Lengendre symbol.
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 fp3_elt_copy(fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
Copy src into dst, src and dst must belong to the same FP3.
void fp2_elt_div(fp2_elt_ptr dst, fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param, uint8_t stack)
Set dst <- src1 / src2.
void fp3_alloc(fp3_param param, const fp_param base)
Allocate space for the cubic extension field informations structure.
bool fp2_elt_issquare(fp2_elt_srcptr src, const fp2_param param, uint8_t stack)
Test if src is a square, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDS...
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 fp_elt_alloc(fp_elt *dst, const fp_param param)
Allocate space for a primary field element.
void fp_elt_inv(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
Set dst <- src^(-1)
void fp2_str(char **str, const fp2_param param, const uint8_t base, uint8_t stack)
Converts fp2_param param to string format in base specified by base.
const fp_elt * fe_srcptr
Pointer on a field element, the field element cannot be modified through this pointer.
void field_get_characteristic(number_ptr c, field_srcptr k)
Get the charactristic of the field "k".
int8_t field_elt_ispower_ui(fe_srcptr src, const block n, field_srcptr k, uint8_t stack)
Test if src is a n-power in src->k.
void field_elt_get_fp_elt(fe_ptr dst, fe_srcptr src, uint8_t pos, field_srcptr k)
Get the field_elt in position 1, 2 or 3 of the src element. Rmq: if src element is in FP,...
void fp3_elt_set_number(fp3_elt_ptr dst, number_srcptr src, const bool isreduced, const fp3_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
int8_t field_elt_cmp(fe_srcptr src1, fe_srcptr src2, field_srcptr k)
Compare src1 and src2.
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 fp2_elt_div_fp_elt(fp2_elt_ptr dst, fp2_elt_srcptr src1, fp_elt_srcptr src2, const fp2_param param, uint8_t stack)
Set dst <- src1 / src2.
bool field_find_nonpower_ui(fe_ptr dst, const block n, field_ptr k, uint8_t stack)
Look for a random non n-power element in k.
void fp3_copy(fp3_param param_res, const fp3_param param)
Copy the cubic extension field structure param into param_res.
Cubic extension field element structure.
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 fp_copy(fp_param param_res, const fp_param param)
Copy the prime field structure param into param_res.
void field_copy(field_ptr k_res, field_srcptr k)
Copy the field structure param into param_res.
void fp2_elt_init(fp2_elt_ptr dst, const fp2_param param)
Initialise a quadratic extension field element.
void fp3_elt_clear(fp3_elt *src)
Clear space used by src (remove the action of fp3_elt_init but let the one of fp3_elt_alloc)
field_type
Define the field type.
void field_elt_init(fe_ptr dst, field_srcptr k)
Initialise the field element.
void fp_elt_div(fp_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param, uint8_t stack)
Set dst <- src1 / src2.
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 fp3_elt_set_fp_elt(fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param)
Set dst to src.
bool fp3_elt_issquare(fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
Test if src is a square, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDS...
void fp3_elt_set_str(fp3_elt_ptr dst, const char *str, const uint8_t base, const bool isreduced, const fp3_param param, uint8_t stack)
Set dst to str, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
int8_t fp_elt_ispower_ui(fp_elt_srcptr src, const block n, const fp_param param, uint8_t stack)
Test if src is a n-power in Fp.
Quadratic extension field element structure.
int8_t fp2_elt_cmp_fp_elt(fp2_elt_srcptr src1, fp_elt_srcptr src2, const fp2_param param)
Compare src1 and src2 in FP2.
void fp_elt_set_str(fp_elt_ptr dst, const char *str, const uint8_t base, const bool isreduced, const fp_param param, uint8_t stack)
Set dst to str, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void fp2_elt_set_number(fp2_elt_ptr dst, number_srcptr src, const bool isreduced, const fp2_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void field_elt_pow_number(fe_ptr dst, fe_srcptr src, number_srcptr n, field_srcptr k, uint8_t stack)
Set dst <- src^n.
Cubic extension field structure.
void fp2_elt_pow_number(fp2_elt_ptr dst, fp2_elt_srcptr src, number_srcptr n, const fp2_param param, uint8_t stack)
Set dst <- src^n.
void field_elt_print(fe_srcptr src, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack)
Print src in base specified by base.
void fp3_create(fp3_param param, const fp_param base, fp_elt_srcptr non_residue, uint8_t stack)
Create a cubic extension of the field base.
int8_t number_cmp(number_srcptr src1, number_srcptr src2)
Compare src1 and src2.
void field_elt_pow_ui(fe_ptr dst, fe_srcptr src, const block n, field_srcptr k, uint8_t stack)
Set dst <- src^n.
void field_free(field_ptr k)
Free the space of the field informations structure.
void fp_elt_unity_nth_root(fp_elt_ptr dst, const block n, const fp_param param, uint8_t stack)
Set dst to a non trivial n-th root of unity if it exists (ie n divides p-1), 1 otherwise.
void field_find_nonsquare(fe_ptr dst, field_ptr k, uint8_t stack)
Look for a random non square element in k.
int8_t fp2_elt_ispower_number(fp2_elt_srcptr src, number_srcptr n, const fp2_param param, uint8_t stack)
Test if src is a n-power in FP2, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VA...
void fp2_elt_inv_fp_elt(fp2_elt_ptr dst, fp_elt_srcptr src, const fp2_param param, uint8_t stack)
Set dst <- src^(-1)
void fp_elt_cube_root(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
Set dst <- src^(1/3) mod p.
void fp_elt_lift(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical fp.
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...
Primary field parameters.
void fp3_elt_free(fp3_elt *src)
Free space used by src.
void fp2_elt_set_str(fp2_elt_ptr dst, const char *str, const uint8_t base, const bool isreduced, const fp2_param param, uint8_t stack)
Set dst to str, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void fp3_elt_set_fp_elts(fp3_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, fp_elt_srcptr src3, const fp3_param param)
Set dst to src1 + src2*x + src3*x^2.
bool fp_elt_issquare(fp_elt_srcptr src, const fp_param param, uint8_t stack)
Test if src is a square using the Lengendre symbol.
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 fp_elt_sqrt(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
Set dst <- src^(1/2) mod p, using Tonelli–Shanks algorithm.
void fp3_elt_set_ui(fp3_elt_ptr dst, const uint64_t src, const bool isreduced, const fp3_param param, uint8_t stack)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void fp2_elt_set_fp_elts(fp2_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, const fp2_param param)
Set dst to src1 + src2*x.
void field_print(field_srcptr k, const uint8_t base, uint8_t stack)
Print the different fields of the structure pointed by k.
void fp_elt_random(fp_elt_ptr dst, const fp_param param, uint8_t stack)
Set dst to a random element of Fp, the random process is chosen at the MHELL initialisation.
void fp3_elt_inv(fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
Set dst <- src^(-1)
void fp_alloc(fp_param param, const uint8_t size)
Allocate space for the prime field informations structure.
void fp2_get_characteristic(number_ptr c, const fp2_param param)
Get the characteristic of the quadratic extension field "param".
int8_t fp2_elt_cmp(fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param)
Compare src1 and src2 in FP2.
void fp_elt_set_one(fp_elt_ptr dst, const fp_param param)
Set dst to one (or its Montgomery form if Montgomery arithmetic is used)
void fp3_elt_div_fp_elt(fp3_elt_ptr dst, fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param, uint8_t stack)
Set dst <- src1 / src2.
void fp2_get_size(number_ptr c, const fp2_param param)
Get the size of the quadratic extension field "param".
void fp_elt_str(char **str, fp_elt_srcptr src, const uint8_t base, const bool lift, const fp_param param, uint8_t stack)
Converts src to string format in base specified by base.
Quadratic extension field structure.
void fp3_elt_lift(fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical FP3.
int8_t fp3_elt_cmp(fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param)
Compare src1 and src2 in FP3.
void fp2_elt_set_fp_elt(fp2_elt_ptr dst, fp_elt_srcptr src, const fp2_param param)
Set dst to src.
void field_elt_random(fe_ptr dst, field_srcptr k, uint8_t stack)
Set dst to a random element of k, the random process is chosen at the MHELL initialisation.
void field_elt_set_number(fe_ptr dst, const bool isreduced, field_srcptr k, uint8_t stack, const uint32_t n,...)
Set dst to src, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montg...
void fp_elt_init(fp_elt_ptr dst, const fp_param param)
Initialise a primary field element.
void fp3_elt_cube_root(fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
Set dst <- src^(1/3)
int8_t field_elt_ispower_number(fe_srcptr src, number_srcptr n, field_srcptr k, uint8_t stack)
Test if src is a n-power in src->k.
int8_t fp3_elt_ispower_ui(fp3_elt_srcptr src, const block n, const fp3_param param, uint8_t stack)
Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VA...
void fp2_elt_free(fp2_elt *src)
Free space used by src.