MPHELL  4.0.0
Typedefs | Enumerations | Functions
mphell-fp.h File Reference

Declaration of primary field functions, if Montgomery arithmetic is used, the Montgomery arithmetic will be used ! More...

#include "mphell-number.h"
Include dependency graph for mphell-fp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef fp_param_tfp_param
 Pointer on a primary field parameters structure.
 
typedef enum fp_id_e fp_id
 Identifier for known field, use by IPPCP to accelerate the field arithmetic.
 

Enumerations

enum  fp_id_e {
  ARBITRARY, P192R1, P224R1, P256R1,
  P384R1, P521R1
}
 Identifier for known field, use by IPPCP to accelerate the field arithmetic. More...
 

Functions

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". More...
 
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. More...
 
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. More...
 
void fp_alloc (fp_param param, const uint8_t size)
 Allocate space for the prime field informations structure. More...
 
void fp_create (fp_param param, number_srcptr p, fp_id id, uint8_t stack)
 Create a prime field of characteristic p. More...
 
void fp_copy (fp_param param_res, const fp_param param)
 Copy the prime field structure param into param_res. More...
 
void fp_free (fp_param param)
 Free the space of the prime field informations structure. More...
 
void fp_get_characteristic (number_ptr c, const fp_param param)
 Get the characteristic of the prime field "param". More...
 
void fp_elt_alloc (fp_elt *dst, const fp_param param)
 Allocate space for a primary field element. More...
 
void fp_elt_init (fp_elt_ptr dst, const fp_param param)
 Initialise a primary field element. More...
 
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. More...
 
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) More...
 
void fp_elt_free (fp_elt *src)
 Free space used by src. More...
 
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) More...
 
void fp_elt_set_zero (fp_elt_ptr dst, const fp_param param)
 Set dst to zero. More...
 
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 Montgomery form. More...
 
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 Montgomery form. More...
 
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 Montgomery form. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
int8_t fp_elt_cmp (fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param)
 Compare src1 and src2 in Fp. More...
 
bool fp_elt_isone (fp_elt_srcptr src, const fp_param param)
 Test if src is one. More...
 
static bool fp_elt_iszero (fp_elt_srcptr src, const fp_param param)
 Test if src is zero. More...
 
static void fp_elt_add (fp_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param)
 Set dst <- src1 + src2. More...
 
