MPHELL
4.0.0
|
Declaration of binary field (finite field constructed with an irreducible polynomial of degree 2) functions. More...
#include "mphell-fp.h"
Go to the source code of this file.
Data Structures | |
struct | fp2_elt_t |
Quadratic extension field element structure. More... | |
struct | fp2_param_t |
Quadratic extension field structure. More... | |
Typedefs | |
typedef fp2_elt_t | fp2_elt |
Quadratic extension field element structure. | |
typedef fp2_elt_t * | fp2_elt_ptr |
Define fp2_elt_ptr, use in all functions. | |
typedef const fp2_elt_t * | fp2_elt_srcptr |
Define fp2_elt_srcptr, use in all functions where the parameter is const. | |
typedef fp2_param_t * | fp2_param |
Pointer on a quadratic extension field structure. | |
Functions | |
void | fp2_elt_get_pool_elt (fp2_elt *dst, const fp2_param param, uint8_t stack) |
Allocate and initialise space for a temporary quadratic extension field element. More... | |
void | fp2_elt_relax_pool_elt (fp2_elt *dst, const fp2_param param, uint8_t stack) |
Free space of a temporary quadratic extension field element. More... | |
void | fp2_alloc (fp2_param param, const fp_param base) |
Allocate space for the quadratic extension field informations structure. More... | |
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. More... | |
void | fp2_copy (fp2_param param_res, const fp2_param param) |
Copy the quadratic extension field structure param into param_res. More... | |
void | fp2_free (fp2_param param) |
Free the space of the quadratic extension field informations structure. More... | |
void | fp2_get_characteristic (number_ptr c, const fp2_param param) |
Get the characteristic of the quadratic extension field "param". More... | |
void | fp2_get_size (number_ptr c, const fp2_param param) |
Get the size of the quadratic extension field "param". More... | |
void | fp2_elt_alloc (fp2_elt *dst, const fp2_param param) |
Allocate space for a quadratic extension field element. More... | |
void | fp2_elt_init (fp2_elt_ptr dst, const fp2_param param) |
Initialise a quadratic extension field element. More... | |
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. More... | |
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) More... | |
void | fp2_elt_free (fp2_elt *src) |
Free space used by src. More... | |
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) More... | |
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 Montgomery form. More... | |
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 Montgomery form. More... | |
void | fp2_elt_set_fp_elt (fp2_elt_ptr dst, fp_elt_srcptr src, const fp2_param param) |
Set dst to src. More... | |
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 its Montgomery form. More... | |
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. More... | |
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 Montgomery form. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int8_t | fp2_elt_cmp (fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param) |
Compare src1 and src2 in FP2. More... | |
bool | fp2_elt_isone (fp2_elt_srcptr src, const fp2_param param) |
Test if src is one. More... | |
bool | fp2_elt_iszero (fp2_elt_srcptr src, const fp2_param param) |
Test if src is zero. More... | |
void | fp2_elt_inc (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- src + 1. More... | |
void | fp2_elt_add_fp_elt (fp2_elt_ptr dst, fp2_elt_srcptr src1, fp_elt_srcptr src2, const fp2_param param) |
Set dst <- src1 + src2. More... | |
void | fp2_elt_add (fp2_elt_ptr dst, fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param) |
Set dst <- src1 + src2. More... | |
void | fp2_elt_dec (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- src - 1. More... | |
void | fp2_elt_sub_fp_elt (fp2_elt_ptr dst, fp2_elt_srcptr src1, fp_elt_srcptr src2, const fp2_param param) |
Set dst <- src1 - src2. More... | |
void | fp2_elt_sub (fp2_elt_ptr dst, fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param) |
Set dst <- src1 - src2. More... | |
void | fp2_elt_neg_fp_elt (fp2_elt_ptr dst, fp_elt_srcptr src, const fp2_param param) |
Set dst <- (-src) More... | |
void | fp2_elt_neg (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- (-src) More... | |
void | fp2_elt_mul_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, if Montgomery arithmetic is used, the Montgomery multiplication will be used ! More... | |
void | fp2_elt_mul2 (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- 2 * src. More... | |
void | fp2_elt_mul4 (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- 4 * src. More... | |
void | fp2_elt_mul8 (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param) |
Set dst <- 8 * src. More... | |
void | fp2_elt_mul3 (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack) |
Set dst <- 3 * src. More... | |
void | fp2_elt_mul (fp2_elt_ptr dst, fp2_elt_srcptr src1, fp2_elt_srcptr src2, const fp2_param param, uint8_t stack) |
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used ! More... | |
void | fp2_elt_sqr_fp_elt (fp2_elt_ptr dst, fp_elt_srcptr src, const fp2_param param, uint8_t stack) |
Set dst <- src^2. More... | |
void | fp2_elt_sqr (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack) |
Set dst <- src^2. More... | |
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) More... | |
void | fp2_elt_inv (fp2_elt_ptr dst, fp2_elt_srcptr src, const fp2_param param, uint8_t stack) |
Set dst <- src^(-1) More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 LUNDSGAARD HANSEN. More... | |
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 VAGN LUNDSGAARD HANSEN. More... | |
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 VAGN LUNDSGAARD HANSEN. More... | |
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. More... | |
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) More... | |
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. More... | |
Declaration of binary field (finite field constructed with an irreducible polynomial of degree 2) functions.
Definition in file mphell-fp2.h.
Allocate space for the quadratic extension field informations structure.
param | Structure for the quadratic extension field informations to allocate |
base | Base prime field |
Definition at line 67 of file mphell-fp2.c.
Copy the quadratic extension field structure param into param_res.
param_res | Destination quadratic extension field |
param | Source quadratic extension field |
Definition at line 125 of file mphell-fp2.c.
Create a quadratic extension of the field base.
param | Informations structure on quadratic extension field to fill (must be allocated) |
base | Base prime field |
non_residue | Non quadratic residue |
stack | Temporary memory stack to use |
Definition at line 106 of file mphell-fp2.c.
void fp2_elt_add | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src1, | ||
fp2_elt_srcptr | src2, | ||
const fp2_param | param | ||
) |
Set dst <- src1 + src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
param | Information on the quadratic extension field |
Definition at line 364 of file mphell-fp2.c.
void fp2_elt_add_fp_elt | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src1, | ||
fp_elt_srcptr | src2, | ||
const fp2_param | param | ||
) |
Set dst <- src1 + src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in the prime field |
param | Information on the quadratic extension field |
Definition at line 356 of file mphell-fp2.c.
Allocate space for a quadratic extension field element.
dst | Quadratic extension field element to allocate |
param | Information on quadratic extension field |
Definition at line 162 of file mphell-fp2.c.
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)
src | Quadratic extension field element to clear |
Definition at line 183 of file mphell-fp2.c.
int8_t fp2_elt_cmp | ( | fp2_elt_srcptr | src1, |
fp2_elt_srcptr | src2, | ||
const fp2_param | param | ||
) |
Compare src1 and src2 in FP2.
src1 | Source field element in FP2 |
src2 | Source field element in FP2 |
param | Information on the quadratic extension field |
Definition at line 321 of file mphell-fp2.c.
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.
src1 | Source field element in FP2 |
src2 | Source number_ptr in FP |
param | Information on the quadratic extension field |
Definition at line 311 of file mphell-fp2.c.
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.
dst | Destination quadratic extension field element |
src | Source quadratic extension field element |
param | Information on quadratic extension field |
Definition at line 176 of file mphell-fp2.c.
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)
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 819 of file mphell-fp2.c.
void fp2_elt_dec | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- src - 1.
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
Definition at line 372 of file mphell-fp2.c.
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.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 543 of file mphell-fp2.c.
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.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in the prime field |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 532 of file mphell-fp2.c.
void fp2_elt_free | ( | fp2_elt * | src | ) |
Free space used by src.
src | Quadratic extension field element to free |
Definition at line 190 of file mphell-fp2.c.
Allocate and initialise space for a temporary quadratic extension field element.
dst | Temporary element to allocate |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 51 of file mphell-fp2.c.
void fp2_elt_inc | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- src + 1.
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
Definition at line 349 of file mphell-fp2.c.
void fp2_elt_init | ( | fp2_elt_ptr | dst, |
const fp2_param | param | ||
) |
Initialise a quadratic extension field element.
dst | Quadratic extension field element to initialise |
param | Information on quadratic extension field |
Definition at line 169 of file mphell-fp2.c.
void fp2_elt_inv | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param, | ||
uint8_t | stack | ||
) |
Set dst <- src^(-1)
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 508 of file mphell-fp2.c.
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)
dst | To store the result |
src | Source field element in the prime field |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 501 of file mphell-fp2.c.
bool fp2_elt_isone | ( | fp2_elt_srcptr | src, |
const fp2_param | param | ||
) |
Test if src is one.
src | Source field element |
param | Information on the quadratic extension field |
Definition at line 335 of file mphell-fp2.c.
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 VAGN LUNDSGAARD HANSEN.
src | Source field element |
n | Source number |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 675 of file mphell-fp2.c.
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 VAGN LUNDSGAARD HANSEN.
src | Source field element |
n | Source block |
stack | Temporary memory stack to use |
param | Information on the quadratic extension field |
Definition at line 634 of file mphell-fp2.c.
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 LUNDSGAARD HANSEN.
src | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 616 of file mphell-fp2.c.
bool fp2_elt_iszero | ( | fp2_elt_srcptr | src, |
const fp2_param | param | ||
) |
Test if src is zero.
src | Source field element |
param | Information on the quadratic extension field |
Definition at line 341 of file mphell-fp2.c.
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.
dst | Destination primary field element (in FP) |
src | Source quadratic extension field element (under Montgomery form) |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 267 of file mphell-fp2.c.
void fp2_elt_mul | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src1, | ||
fp2_elt_srcptr | src2, | ||
const fp2_param | param, | ||
uint8_t | stack | ||
) |
Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used !
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
param | Information the quadratic extension prime field |
stack | Temporary memory stack to use |
Definition at line 451 of file mphell-fp2.c.
void fp2_elt_mul2 | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- 2 * src.
dst | To store the result |
src | Source field element |
param | Information the quadratic extension prime field |
Definition at line 419 of file mphell-fp2.c.
void fp2_elt_mul3 | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param, | ||
uint8_t | stack | ||
) |
Set dst <- 3 * src.
dst | To store the result |
src | Source field element |
param | Information the quadratic extension prime field |
stack | Temporary memory stack to use |
Definition at line 443 of file mphell-fp2.c.
void fp2_elt_mul4 | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- 4 * src.
dst | To store the result |
src | Source field element |
param | Information the quadratic extension prime field |
Definition at line 427 of file mphell-fp2.c.
void fp2_elt_mul8 | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- 8 * src.
dst | To store the result |
src | Source field element |
param | Information the quadratic extension prime field |
Definition at line 435 of file mphell-fp2.c.
void fp2_elt_mul_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, if Montgomery arithmetic is used, the Montgomery multiplication will be used !
dst | To store the result |
src1 | Source field element |
src2 | Source field element in the prime field |
param | Information the quadratic extension prime field |
stack | Temporary memory stack to use |
Definition at line 411 of file mphell-fp2.c.
void fp2_elt_neg | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- (-src)
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
Definition at line 402 of file mphell-fp2.c.
void fp2_elt_neg_fp_elt | ( | fp2_elt_ptr | dst, |
fp_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst <- (-src)
dst | To store the result |
src | Source field element in the prime field |
param | Information on the quadratic extension field |
Definition at line 395 of file mphell-fp2.c.
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.
dst | To store the result |
src | Source field element |
n | Source number |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 577 of file mphell-fp2.c.
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.
dst | To store the result |
src | Source field element |
n | Source block |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 554 of file mphell-fp2.c.
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.
dst | Destination quadratic extension field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 260 of file mphell-fp2.c.
Free space of a temporary quadratic extension field element.
dst | Temporary element to free |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 58 of file mphell-fp2.c.
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 its Montgomery form.
dst | Destination quadratic extension field element |
src1 | Source number |
src2 | Source number |
isreduced | If Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 227 of file mphell-fp2.c.
void fp2_elt_set_fp_elt | ( | fp2_elt_ptr | dst, |
fp_elt_srcptr | src, | ||
const fp2_param | param | ||
) |
Set dst to src.
dst | Destination quadratic extension field element |
src | Source fp_elt |
param | Information on the quadratic extension field |
Definition at line 220 of file mphell-fp2.c.
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.
dst | Destination quadratic extension field element |
src1 | Source fp_elt |
src2 | Source fp_elt |
param | Information on the quadratic extension field |
Definition at line 235 of file mphell-fp2.c.
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 Montgomery form.
dst | Destination quadratic extension field element |
src | Source number |
isreduced | If Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 212 of file mphell-fp2.c.
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)
dst | Destination quadratic extension field element (must be allocated) |
param | Information on the quadratic extension field |
Definition at line 197 of file mphell-fp2.c.
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 Montgomery form.
dst | Destination quadratic extension field element |
str | Source polynomial coefficient under string format in base "base", separated by a "," without space. ex: "123,456" will create the polynomial 123 + 456.X |
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 |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 242 of file mphell-fp2.c.
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 Montgomery form.
dst | Destination quadratic extension 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 |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 204 of file mphell-fp2.c.
void fp2_elt_sqr | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src, | ||
const fp2_param | param, | ||
uint8_t | stack | ||
) |
Set dst <- src^2.
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 495 of file mphell-fp2.c.
void fp2_elt_sqr_fp_elt | ( | fp2_elt_ptr | dst, |
fp_elt_srcptr | src, | ||
const fp2_param | param, | ||
uint8_t | stack | ||
) |
Set dst <- src^2.
dst | To store the result |
src | Source field element in the prime field |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 483 of file mphell-fp2.c.
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.
dst | To store the result |
src | Source field element |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 742 of file mphell-fp2.c.
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.
str | Destination string, allocated by the function, must be free by the user. Polynomial coefficient are written separated by ",". ex: 123 + 456.X will be written as "123,456" |
src | Source quadratic extension 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 FP2 before conversion |
param | Information on the quadratic extension field |
stack | Temporary memory stack to use |
Definition at line 294 of file mphell-fp2.c.
void fp2_elt_sub | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src1, | ||
fp2_elt_srcptr | src2, | ||
const fp2_param | param | ||
) |
Set dst <- src1 - src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element |
param | Information on the quadratic extension field |
Definition at line 387 of file mphell-fp2.c.
void fp2_elt_sub_fp_elt | ( | fp2_elt_ptr | dst, |
fp2_elt_srcptr | src1, | ||
fp_elt_srcptr | src2, | ||
const fp2_param | param | ||
) |
Set dst <- src1 - src2.
dst | To store the result |
src1 | Source field element |
src2 | Source field element in the prime field |
param | Information on the quadratic extension field |
Definition at line 379 of file mphell-fp2.c.
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.
dst | To store the result |
n | Source block |
param | Information on prime field |
stack | Temporary memory stack to use |
Definition at line 1007 of file mphell-fp2.c.
void fp2_free | ( | fp2_param | param | ) |
Free the space of the quadratic extension field informations structure.
param | Quadratic extension field informations structure |
Definition at line 133 of file mphell-fp2.c.
void fp2_get_characteristic | ( | number_ptr | c, |
const fp2_param | param | ||
) |
Get the characteristic of the quadratic extension field "param".
c | Destination number_ptr (to store the characteristic) |
param | Information on quadratic extension field |
Definition at line 144 of file mphell-fp2.c.
void fp2_get_size | ( | number_ptr | c, |
const fp2_param | param | ||
) |
Get the size of the quadratic extension field "param".
c | Destination number_ptr (to store the characteristic) |
param | Information on quadratic extension field |
Definition at line 150 of file mphell-fp2.c.
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.
str | Destination string, allocated by the function, must be free by the user. |
param | Information on the quadratic extension field |
base | Base to use to write str, can be 2, 10 or 16 |
stack | Temporary memory stack to use |
Definition at line 274 of file mphell-fp2.c.