MPHELL  4.0.0
Data Structures | Typedefs | Functions
mphell-fp2.h File Reference

Declaration of binary field (finite field constructed with an irreducible polynomial of degree 2) functions. More...

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

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_tfp2_elt_ptr
 Define fp2_elt_ptr, use in all functions.
 
typedef const fp2_elt_tfp2_elt_srcptr
 Define fp2_elt_srcptr, use in all functions where the parameter is const.
 
typedef fp2_param_tfp2_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...
 

Detailed Description

Declaration of binary field (finite field constructed with an irreducible polynomial of degree 2) functions.

Definition in file mphell-fp2.h.

Function Documentation

◆ fp2_alloc()

void fp2_alloc ( fp2_param  param,
const fp_param  base 
)

Allocate space for the quadratic extension field informations structure.

Parameters
paramStructure for the quadratic extension field informations to allocate
baseBase prime field

Definition at line 67 of file mphell-fp2.c.

◆ fp2_copy()

void fp2_copy ( fp2_param  param_res,
const fp2_param  param 
)

Copy the quadratic extension field structure param into param_res.

Parameters
param_resDestination quadratic extension field
paramSource quadratic extension field

Definition at line 125 of file mphell-fp2.c.

◆ fp2_create()

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.

Parameters
paramInformations structure on quadratic extension field to fill (must be allocated)
baseBase prime field
non_residueNon quadratic residue
stackTemporary memory stack to use

Definition at line 106 of file mphell-fp2.c.

◆ fp2_elt_add()

void fp2_elt_add ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src1,
fp2_elt_srcptr  src2,
const fp2_param  param 
)

Set dst <- src1 + src2.

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on the quadratic extension field

Definition at line 364 of file mphell-fp2.c.

◆ fp2_elt_add_fp_elt()

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.

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

Definition at line 356 of file mphell-fp2.c.

◆ fp2_elt_alloc()

void fp2_elt_alloc ( fp2_elt dst,
const fp2_param  param 
)

Allocate space for a quadratic extension field element.

Parameters
dstQuadratic extension field element to allocate
paramInformation on quadratic extension field

Definition at line 162 of file mphell-fp2.c.

◆ fp2_elt_clear()

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)

Parameters
srcQuadratic extension field element to clear

Definition at line 183 of file mphell-fp2.c.

◆ fp2_elt_cmp()

int8_t fp2_elt_cmp ( fp2_elt_srcptr  src1,
fp2_elt_srcptr  src2,
const fp2_param  param 
)

Compare src1 and src2 in FP2.

Parameters
src1Source field element in FP2
src2Source field element in FP2
paramInformation on the quadratic extension field
Returns
-1 if src1 < src2
0 if src1 == src2
1 if src1 > src2

Definition at line 321 of file mphell-fp2.c.

◆ fp2_elt_cmp_fp_elt()

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.

Parameters
src1Source field element in FP2
src2Source number_ptr in FP
paramInformation on the quadratic extension field
Returns
-1 if src1 < src2
0 if src1 == src2
1 if src1 > src2

Definition at line 311 of file mphell-fp2.c.

◆ fp2_elt_copy()

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.

Parameters
dstDestination quadratic extension field element
srcSource quadratic extension field element
paramInformation on quadratic extension field

Definition at line 176 of file mphell-fp2.c.

◆ fp2_elt_cube_root()

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)

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

Definition at line 819 of file mphell-fp2.c.

◆ fp2_elt_dec()

void fp2_elt_dec ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- src - 1.

Parameters
dstTo store the result
srcSource field element
paramInformation on the quadratic extension field

Definition at line 372 of file mphell-fp2.c.

◆ fp2_elt_div()

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.

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

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

◆ fp2_elt_div_fp_elt()

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.

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

Definition at line 532 of file mphell-fp2.c.

◆ fp2_elt_free()

void fp2_elt_free ( fp2_elt src)

Free space used by src.

Parameters
srcQuadratic extension field element to free

Definition at line 190 of file mphell-fp2.c.

◆ fp2_elt_get_pool_elt()

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.

Parameters
dstTemporary element to allocate
paramInformation on the quadratic extension field
stackTemporary memory stack to use

Definition at line 51 of file mphell-fp2.c.

◆ fp2_elt_inc()

