MPHELL
4.0.0
|
Declaration of field functions. More...
Go to the source code of this file.
Data Structures | |
struct | field_t |
Define a field. More... | |
Typedefs | |
typedef fp_elt * | field_elt |
Generic field element. | |
typedef fp_elt * | fe_ptr |
Pointer on a field element. | |
typedef const fp_elt * | fe_srcptr |
Pointer on a field element, the field element cannot be modified through this pointer. | |
typedef field_t | field[1] |
Address of a field structure. | |
typedef field_t * | field_ptr |
Address of a field structure, use in all functions. | |
typedef const field_t * | field_srcptr |
Address of a field structure, use in all functions where the parameter is const. | |
Enumerations | |
enum | field_type { FP, FP2, FP3 } |
Define the field type. More... | |
Functions | |
static void | field_elt_get_pool_elt (field_elt *dst, field_ptr k, uint8_t stack) |
Get an initialised field element from the pool. More... | |
static void | field_elt_relax_pool_elt (field_elt *dst, field_ptr k, uint8_t stack) |
Relax an initialised field element from the pool. More... | |
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. More... | |
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. More... | |
void | field_copy (field_ptr k_res, field_srcptr k) |
Copy the field structure param into param_res. More... | |
void | field_free (field_ptr k) |
Free the space of the field informations structure. More... | |
void | field_get_size (number_ptr c, field_srcptr k) |
Get the size of the field "k". More... | |
void | field_get_characteristic (number_ptr c, field_srcptr k) |
Get the charactristic of the field "k". More... | |
void | field_elt_alloc (fe_ptr *dst, field_srcptr k) |
Allocate space for a field element. More... | |
void | field_elt_init (fe_ptr dst, field_srcptr k) |
Initialise the field element. More... | |
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. More... | |
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) More... | |
void | field_elt_free (fe_ptr *src, field_srcptr k) |
Free space used by src. More... | |
void | field_elt_set_one (fe_ptr dst, field_srcptr k) |
Set dst to one (or its Montgomery form if Montgomery arithmetic is used) More... | |
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 Montgomery form. More... | |
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 Montgomery form. More... | |
void | field_elt_set_fp_elts (fe_ptr dst, field_srcptr k, const uint32_t n,...) |
Set dst to src(s) More... | |
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 Montgomery form. More... | |
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. More... | |
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 coefficients). More... | |
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 coefficients). More... | |
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, it is just a copy. More... | |
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. More... | |
void | field_print (field_srcptr k, const uint8_t base, uint8_t stack) |
Print the different fields of the structure pointed by k. More... | |
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. More... | |
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. More... | |
bool | field_isequal (field_srcptr k1, field_srcptr k2) |
Test if k1 and k2 are equals. More... | |
int8_t | field_elt_cmp (fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Compare src1 and src2. More... | |
int8_t | field_elt_cmp_fp_elt (fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Compare src1 and src2. More... | |
bool | field_elt_isone (fe_srcptr src, field_srcptr k) |
Test if src is one. More... | |
static bool | field_elt_iszero (fe_srcptr src, field_srcptr k) |
Test if src is zero. More... | |
static void | field_elt_inc (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- src + 1. More... | |
static void | field_elt_add (fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Set dst <- src1 + src2. More... | |
static void | field_elt_add_fp_elt (fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Set dst <- src1 + src2. More... | |
static void | field_elt_dec (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- src - 1. More... | |
static void | field_elt_sub (fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Set dst <- src1 - src2. More... | |
static void | field_elt_sub_fp_elt (fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k) |
Set dst <- src1 - src2. More... | |
static void | field_elt_neg (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- (-src) More... | |
static void | field_elt_neg_fp_elt (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- (-src) More... | |
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 ! More... | |
static void | field_elt_mul_fp_elt (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 ! More... | |
static void | field_elt_mul2 (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- 2 * src. More... | |
static void | field_elt_mul4 (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- 4 * src. More... | |
static void | field_elt_mul8 (fe_ptr dst, fe_srcptr src, field_srcptr k) |
Set dst <- 8 * src. More... | |
static void | field_elt_mul3 (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- 3 * src. More... | |
static void | field_elt_sqr (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^2. More... | |
static void | field_elt_sqr_fp_elt (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^2. More... | |
void | field_elt_pow_ui (fe_ptr dst, fe_srcptr src, const block n, field_srcptr k, uint8_t stack) |
Set dst <- src^n. More... | |
void | field_elt_pow_number (fe_ptr dst, fe_srcptr src, number_srcptr n, field_srcptr k, uint8_t stack) |
Set dst <- src^n. More... | |
bool | field_elt_issquare (fe_srcptr src, field_srcptr k, uint8_t stack) |
Test if src is a square using the Lengendre symbol. More... | |
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. More... | |
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. More... | |
void | field_find_nonsquare (fe_ptr dst, field_ptr k, uint8_t stack) |
Look for a random non square element in k. More... | |
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. More... | |
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. More... | |
void | field_elt_sqrt (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^(1/2) More... | |
void | field_elt_cube_root (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^(1/3) More... | |
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), 1 otherwise. More... | |
void | field_elt_inv (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^(-1) More... | |
void | field_elt_inv_fp_elt (fe_ptr dst, fe_srcptr src, field_srcptr k, uint8_t stack) |
Set dst <- src^(-1) More... | |
void | field_elt_div (fe_ptr dst, fe_srcptr src1, fe_srcptr src2, field_srcptr k, uint8_t stack) |
Set dst <- src1 / src2. More... | |
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. More... | |
Declaration of field functions.
Definition in file mphell-field.h.
enum field_type |
Define the field type.
Enumerator | |
---|---|
FP | Prime field |
FP2 | Finite field of p^2 element |
FP3 | Finite field of p^3 element |
Definition at line 79 of file mphell-field.h.
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.
k | Structure for the field informations to allocate |
type | Type of field, available fields are FP, FP2 and FP3 |
size | Size in blocks of the field (ex: 4 for a 4 * 64 = 256 bits prime field on a 64 bits architecture) |
base | Base prime field or NULL if k is already a prime field |
Definition at line 37 of file mphell-field.c.
void field_copy | ( | field_ptr | k_res, |
field_srcptr | k | ||
) |
Copy the field structure param into param_res.
k_res | Destination field |
k | Source field |
Definition at line 164 of file mphell-field.c.
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.
k | Informations structure on the field to fill (must be allocated) |
id | Name of the field |
stack | Temporary memory stack to use |
n | Number of arguments that follow (use 1 for FP and 2 for FP2 and FP3) |
... | Characteristic (number) for FP and base field (prime field) and non_residu (field_elt) for FP2 and FP3 |
Definition at line 76 of file mphell-field.c.
|
inlinestatic |
Set dst <- src1 + src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
k | Field |
Definition at line 562 of file mphell-field.h.
|
inlinestatic |
Set dst <- src1 + src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in FP |
k | Field |
Definition at line 589 of file mphell-field.h.
void field_elt_alloc | ( | fe_ptr * | dst, |
field_srcptr | k | ||
) |
Allocate space for a field element.
dst | Field element to allocate |
k | Field |
Definition at line 277 of file mphell-field.c.
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)
src | Field element to clear |
k | Field |
Definition at line 337 of file mphell-field.c.
int8_t field_elt_cmp | ( | fe_srcptr | src1, |
fe_srcptr | src2, | ||
field_srcptr | k | ||
) |
Compare src1 and src2.
src1 | Source field element |
src2 | Source field element |
k | Field |
Definition at line 732 of file mphell-field.c.
int8_t field_elt_cmp_fp_elt | ( | fe_srcptr | src1, |
fe_srcptr | src2, | ||
field_srcptr | k | ||
) |
Compare src1 and src2.
src1 | Source field element |
src2 | Source field element in FP |
k | Field |
Definition at line 753 of file mphell-field.c.
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.
dst | Destination field element |
src | Source field element |
k | Field |
Definition at line 318 of file mphell-field.c.
void field_elt_cube_root | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^(1/3)
dst | To store the result |
src | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1046 of file mphell-field.c.
|
inlinestatic |
Set dst <- src - 1.
dst | To store the result |
src | Source field element |
k | Field |
Definition at line 615 of file mphell-field.h.
void field_elt_div | ( | fe_ptr | dst, |
fe_srcptr | src1, | ||
fe_srcptr | src2, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src1 / src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1193 of file mphell-field.c.
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.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in FP |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1212 of file mphell-field.c.
void field_elt_free | ( | fe_ptr * | src, |
field_srcptr | k | ||
) |
Free space used by src.
src | Field element to free |
k | Field |
Definition at line 356 of file mphell-field.c.
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, it is just a copy.
dst | Destination field element in FP |
src | Source field element |
pos | 1 for FP, 1 or 2 for FP2, 1 or 2 or 3 for FP3 to get the wanted part of the field element. |
k | Field from src |
Definition at line 607 of file mphell-field.c.
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 coefficients).
dst | Destination number |
src | Source field element (eventually under Montgomery form) |
pos | 1 for FP, 1 or 2 for FP2, 1 or 2 or 3 for FP3 to get the wanted part of the field element. |
k | Field |
stack | Temporary memory stack to use |
Definition at line 563 of file mphell-field.c.
Get an initialised field element from the pool.
dst | Address of a field element |
k | Information on the field, k must have been created with field_create. |
stack | Temporary memory stack to use |
Definition at line 134 of file mphell-field.h.
|
inlinestatic |
Set dst <- src + 1.
dst | To store the result |
src | Source field element |
k | Field |
Definition at line 535 of file mphell-field.h.
void field_elt_init | ( | fe_ptr | dst, |
field_srcptr | k | ||
) |
Initialise the field element.
dst | Field element to initialise |
k | Field |
Definition at line 299 of file mphell-field.c.
void field_elt_inv | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^(-1)
dst | To store the result |
src | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1088 of file mphell-field.c.
void field_elt_inv_fp_elt | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^(-1)
dst | To store the result |
src | Source field element in FP |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1107 of file mphell-field.c.
bool field_elt_isone | ( | fe_srcptr | src, |
field_srcptr | k | ||
) |
Test if src is one.
src | Source field element |
k | Field |
Definition at line 774 of file mphell-field.c.
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.
src | Source field element |
n | Source number |
k | Field |
stack | Temporary memory stack to use |
Definition at line 961 of file mphell-field.c.
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.
src | Source field element |
n | Source block |
k | Field |
stack | Temporary memory stack to use |
Definition at line 940 of file mphell-field.c.
bool field_elt_issquare | ( | fe_srcptr | src, |
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Test if src is a square using the Lengendre symbol.
src | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 921 of file mphell-field.c.
|
inlinestatic |
Test if src is zero.
src | Source field element |
k | Field |
Definition at line 504 of file mphell-field.h.
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 coefficients).
dst | Destination field element (in FP or with coefficients in Fp for FP2 and FP3) |
src | Source field element (eventually under Montgomery form) |
k | Field |
stack | Temporary memory stack to use |
Definition at line 544 of file mphell-field.c.
|
inlinestatic |
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used !
dst | To store the result |
src1 | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
src2 | Source field element, can be of the same type than dst (FP, FP2, FP3) or FP. |
k | Field |
stack | Temporary memory stack to use |
Definition at line 753 of file mphell-field.h.
|
inlinestatic |
Set dst <- 2 * src.
dst | To store the result |
src | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
k | Field |
Definition at line 807 of file mphell-field.h.
|
inlinestatic |
Set dst <- 3 * src.
dst | To store the result |
src | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
k | Field |
stack | Temporary memory stack to use |
Definition at line 886 of file mphell-field.h.
|
inlinestatic |
Set dst <- 4 * src.
dst | To store the result |
src | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
k | Field |
Definition at line 833 of file mphell-field.h.
|
inlinestatic |
Set dst <- 8 * src.
dst | To store the result |
src | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
k | Field |
Definition at line 859 of file mphell-field.h.
|
inlinestatic |
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used !
dst | To store the result |
src1 | Source field element, must be of the same type than dst (FP, FP2 or FP3) |
src2 | Source field element in FP. |
k | Field |
stack | Temporary memory stack to use |
Definition at line 781 of file mphell-field.h.
|
inlinestatic |
Set dst <- (-src)
dst | To store the result |
src | Source field element |
k | Field |
Definition at line 695 of file mphell-field.h.
|
inlinestatic |
Set dst <- (-src)
dst | To store the result |
src | Source field element in FP |
k | Field |
Definition at line 721 of file mphell-field.h.
void field_elt_pow_number | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
number_srcptr | n, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^n.
dst | To store the result |
src | Source field element |
n | Source number |
k | Field |
stack | Temporary memory stack to use |
Definition at line 902 of file mphell-field.c.
void field_elt_pow_ui | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
const block | n, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^n.
dst | To store the result |
src | Source field element |
n | Source block |
k | Field |
stack | Temporary memory stack to use |
Definition at line 883 of file mphell-field.c.
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.
src | Source field element (under Montgomery form if Montgomery arithmetic is used) |
base | Base to use to write str, can be 2, 10 or 16 |
lift | If Montgomery arithmetic is used, lift == true -> lift src into Fp (or its coefficients to FP) before conversion |
k | Field |
stack | Temporary memory stack to use |
Definition at line 721 of file mphell-field.c.
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.
dst | Destination field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 525 of file mphell-field.c.
Relax an initialised field element from the pool.
dst | Address of a field element |
k | Information on the field, k must have been created with field_create. |
stack | Temporary memory stack to use |
Definition at line 167 of file mphell-field.h.
void field_elt_set_fp_elts | ( | fe_ptr | dst, |
field_srcptr | k, | ||
const uint32_t | n, | ||
... | |||
) |
Set dst to src(s)
dst | Destination field element |
k | Field |
n | Number of arguments that follow (use 1 for FP, 1 or 2 for FP2 and 1 or 3 FP3) |
... | fp_elt for FP, coefficients of the polynomial for FP2 and FP3 |
Definition at line 460 of file mphell-field.c.
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 Montgomery form.
dst | Destination field element |
isreduced | If Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy |
k | Field |
stack | Temporary memory stack to use |
n | Number of arguments that follow (use 1 for FP, 1 or 2 for FP2 and 1 or 3 FP3) |
... | Number for FP, coefficients of the polynomial for FP2 and FP3 |
Definition at line 415 of file mphell-field.c.
void field_elt_set_one | ( | fe_ptr | dst, |
field_srcptr | k | ||
) |
Set dst to one (or its Montgomery form if Montgomery arithmetic is used)
dst | Destination field element (must be allocated) |
k | Field |
Definition at line 376 of file mphell-field.c.
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 Montgomery form.
dst | Destination field element |
str | Source number under string format in base "base". If FP2 or FP3 is use the polynomials coefficients are given separated by a "," without space. |
base | Base used to write str, can be 2, 10 or 16 |
isreduced | If Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy |
k | Field |
stack | Temporary memory stack to use |
Definition at line 505 of file mphell-field.c.
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 Montgomery form.
dst | Destination field element |
src | Source block |
isreduced | If Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy |
k | Field |
stack | Temporary memory stack to use |
Definition at line 395 of file mphell-field.c.
|
inlinestatic |
Set dst <- src^2.
dst | To store the result |
src | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 913 of file mphell-field.h.
|
inlinestatic |
Set dst <- src^2.
dst | To store the result |
src | Source field element in FP |
k | Field |
stack | Temporary memory stack to use |
Definition at line 940 of file mphell-field.h.
void field_elt_sqrt | ( | fe_ptr | dst, |
fe_srcptr | src, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set dst <- src^(1/2)
dst | To store the result |
src | Source field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1025 of file mphell-field.c.
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.
str | Destination string, allocated by the function, must be free by the user. |
src | Source field element (under Montgomery form if Montgomery arithmetic is used) |
base | Base to use to write str, can be 2, 10 or 16 |
lift | If Montgomery arithmetic is used, lift == true -> lift src into Fp (or its coefficients to FP) before conversion |
k | Field |
stack | Temporary memory stack to use |
Definition at line 691 of file mphell-field.c.
|
inlinestatic |
Set dst <- src1 - src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
k | Field |
Definition at line 642 of file mphell-field.h.
|
inlinestatic |
Set dst <- src1 - src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in FP |
k | Field |
Definition at line 669 of file mphell-field.h.
Set dst to a non trivial n-th root of unity if it exists (ie n divides order(k)-1), 1 otherwise.
dst | To store the result |
n | Source block |
param | Field |
stack | Temporary memory stack to use |
Definition at line 1067 of file mphell-field.c.
Look for a random non n-power element in k.
dst | Destination field element |
n | Source number |
k | Field |
stack | Temporary memory stack to use |
Definition at line 1008 of file mphell-field.c.
Look for a random non n-power element in k.
dst | Destination field element |
n | Source block |
k | Field |
stack | Temporary memory stack to use |
Definition at line 991 of file mphell-field.c.
Look for a random non square element in k.
dst | Destination field element |
k | Field |
stack | Temporary memory stack to use |
Definition at line 982 of file mphell-field.c.
void field_free | ( | field_ptr | k | ) |
Free the space of the field informations structure.
k | Field informations structure |
Definition at line 183 of file mphell-field.c.
void field_get_characteristic | ( | number_ptr | c, |
field_srcptr | k | ||
) |
Get the charactristic of the field "k".
c | Destination number (to store the characteristic) |
k | Field |
Definition at line 239 of file mphell-field.c.
void field_get_size | ( | number_ptr | c, |
field_srcptr | k | ||
) |
Get the size of the field "k".
c | Destination number (to store the characteristic) |
k | Field |
Definition at line 220 of file mphell-field.c.
bool field_isequal | ( | field_srcptr | k1, |
field_srcptr | k2 | ||
) |
Test if k1 and k2 are equals.
k1 | Field |
k2 | Field |
Definition at line 797 of file mphell-field.c.
void field_print | ( | field_srcptr | k, |
const uint8_t | base, | ||
uint8_t | stack | ||
) |
Print the different fields of the structure pointed by k.
k | Field |
base | Base to use to print k, can be 2, 10 or 16 |
stack | Temporary memory stack to use |
Definition at line 682 of file mphell-field.c.
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.
str | Destination string, allocated by the function, must be free by the user. |
k | Field |
base | Base to use to write str, can be 2, 10 or 16 |
stack | Temporary memory stack to use |
Definition at line 651 of file mphell-field.c.