static void fp_elt_inc (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- src + 1. More...
 
static void fp_elt_sub (fp_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, const fp_param param)
 Set dst <- src1 - src2. More...
 
static void fp_elt_dec (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- src - 1. More...
 
static void fp_elt_neg (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- (-src) mod p. More...
 
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 ! More...
 
static void fp_elt_mul2 (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- 2 * src. More...
 
static void fp_elt_mul4 (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- 4 * src. More...
 
static void fp_elt_mul8 (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param)
 Set dst <- 8 * src. More...
 
static void fp_elt_mul3 (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
 Set dst <- 3 * src. More...
 
static void fp_elt_sqr (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
 Set dst <- src^2. More...
 
void fp_elt_inv_flt (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
 Set dst <- src^(-1) using Fermat Little Theorem. More...
 
void fp_elt_inv (fp_elt_ptr dst, fp_elt_srcptr src, const fp_param param, uint8_t stack)
 Set dst <- src^(-1) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Declaration of primary field functions, if Montgomery arithmetic is used, the Montgomery arithmetic will be used !

Definition in file mphell-fp.h.

Enumeration Type Documentation

◆ fp_id_e

enum fp_id_e

Identifier for known field, use by IPPCP to accelerate the field arithmetic.

Enumerator
ARBITRARY 

Arbitrary field

P192R1 

Nist prime field use for the curve p192r1

P224R1 

Nist prime field use for the curve p224r1

P256R1 

Nist prime field use for the curve p256r1

P384R1 

Nist prime field use for the curve p384r1

P521R1 

Nist prime field use for the curve p521r1

Definition at line 130 of file mphell-fp.h.

Function Documentation

◆ fp_alloc()

void fp_alloc ( fp_param  param,
const uint8_t  size 
)

Allocate space for the prime field informations structure.

Parameters
paramStructure for the prime field informations to allocate
sizeSize in blocks of the prime field (ex: 4 for a 4 * 64 = 256 bits prime field on a 64 bits architecture)

Definition at line 58 of file mphell-fp.c.

◆ fp_copy()

void fp_copy ( fp_param  param_res,
const fp_param  param 
)

Copy the prime field structure param into param_res.

Parameters
param_resDestination prime field
paramSource prime field

Definition at line 266 of file mphell-fp.c.

◆ fp_create()

void fp_create ( fp_param  param,
number_srcptr  p,
fp_id  id,
uint8_t  stack 
)

Create a prime field of characteristic p.

Parameters
paramInformations structure on prime field to fill (must be allocated)
pCharacteristic of the prime field
idName of the field, use P192R1, P224R1, P256R1, P384R1, P521R1 for the NIST curve, ARBITRARY otherwise.
stackTemporary memory stack to use

Definition at line 126 of file mphell-fp.c.

◆ fp_elt_add()

void fp_elt_add ( fp_elt_ptr  dst,
fp_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp_param  param 
)
inlinestatic

Set dst <- src1 + src2.

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on prime field

Definition at line 514 of file mphell-fp.h.

◆ fp_elt_alloc()

void fp_elt_alloc ( fp_elt *  dst,
const fp_param  param 
)

Allocate space for a primary field element.

Parameters
dstPrimary field element to allocate
paramInformation on prime field

Definition at line 344 of file mphell-fp.c.

◆ fp_elt_clear()

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)

Parameters
srcPrimary field element to free

Definition at line 377 of file mphell-fp.c.

◆ fp_elt_cmp()

int8_t fp_elt_cmp ( fp_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp_param  param 
)

Compare src1 and src2 in Fp.

Parameters
src1Source field element
src2Source field element
paramInformation on prime field
Returns
-1 if src1 < src2
0 if src1 == src2
1 if src1 > src2

Definition at line 631 of file mphell-fp.c.

◆ fp_elt_copy()

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.

Parameters
dstDestination primary field element
srcSource primary field element
paramInformation on prime field

Definition at line 367 of file mphell-fp.c.

◆ fp_elt_cube_root()

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.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 1019 of file mphell-fp.c.

◆ fp_elt_dec()

void fp_elt_dec ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- src - 1.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 596 of file mphell-fp.h.

◆ fp_elt_div()

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.

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 740 of file mphell-fp.c.

◆ fp_elt_free()

void fp_elt_free ( fp_elt *  src)

Free space used by src.

Parameters
srcPrimary field element to free

Definition at line 385 of file mphell-fp.c.

◆ fp_elt_get_number()

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).

Parameters
dstDestination number
srcSource field element (eventually under Montgomery form)
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 522 of file mphell-fp.c.

◆ fp_elt_get_pool_elt()

void fp_elt_get_pool_elt ( fp_elt *  dst,
const fp_param  param,
uint8_t  stack 
)
inlinestatic

Get an initialised field element from the pool.

Parameters
dstAdress of the temporary element to allocate
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 158 of file mphell-fp.h.

◆ fp_elt_inc()

void fp_elt_inc ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- src + 1.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 539 of file mphell-fp.h.

◆ fp_elt_init()

void fp_elt_init ( fp_elt_ptr  dst,
const fp_param  param 
)

Initialise a primary field element.

Parameters
dstPrimary field element to initialise
paramInformation on prime field

Definition at line 357 of file mphell-fp.c.

◆ fp_elt_inv()

void fp_elt_inv ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param,
uint8_t  stack 
)

Set dst <- src^(-1)

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 716 of file mphell-fp.c.

◆ fp_elt_inv_flt()

void fp_elt_inv_flt ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param,
uint8_t  stack 
)

Set dst <- src^(-1) using Fermat Little Theorem.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

◆ fp_elt_isone()

bool fp_elt_isone ( fp_elt_srcptr  src,
const fp_param  param 
)

Test if src is one.

Parameters
srcSource field element
paramInformation on prime field
Returns
true if scr is one, false otherwise

Definition at line 654 of file mphell-fp.c.

◆ fp_elt_ispower_number()

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.

Parameters
srcSource field element
nSource number
paramInformation on prime field
stackTemporary memory stack to use
Returns
2 if all element in Fp are some n-power
1 if src is a n-power in Fp
false otherwise

Definition at line 909 of file mphell-fp.c.

◆ fp_elt_ispower_ui()

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.

Parameters
srcSource field element
nSource block
paramInformation on prime field
stackTemporary memory stack to use
Returns
2 if all element in Fp are some n-power
1 if src is a n-power in Fp
false otherwise

Definition at line 865 of file mphell-fp.c.

◆ fp_elt_issquare()

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.

Parameters
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use
Returns
true if src is a square in Fp, false otherwise

Definition at line 848 of file mphell-fp.c.

◆ fp_elt_iszero()

bool fp_elt_iszero ( fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Test if src is zero.

Parameters
srcSource field element
paramInformation on prime field
Returns
true if scr is zero, false otherwise

Definition at line 462 of file mphell-fp.h.

◆ fp_elt_lift()

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.

Parameters
dstDestination primary field element (in Fp)
srcSource primary field element (under Montgomery form)
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 503 of file mphell-fp.c.

◆ fp_elt_mul()

void fp_elt_mul ( fp_elt_ptr  dst,
fp_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp_param  param,
uint8_t  stack 
)
inlinestatic

Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used !

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 643 of file mphell-fp.h.

◆ fp_elt_mul2()

void fp_elt_mul2 ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- 2 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 665 of file mphell-fp.h.

◆ fp_elt_mul3()

void fp_elt_mul3 ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param,
uint8_t  stack 
)
inlinestatic

Set dst <- 3 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 768 of file mphell-fp.h.

◆ fp_elt_mul4()

void fp_elt_mul4 ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- 4 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 690 of file mphell-fp.h.

◆ fp_elt_mul8()

void fp_elt_mul8 ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- 8 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 728 of file mphell-fp.h.

◆ fp_elt_neg()

void fp_elt_neg ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param 
)
inlinestatic

Set dst <- (-src) mod p.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field

Definition at line 613 of file mphell-fp.h.

◆ fp_elt_pow_number()

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.

Parameters
dstTo store the result
srcSource field element
nSource number
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 806 of file mphell-fp.c.

◆ fp_elt_pow_ui()

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.

Parameters
dstTo store the result
srcSource field element
nSource block
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 763 of file mphell-fp.c.

◆ fp_elt_print()

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".

Parameters
srcField element to print
baseBase to use to write str, can be 2, 10 or 16
liftIf Montgomery arithmetic is used, lift == true -> lift src into Fp (or its coefficients to FP) before conversion
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 40 of file mphell-fp.c.

◆ fp_elt_random()

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.

Parameters
dstDestination primary field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 481 of file mphell-fp.c.

◆ fp_elt_relax_pool_elt()

void fp_elt_relax_pool_elt ( fp_elt *  dst,
const fp_param  param,
uint8_t  stack 
)
inlinestatic

Relax an initialised field element from the pool.

Parameters
dstAdress of the temporary element to free
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 195 of file mphell-fp.h.

◆ fp_elt_set_number()

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 Montgomery form.

Parameters
dstDestination primary field element
srcSource number
isreducedIf Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 433 of file mphell-fp.c.

◆ fp_elt_set_one()

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)

Parameters
dstDestination primary field element (must be allocated)
paramInformation on prime field

Definition at line 394 of file mphell-fp.c.

◆ fp_elt_set_str()

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 Montgomery form.

Parameters
dstDestination primary field element
strSource number under string format in base "base"
baseBase used to write str, can be 2, 10 or 16
isreducedIf Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 455 of file mphell-fp.c.

◆ fp_elt_set_ui()

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 Montgomery form.

Parameters
dstDestination primary field element
srcSource block
isreducedIf Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 415 of file mphell-fp.c.

◆ fp_elt_set_zero()

void fp_elt_set_zero ( fp_elt_ptr  dst,
const fp_param  param 
)

Set dst to zero.

Parameters
dstDestination primary field element (must be allocated)
paramInformation on prime field

Definition at line 404 of file mphell-fp.c.

◆ fp_elt_sqr()

void fp_elt_sqr ( fp_elt_ptr  dst,
fp_elt_srcptr  src,
const fp_param  param,
uint8_t  stack 
)
inlinestatic

Set dst <- src^2.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 806 of file mphell-fp.h.

◆ fp_elt_sqrt()

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.

Parameters
dstTo store the result
srcSource field element
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 956 of file mphell-fp.c.

◆ fp_elt_str()

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.

Parameters
strDestination string, allocated by the function, must be free by the user.
srcSource primary field element (under Montgomery form if Montgomery arithmetic is used)
baseBase to use to write str, can be 2, 10 or 16
liftIf Montgomery arithmetic is used, lift == true -> lift src into Fp before conversion
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 600 of file mphell-fp.c.

◆ fp_elt_sub()

void fp_elt_sub ( fp_elt_ptr  dst,
fp_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp_param  param 
)
inlinestatic

Set dst <- src1 - src2.

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on prime field

Definition at line 557 of file mphell-fp.h.

◆ fp_elt_unity_nth_root()

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.

Parameters
dstTo store the result
nSource block
paramInformation on prime field
stackTemporary memory stack to use

Definition at line 1257 of file mphell-fp.c.

◆ fp_free()

void fp_free ( fp_param  param)

Free the space of the prime field informations structure.

Parameters
paramPrime field informations structure

Definition at line 292 of file mphell-fp.c.

◆ fp_get_characteristic()

void fp_get_characteristic ( number_ptr  c,
const fp_param  param 
)

Get the characteristic of the prime field "param".

Parameters
cDestination number (to store the characteristic)
paramInformation on prime field

Definition at line 332 of file mphell-fp.c.

◆ fp_str()

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.

Parameters
strDestination string, allocated by the function, must be free by the user.
paramInformation on prime field
baseBase to use to write str, can be 2, 10 or 16
stackTemporary memory stack to use

Definition at line 543 of file mphell-fp.c.