void fp2_elt_inc ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- src + 1.

Parameters
dstTo store the result
srcSource field element
paramInformation on the quadratic extension field

Definition at line 349 of file mphell-fp2.c.

◆ fp2_elt_init()

void fp2_elt_init ( fp2_elt_ptr  dst,
const fp2_param  param 
)

Initialise a quadratic extension field element.

Parameters
dstQuadratic extension field element to initialise
paramInformation on quadratic extension field

Definition at line 169 of file mphell-fp2.c.

◆ fp2_elt_inv()

void fp2_elt_inv ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param,
uint8_t  stack 
)

Set dst <- src^(-1)

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

Definition at line 508 of file mphell-fp2.c.

◆ fp2_elt_inv_fp_elt()

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)

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

Definition at line 501 of file mphell-fp2.c.

◆ fp2_elt_isone()

bool fp2_elt_isone ( fp2_elt_srcptr  src,
const fp2_param  param 
)

Test if src is one.

Parameters
srcSource field element
paramInformation on the quadratic extension field
Returns
true if scr is one, false otherwise

Definition at line 335 of file mphell-fp2.c.

◆ fp2_elt_ispower_number()

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.

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

Definition at line 675 of file mphell-fp2.c.

◆ fp2_elt_ispower_ui()

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.

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

Definition at line 634 of file mphell-fp2.c.

◆ fp2_elt_issquare()

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.

Parameters
srcSource field element
paramInformation on the quadratic extension field
stackTemporary memory stack to use
Returns
true if src is a square in Fp2, false otherwise

Definition at line 616 of file mphell-fp2.c.

◆ fp2_elt_iszero()

bool fp2_elt_iszero ( fp2_elt_srcptr  src,
const fp2_param  param 
)

Test if src is zero.

Parameters
srcSource field element
paramInformation on the quadratic extension field
Returns
true if scr is zero, false otherwise

Definition at line 341 of file mphell-fp2.c.

◆ fp2_elt_lift()

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.

Parameters
dstDestination primary field element (in FP)
srcSource quadratic extension field element (under Montgomery form)
paramInformation on the quadratic extension field
stackTemporary memory stack to use

Definition at line 267 of file mphell-fp2.c.

◆ fp2_elt_mul()

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 !

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

Definition at line 451 of file mphell-fp2.c.

◆ fp2_elt_mul2()

void fp2_elt_mul2 ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- 2 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation the quadratic extension prime field

Definition at line 419 of file mphell-fp2.c.

◆ fp2_elt_mul3()

void fp2_elt_mul3 ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param,
uint8_t  stack 
)

Set dst <- 3 * src.

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

Definition at line 443 of file mphell-fp2.c.

◆ fp2_elt_mul4()

void fp2_elt_mul4 ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- 4 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation the quadratic extension prime field

Definition at line 427 of file mphell-fp2.c.

◆ fp2_elt_mul8()

void fp2_elt_mul8 ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- 8 * src.

Parameters
dstTo store the result
srcSource field element
paramInformation the quadratic extension prime field

Definition at line 435 of file mphell-fp2.c.

◆ fp2_elt_mul_fp_elt()

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 !

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

Definition at line 411 of file mphell-fp2.c.

◆ fp2_elt_neg()

void fp2_elt_neg ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- (-src)

Parameters
dstTo store the result
srcSource field element
paramInformation on the quadratic extension field

Definition at line 402 of file mphell-fp2.c.

◆ fp2_elt_neg_fp_elt()

void fp2_elt_neg_fp_elt ( fp2_elt_ptr  dst,
fp_elt_srcptr  src,
const fp2_param  param 
)

Set dst <- (-src)

Parameters
dstTo store the result
srcSource field element in the prime field
paramInformation on the quadratic extension field

Definition at line 395 of file mphell-fp2.c.

◆ fp2_elt_pow_number()

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.

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

Definition at line 577 of file mphell-fp2.c.

◆ fp2_elt_pow_ui()

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.

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

Definition at line 554 of file mphell-fp2.c.

◆ fp2_elt_random()

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.

Parameters
dstDestination quadratic extension field element
paramInformation on the quadratic extension field
stackTemporary memory stack to use

Definition at line 260 of file mphell-fp2.c.

◆ fp2_elt_relax_pool_elt()

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.

