43 fp_elt_str(&str, src, base, lift, param, stack);
62 MPHELL_ASSERT(size >= 1,
"fp_alloc : size specified is 0");
69 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 70 #if MPHELL_USE_MONTGOMERY == 1 76 #elif MPHELL_USE_IPP == 1 79 ippsGFpGetSize(size*32, &ctxsize);
80 param->gf = (IppsGFpState *)malloc(ctxsize *
sizeof(Ipp8u));
84 for(i=0; i<POOL_SIZE_FP; i++)
88 #if MPHELL_USE_MULTITHREADING == 1 90 for(i=0; i<POOL_SIZE_FP; i++)
106 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 118 fp_elt_pow_number(param->gen_2sylow, param->non_residue, param->p_odd, param, stack);
142 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 143 MPHELL_ASSERT(param->size >= 1,
"fp_create : k is not well allocated");
144 MPHELL_ASSERT((SIZ(p) <= param->size),
"fp_create : The size of p is different from the size used to allocate k");
149 #if MPHELL_USE_MONTGOMERY == 1 150 uint8_t n = param->size;
189 #elif MPHELL_USE_IPP == 1 195 ippsRef_BN(NULL, &len, NULL, p);
196 st = ippsGFpInitArbitrary(p, len, param->gf);
197 if(st != ippStsNoErr)
199 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
203 st = ippsGFpInitFixed(192, ippsGFpMethod_p192r1(), param->gf);
204 if(st != ippStsNoErr)
206 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
210 st = ippsGFpInitFixed(224, ippsGFpMethod_p224r1(), param->gf);
211 if(st != ippStsNoErr)
213 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
217 st = ippsGFpInitFixed(256, ippsGFpMethod_p256r1(), param->gf);
218 if(st != ippStsNoErr)
220 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
224 st = ippsGFpInitFixed(384, ippsGFpMethod_p384r1(), param->gf);
225 if(st != ippStsNoErr)
227 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
231 st = ippsGFpInitFixed(521, ippsGFpMethod_p521r1(), param->gf);
232 if(st != ippStsNoErr)
234 printf(
"Error fp_create: ippsGFpInitArbitrary: %s\n", ippcpGetStatusString(st));
241 st = ippsGFpSetElement(&one, 1, param->one, param->gf);
242 if(st != ippStsNoErr)
244 printf(
"Error fp_create: ippsGFpSetElement: %s\n", ippcpGetStatusString(st));
249 for(i=0; i<POOL_SIZE_FP; i++)
253 #if MPHELL_USE_MULTITHREADING == 1 255 for(i=0; i<POOL_SIZE_FP; i++)
260 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 268 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 269 MPHELL_ASSERT(param_res->size == param->size,
"fp_copy : The size of k_res \ 270 is different from the size of k");
278 #if MPHELL_USE_MONTGOMERY == 1 280 param_res->invp = param->invp;
282 fp_elt_copy(param_res->non_residue, param->non_residue, param);
283 fp_elt_copy(param_res->gen_2sylow, param->gen_2sylow, param);
285 param_res->p_even = param->p_even;
286 #elif MPHELL_USE_IPP == 1 297 for(i=0; i<POOL_SIZE_FP; i++)
308 #if MPHELL_USE_MULTITHREADING == 1 310 for(i=0; i<POOL_SIZE_FP; i++)
316 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 317 #if MPHELL_USE_MONTGOMERY == 1 319 param->invp = (block)0;
324 param->p_even = (uint32_t)0;
325 param->size = (uint8_t)0;
326 #elif MPHELL_USE_IPP == 1 346 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 347 *dst = (fp_elt)malloc(
sizeof(number));
348 #elif MPHELL_USE_IPP == 1 351 int size = 16 + (param->size)*8;
352 *dst = (fp_elt)malloc(size *
sizeof(Ipp8u));
359 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 361 #elif MPHELL_USE_IPP == 1 362 ippsGFpElementInit(NULL, 0, dst, param->gf);
369 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 371 #elif MPHELL_USE_IPP == 1 372 ippsGFpCpyElement(src, dst, param->gf);
379 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 387 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 396 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 398 #elif MPHELL_USE_IPP == 1 406 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 408 #elif MPHELL_USE_IPP == 1 410 ippsGFpSetElement(&zero, 1, dst, param->gf);
416 const fp_param param, uint8_t stack)
418 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 420 #if MPHELL_USE_MONTGOMERY == 1 424 redcify(*dst, *dst, param->p, stack);
427 #elif MPHELL_USE_IPP == 1 428 ippsGFpSetElement(&src, 1, dst, param->gf);
434 const fp_param param, uint8_t stack)
436 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 438 #if MPHELL_USE_MONTGOMERY == 1 442 redcify(*dst, *dst, param->p, stack);
445 #elif MPHELL_USE_IPP == 1 448 ippsRef_BN(NULL, &len, &data, src);
450 ippsGFpSetElement(data, lenchunk, dst, param->gf);
456 const bool isreduced,
const fp_param param, uint8_t stack)
458 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 460 #if MPHELL_USE_MONTGOMERY == 1 464 redcify(*dst, *dst, param->p, stack);
467 #elif MPHELL_USE_IPP == 1 473 ippsRef_BN(NULL, &len, &data, tmp);
475 ippsGFpSetElement(data, lenchunk, dst, param->gf);
483 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 485 #if MPHELL_USE_MONTGOMERY == 1 487 redcify(*dst, *dst, param->p, stack);
489 #elif MPHELL_USE_IPP == 1 495 ippsRef_BN(NULL, &len, &data, tmp);
497 ippsGFpSetElement(data, lenchunk, dst, param->gf);
505 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 506 #if MPHELL_USE_MONTGOMERY == 1 516 #elif MPHELL_USE_IPP == 1 524 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 525 #if MPHELL_USE_MONTGOMERY == 1 535 #elif MPHELL_USE_IPP == 1 536 Ipp32u data[param->size];
537 ippsGFpGetElement(src, data, param->size, param->gf);
538 ippsSet_BN(IppsBigNumPOS, param->size, data, dst);
545 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 547 char *p_str, *one_str;
548 char *non_residue_str, *p_odd_str, *gen_2sylow_str;
549 #if MPHELL_USE_MONTGOMERY == 1 553 fp_elt_str(&one_str, param->one, base,
false, param, stack);
555 fp_elt_str(&non_residue_str, param->non_residue, base,
true, param, stack);
556 fp_elt_str(&gen_2sylow_str, param->gen_2sylow, base,
true, param, stack);
557 #if MPHELL_USE_MONTGOMERY == 1 560 strsize = 250 + strlen(p_str) + strlen(one_str);
561 strsize += strlen(non_residue_str) + strlen(p_odd_str) + strlen(gen_2sylow_str);
562 #if MPHELL_USE_MONTGOMERY == 1 563 strsize += strlen(R2_str);
565 *str = (
char*)malloc(strsize*
sizeof(
char));
567 sprintf(s,
"p : %s \none : %s\n", p_str, one_str);
568 sprintf(s + strlen(s),
"non_residue : %s\np_odd : %s\ 569 \np_even : %d\ngen_2sylow : %s", non_residue_str,
570 p_odd_str, (
int)param->p_even, gen_2sylow_str);
571 #if MPHELL_USE_MONTGOMERY == 1 573 sprintf(s + strlen(s),
"\nR2 : %s \ninvp : %"PRIu64
"\n", R2_str,
576 sprintf(s + strlen(s),
"\nR2 : %s \ninvp : %"PRIu32
"\n", R2_str,
581 free(non_residue_str);
582 free(gen_2sylow_str);
583 #if MPHELL_USE_MONTGOMERY == 1 588 #elif MPHELL_USE_IPP == 1 592 strsize = 250 + strlen(p_str);
593 *str = (
char*)malloc(strsize*
sizeof(
char));
594 sprintf(*str,
"p : %s \n", p_str);
600 fp_elt_str (
char **str, fp_elt_srcptr src,
const uint8_t base,
601 const bool lift,
const fp_param param, uint8_t stack)
603 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 616 #elif MPHELL_USE_IPP == 1 619 Ipp32u *data = malloc(param->size *
sizeof(Ipp32u));
620 ippsGFpGetElement(src, data, param->size, param->gf);
621 ippsSet_BN(IppsBigNumPOS, param->size, data, tmp);
633 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 635 #elif MPHELL_USE_IPP == 1 637 ippsGFpCmpElement(src1, src2, &res, param->gf);
642 else if (res == IPP_IS_GT)
656 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 658 #elif MPHELL_USE_IPP == 1 660 ippsGFpIsUnityElement(src, &res, param->gf);
661 return (res == IPP_IS_EQ);
718 MPHELL_ASSERT(
fp_elt_iszero(src, param) ==
false,
"fp_elt_inv : src == 0");
724 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 725 #if MPHELL_USE_MONTGOMERY == 1 730 #elif MPHELL_USE_IPP == 1 731 IppStatus st = ippsGFpInv(src, dst, param->gf);
732 if(st != ippStsNoErr)
734 printf(
"Error fp_elt_inv: %s\n", ippcpGetStatusString(st));
740 fp_elt_div (fp_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2,
741 const fp_param param, uint8_t stack)
743 MPHELL_ASSERT(
fp_elt_iszero(src2, param) ==
false,
"fp_elt_div : src2 == 0");
764 const fp_param param, uint8_t stack)
766 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 767 #if MPHELL_USE_MONTGOMERY == 1 775 while (m != (block)0)
788 #elif MPHELL_USE_IPP == 1 793 ippsGFpScratchBufferSize(1, 32, param->gf, &sizebuf);
794 Ipp8u * buf = malloc(sizebuf *
sizeof(Ipp8u));
795 IppStatus st = ippsGFpExp(src, tmp, dst, param->gf, buf);
796 if(st != ippStsNoErr)
798 printf(
"Error fp_elt_pow_ui: %s\n", ippcpGetStatusString(st));
807 const fp_param param, uint8_t stack)
809 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 810 #if MPHELL_USE_MONTGOMERY == 1 834 #elif MPHELL_USE_IPP == 1 836 ippsGFpScratchBufferSize(1, (param->size)*32, param->gf, &sizebuf);
837 Ipp8u * buf = malloc(sizebuf *
sizeof(Ipp8u));
838 IppStatus st = ippsGFpExp(src, n, dst, param->gf, buf);
839 if(st != ippStsNoErr)
841 printf(
"Error fp_elt_pow_number: %s\n", ippcpGetStatusString(st));
850 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 852 #elif MPHELL_USE_IPP == 1 855 Ipp32u data[param->size];
856 ippsGFpGetElement(src, data, param->size, param->gf);
857 ippsSet_BN(IppsBigNumPOS, param->size, data, tmp);
958 #if (MPHELL_USE_GMP == 1 || MPHELL_USE_MBEDTLS == 1) 996 MPHELL_ASSERT_ALWAYS(m <= param->p_even,
"fp_elt_sqrt : \ 1001 while (m < param->p_even - 1)
1013 #elif MPHELL_USE_IPP == 1 1014 ippsGFpSqrt(src, dst, param->gf);
1077 block pow = (block)1;
1081 fp_elt b, c1, c2, h, r, d, tmp1;
1136 for(i=1; i<= (s-1); i++)
1217 block prime[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
1246 while(test ==
false);
bool number_isdiff_ui(number_srcptr src1, const block src2)
Test if src1 != src2.
bool number_iszero(number_srcptr src)
Test if src is zero.
int8_t fp_elt_cmp(fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param)
Compare src1 and src2 in Fp.
void number_mod_ui(block *dst, number_srcptr src1, const block src2)
Compute dst such that src1 = q * src2 + dst ; dst < src2.
void number_div_ui(number_ptr dst, number_srcptr src1, const block src2)
Compute dst such that src1 = dst * src2 + r ; r < src2.
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 number_invmod(number_ptr dst, number_srcptr src1, number_srcptr src2)
Compute dst such that dst = src1^(-1) mod src2.
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...
void number_powm_ui(number_ptr dst, number_srcptr src1, const block src2, number_srcptr mod, uint8_t stack)
Set dst to src1^src2 modulo mod.
void fp_elt_free(fp_elt *src)
Free space used by src.
void number_mul_ui(number_ptr dst, number_srcptr src1, const block src2)
Set dst to src1 * src2.
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)
void number_set_ui(number_ptr dst, const block src)
Set dst to src.
enum fp_id_e fp_id
Identifier for known field, use by IPPCP to accelerate the field arithmetic.
bool number_iseven(number_srcptr src)
Test if src is even.
void number_div(number_ptr dst, number_srcptr src1, number_srcptr src2)
Compute dst such that src1 = dst * src2 + r ; r < src2.
uint8_t bits_to_nblock(const uint16_t nbits)
Return the number of blocks required to store a nbits number.
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 redcify(number_ptr dst, number_srcptr src, number_srcptr p, uint8_t stack)
Set dst to redc form dst=B^n*src mod p.
static void fp_elt_sqr(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
Set dst <- src^2.
void number_mul_montgomery(number_ptr dst, number_srcptr src1, number_srcptr src2, number_srcptr p, const block invp, uint8_t stack)
Compute dst such that dst = (src1 * src2) mod(p) into the Montgomery form.
static void fp_elt_relax_pool_elt(fp_elt *dst, const fp_param param, uint8_t stack)
Relax an initialised field element from the pool.
void number_gcd(number_ptr dst, number_srcptr src1, number_srcptr src2)
Set dst to GCD(src1, src2)
void number_random1(number_ptr dst, number_srcptr bound, uint8_t stack)
Set dst to a random number_ptr between 0 and bound, the random process is chosen at the MPHELL initia...
void number_free(number *dst)
Free a number_ptr allocated on the RAM memory (malloc)
void number_divmod_ui(number_ptr q, block *r, number_srcptr src1, const block src2)
Compute (q, r) such that src1 = q * src2 + r ; r < src2.
void fp_create(fp_param param, number_srcptr p, fp_id id, uint8_t stack)
Create a prime field of characteristic p.
bool number_isequal_ui(number_srcptr src1, const block src2)
Test if src1 == src2.
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 fp_get_characteristic(number_ptr c, const fp_param param)
Get the characteristic of the prime field "param".
void fp_free(fp_param param)
Free the space of the prime field informations structure.
void fp_prepare_sqrt(fp_param param, uint8_t stack)
Find a non square residue in FP, factor out p-1 by powers of 2, find Q and S such that p − 1 = Q....
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 number_lshift(number_ptr dst, number_srcptr src, const uint16_t shift)
Set dst to src << shift.
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...
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...
void number_gcd_ui(block *dst, number_srcptr src1, const block src2)
Set dst to GCD(src1, src2)
static void fp_elt_mul(fp_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param, uint8_t stack)
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used ...
static bool fp_elt_iszero(fp_elt_srcptr src, const fp_param param)
Test if src is zero.
block number_and_ui(number_srcptr src1, const block src2, uint8_t stack)
Apply logical bitwise AND operator between src1 and src2.
static void fp_elt_get_pool_elt(fp_elt *dst, const fp_param param, uint8_t stack)
Get an initialised field element from the pool.
void number_copy(number_ptr dst, number_srcptr src)
Copy src into dst.
void number_sqr(number_ptr dst, number_srcptr src)
Set dst to src1^2.
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)
static void fp_elt_neg(fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
Set dst <- (-src) mod p.
void fp_elt_set_zero(fp_elt_ptr dst, const fp_param param)
Set dst to zero.
void number_tmp_free(number *t, const uint8_t size, uint8_t stack)
Free a temporary number.
void number_powm(number_ptr dst, number_srcptr src1, number_srcptr src2, number_srcptr mod, uint8_t stack)
Set dst to src1^src2 modulo mod.
void number_inv_montgomery(number_ptr dst, number_srcptr src, number_srcptr p, const block invp, number_srcptr R2, number_srcptr one, uint8_t stack)
Compute dst such that dst = src^(-1) mod(p) into the Montgomery form.
void fp_copy(fp_param param_res, const fp_param param)
Copy the prime field structure param into param_res.
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 number_dec(number_ptr dst, number_srcptr src)
Set dst to src - 1 if src - 1 fit in dst.
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.
void number_inc(number_ptr dst, number_srcptr src)
Set dst to src + 1 if src + 1 fit in dst.
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 number_add(number_ptr dst, number_srcptr src1, number_srcptr src2)
Set dst to src1 + src2 if src1 + src2 fit in dst.
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.
int8_t number_legendre(number_srcptr src1, number_srcptr src2, uint8_t stack)
Compute the legendre symbole of src1 and src2.
void number_init(number *dst, const uint8_t n)
Allocate a number_ptr on the RAM memory (malloc)
int8_t number_cmp(number_srcptr src1, number_srcptr src2)
Compare src1 and src2.
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.
Declaration of primary field functions, if Montgomery arithmetic is used, the Montgomery arithmetic w...
void fp_elt_print(fp_elt_srcptr src, const uint8_t base, const bool lift, const fp_param param, uint8_t stack)
Print src in base "base".
void number_mod(number_ptr dst, number_srcptr src1, number_srcptr src2)
Compute dst such that src1 = q * src2 + dst ; dst < src2.
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 number_rshift(number_ptr dst, number_srcptr src, const uint16_t shift)
Set dst to src >> shift.
Primary field parameters.
void number_mul_montgomery_block(number_ptr dst, number_srcptr src1, number_srcptr src2, number_srcptr p, const block invp, uint8_t stack)
Compute dst such that dst = (src1 * src2) mod(p) into the Montgomery form, use when SIZ(src1) or SIZ(...
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 fp_elt_primitive_elt(fp_elt_ptr dst, const fp_param param, uint8_t stack)
Find a possible primitive element in the field defined by param.
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 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 number_inv_mod_basis(block *dst, const block src)
Compute dst such that dst * (-src) = -1 mod (2^(BLOCK_SIZE))
int8_t number_cmp_ui(number_srcptr src1, const block src2)
Compare src1 and src2.
void fp_alloc(fp_param param, const uint8_t size)
Allocate space for the prime field informations structure.
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 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.
void number_str(char **str, number_srcptr src, const uint8_t base)
Converts src to string format in base specified by base.
void fp_elt_init(fp_elt_ptr dst, const fp_param param)
Initialise a primary field element.