Parameters
dstTemporary element to free
paramInformation on the quadratic extension field
stackTemporary memory stack to use

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

◆ fp2_elt_set()

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.

Parameters
dstDestination quadratic extension field element
src1Source number
src2Source number
isreducedIf Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form, is_reduced == true -> simple copy
paramInformation on the quadratic extension field
stackTemporary memory stack to use

Definition at line 227 of file mphell-fp2.c.

◆ fp2_elt_set_fp_elt()

void fp2_elt_set_fp_elt ( fp2_elt_ptr  dst,
fp_elt_srcptr  src,
const fp2_param  param 
)

Set dst to src.

Parameters
dstDestination quadratic extension field element
srcSource fp_elt
paramInformation on the quadratic extension field

Definition at line 220 of file mphell-fp2.c.

◆ fp2_elt_set_fp_elts()

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.

Parameters
dstDestination quadratic extension field element
src1Source fp_elt
src2Source fp_elt
paramInformation on the quadratic extension field

Definition at line 235 of file mphell-fp2.c.

◆ fp2_elt_set_number()

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.

Parameters
dstDestination quadratic extension 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 the quadratic extension field
stackTemporary memory stack to use

Definition at line 212 of file mphell-fp2.c.

◆ fp2_elt_set_one()

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)

Parameters
dstDestination quadratic extension field element (must be allocated)
paramInformation on the quadratic extension field

Definition at line 197 of file mphell-fp2.c.

◆ fp2_elt_set_str()

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.

Parameters
dstDestination quadratic extension field element
strSource polynomial coefficient under string format in base "base", separated by a "," without space. ex: "123,456" will create the polynomial 123 + 456.X
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 the quadratic extension field
stackTemporary memory stack to use

Definition at line 242 of file mphell-fp2.c.

◆ fp2_elt_set_ui()

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.

Parameters
dstDestination quadratic extension 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 the quadratic extension field
stackTemporary memory stack to use

Definition at line 204 of file mphell-fp2.c.

◆ fp2_elt_sqr()

void fp2_elt_sqr ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src,
const fp2_param  param,
uint8_t  stack 
)

Set dst <- src^2.

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

Definition at line 495 of file mphell-fp2.c.

◆ fp2_elt_sqr_fp_elt()

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.

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

Definition at line 483 of file mphell-fp2.c.

◆ fp2_elt_sqrt()

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.

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

Definition at line 742 of file mphell-fp2.c.

◆ fp2_elt_str()

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.

Parameters
strDestination 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"
srcSource quadratic extension 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 FP2 before conversion
paramInformation on the quadratic extension field
stackTemporary memory stack to use

Definition at line 294 of file mphell-fp2.c.

◆ fp2_elt_sub()

void fp2_elt_sub ( fp2_elt_ptr  dst,
fp2_elt_srcptr  src1,
fp2_elt_srcptr  src2,
const fp2_param  param 
)

Set dst <- src1 - src2.

Parameters
dstTo store the result
src1Source field element
src2Source field element
paramInformation on the quadratic extension field

Definition at line 387 of file mphell-fp2.c.

◆ fp2_elt_sub_fp_elt()

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.

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

Definition at line 379 of file mphell-fp2.c.

◆ fp2_elt_unity_nth_root()

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.

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

Definition at line 1007 of file mphell-fp2.c.

◆ fp2_free()

void fp2_free ( fp2_param  param)

Free the space of the quadratic extension field informations structure.

Parameters
paramQuadratic extension field informations structure

Definition at line 133 of file mphell-fp2.c.

◆ fp2_get_characteristic()

void fp2_get_characteristic ( number_ptr  c,
const fp2_param  param 
)

Get the characteristic of the quadratic extension field "param".

Parameters
cDestination number_ptr (to store the characteristic)
paramInformation on quadratic extension field

Definition at line 144 of file mphell-fp2.c.

◆ fp2_get_size()

void fp2_get_size ( number_ptr  c,
const fp2_param  param 
)

Get the size of the quadratic extension field "param".

Parameters
cDestination number_ptr (to store the characteristic)
paramInformation on quadratic extension field

Definition at line 150 of file mphell-fp2.c.

◆ fp2_str()

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.

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

Definition at line 274 of file mphell-fp2.c.