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

Declaration of cubic field (finite field constructed with an irreducible polynomial of degree 3) functions. More...

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

Go to the source code of this file.

Data Structures

struct  fp3_elt_t
 Cubic extension field element structure. More...
 
struct  fp3_param_t
 Cubic extension field structure. More...
 

Typedefs

typedef fp3_elt_t fp3_elt
 Cubic extension field element structure.
 
typedef fp3_elt_tfp3_elt_ptr
 Define fp3_elt_ptr, use in all functions.
 
typedef const fp3_elt_tfp3_elt_srcptr
 Define fp3_elt_srcptr, use in all functions where the parameter is const.
 
typedef fp3_param_tfp3_param
 Address of a cubic extension field structure.
 

Functions

void fp3_elt_get_pool_elt (fp3_elt *dst, const fp3_param param, uint8_t stack)
 Allocate and initialise space for a temporary cubic extension field element. More...
 
void fp3_elt_relax_pool_elt (fp3_elt *dst, const fp3_param param, uint8_t stack)
 Free space of a temporary cubic extension field element. More...
 
void fp3_alloc (fp3_param param, const fp_param base)
 Allocate space for the cubic extension field informations structure. More...
 
void fp3_create (fp3_param param, const fp_param base, fp_elt_srcptr non_residue, uint8_t stack)
 Create a cubic extension of the field base. More...
 
void fp3_copy (fp3_param param_res, const fp3_param param)
 Copy the cubic extension field structure param into param_res. More...
 
void fp3_free (fp3_param param)
 Free the space of the cubic extension field informations structure. More...
 
void fp3_get_characteristic (number_ptr c, const fp3_param param)
 Get the characteristic of the cubic extension field "param". More...
 
void fp3_get_size (number_ptr c, const fp3_param param)
 Get the size of the cubic extension field "param". More...
 
void fp3_elt_alloc (fp3_elt *dst, const fp3_param param)
 Allocate space for a cubic extension field element. More...
 
void fp3_elt_init (fp3_elt_ptr dst, const fp3_param param)
 Initialise a cubic extension field element. More...
 
void fp3_elt_copy (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Copy src into dst, src and dst must belong to the same FP3. More...
 
void fp3_elt_clear (fp3_elt *src)
 Clear space used by src (remove the action of fp3_elt_init but let the one of fp3_elt_alloc) More...
 
void fp3_elt_free (fp3_elt *src)
 Free space used by src. More...
 
void fp3_elt_set_one (fp3_elt_ptr dst, const fp3_param param)
 Set dst to one (or its Montgomery form if Montgomery arithmetic is used) More...
 
void fp3_elt_set_ui (fp3_elt_ptr dst, const uint64_t src, const bool isreduced, const fp3_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 fp3_elt_set_number (fp3_elt_ptr dst, number_srcptr src, const bool isreduced, const fp3_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 fp3_elt_set_fp_elt (fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param)
 Set dst to src. More...
 
void fp3_elt_set (fp3_elt_ptr dst, number_srcptr src1, number_srcptr src2, number_srcptr src3, const bool isreduced, const fp3_param param, uint8_t stack)
 Set dst to src1 + src2*x + src3*x^2, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form. More...
 
void fp3_elt_set_fp_elts (fp3_elt_ptr dst, fp_elt_srcptr src1, fp_elt_srcptr src2, fp_elt_srcptr src3, const fp3_param param)
 Set dst to src1 + src2*x + src3*x^2. More...
 
void fp3_elt_set_str (fp3_elt_ptr dst, const char *str, const uint8_t base, const bool isreduced, const fp3_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 fp3_elt_random (fp3_elt_ptr dst, const fp3_param param, uint8_t stack)
 Set dst to a random element of FP3, the random process is chosen at the MHELL initialisation. More...
 
void fp3_elt_lift (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical FP3. More...
 
void fp3_str (char **str, const fp3_param param, const uint8_t base, uint8_t stack)
 Converts fp2_param param to string format in base specified by base. More...
 
void fp3_elt_str (char **str, fp3_elt_srcptr src, const uint8_t base, const bool lift, const fp3_param param, uint8_t stack)
 Converts src to string format in base specified by base. More...
 
int8_t fp3_elt_cmp_fp_elt (fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param)
 Compare src1 and src2 in FP3. More...
 
int8_t fp3_elt_cmp (fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param)
 Compare src1 and src2 in FP3. More...
 
bool fp3_elt_isone (fp3_elt_srcptr src, const fp3_param param)
 Test if src is one. More...
 
bool fp3_elt_iszero (fp3_elt_srcptr src, const fp3_param param)
 Test if src is zero. More...
 
void fp3_elt_inc (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- src + 1. More...
 
void fp3_elt_add_fp_elt (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param)
 Set dst <- src1 + src2. More...
 
void fp3_elt_add (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param)
 Set dst <- src1 + src2. More...
 
void fp3_elt_dec (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- src - 1. More...
 
void fp3_elt_sub_fp_elt (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param)
 Set dst <- src1 - src2. More...
 
void fp3_elt_sub (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param)
 Set dst <- src1 - src2. More...
 
void fp3_elt_neg_fp_elt (fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param)
 Set dst <- (-src) More...
 
void fp3_elt_neg (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- (-src) More...
 
void fp3_elt_mul_fp_elt (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param, uint8_t stack)
 Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used ! More...
 
void fp3_elt_mul2 (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- 2 * src. More...
 
void fp3_elt_mul4 (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- 4 * src. More...
 
void fp3_elt_mul8 (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param)
 Set dst <- 8 * src. More...
 
void fp3_elt_mul3 (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- 3 * src. More...
 
void fp3_elt_mul (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param, uint8_t stack)
 Set dst <- src1 * src2, if Montgomery arithmetic is used, the Montgomery multiplication will be used ! More...
 
void fp3_elt_sqr_fp_elt (fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^2. More...
 
void fp3_elt_sqr (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^2. More...
 
void fp3_elt_inv_fp_elt (fp3_elt_ptr dst, fp_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^(-1) More...
 
void fp3_elt_inv (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^(-1) More...
 
void fp3_elt_div_fp_elt (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp_elt_srcptr src2, const fp3_param param, uint8_t stack)
 Set dst <- src1 / src2. More...
 
void fp3_elt_div (fp3_elt_ptr dst, fp3_elt_srcptr src1, fp3_elt_srcptr src2, const fp3_param param, uint8_t stack)
 Set dst <- src1 / src2. More...
 
void fp3_elt_pow_ui (fp3_elt_ptr dst, fp3_elt_srcptr src, const block n, const fp3_param param, uint8_t stack)
 Set dst <- src^n. More...
 
void fp3_elt_pow_number (fp3_elt_ptr dst, fp3_elt_srcptr src, number_srcptr n, const fp3_param param, uint8_t stack)
 Set dst <- src^n. More...
 
bool fp3_elt_issquare (fp3_elt_srcptr src, const fp3_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 fp3_elt_ispower_ui (fp3_elt_srcptr src, const block n, const fp3_param param, uint8_t stack)
 Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDSGAARD HANSEN. More...
 
int8_t fp3_elt_ispower_number (fp3_elt_srcptr src, number_srcptr n, const fp3_param param, uint8_t stack)
 Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDSGAARD HANSEN. More...
 
void fp3_elt_sqrt (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^(1/2), using Tonelli–Shanks algorithm. More...
 
void fp3_elt_cube_root (fp3_elt_ptr dst, fp3_elt_srcptr src, const fp3_param param, uint8_t stack)
 Set dst <- src^(1/3) More...
 
void fp3_elt_unity_nth_root (fp3_elt_ptr dst, const block n, const fp3_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 cubic field (finite field constructed with an irreducible polynomial of degree 3) functions.

Definition in file mphell-fp3.h.

Function Documentation

◆ fp3_alloc()

void fp3_alloc ( fp3_param  param,
const fp_param  base 
)

Allocate space for the cubic extension field informations structure.

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

Definition at line 69 of file mphell-fp3.c.

◆ fp3_copy()

void fp3_copy ( fp3_param  param_res,
const fp3_param  param 
)

Copy the cubic extension field structure param into param_res.

Parameters
param_resDestination cubic extension field
paramSource cubic extension field

Definition at line 131 of file mphell-fp3.c.

◆ fp3_create()

void fp3_create ( fp3_param  param,
const fp_param  base,
fp_elt_srcptr  non_residue,
uint8_t  stack 
)

Create a cubic extension of the field base.

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

Definition at line 108 of file mphell-fp3.c.

◆ fp3_elt_add()

void fp3_elt_add ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp3_elt_srcptr  src2,
const fp3_param  param 
)

Set dst <- src1 + src2.

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

Definition at line 403 of file mphell-fp3.c.

◆ fp3_elt_add_fp_elt()

void fp3_elt_add_fp_elt ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp3_param  param 
)

Set dst <- src1 + src2.

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

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

◆ fp3_elt_alloc()

void fp3_elt_alloc ( fp3_elt dst,
const fp3_param  param 
)

Allocate space for a cubic extension field element.

Parameters
dstCubic extension field element to allocate
paramInformation on cubic extension field

Definition at line 174 of file mphell-fp3.c.

◆ fp3_elt_clear()

void fp3_elt_clear ( fp3_elt src)

Clear space used by src (remove the action of fp3_elt_init but let the one of fp3_elt_alloc)

Parameters
srccubic extension field element to clear

Definition at line 198 of file mphell-fp3.c.

◆ fp3_elt_cmp()

int8_t fp3_elt_cmp ( fp3_elt_srcptr  src1,
fp3_elt_srcptr  src2,
const fp3_param  param 
)

Compare src1 and src2 in FP3.

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

Definition at line 348 of file mphell-fp3.c.

◆ fp3_elt_cmp_fp_elt()

int8_t fp3_elt_cmp_fp_elt ( fp3_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp3_param  param 
)

Compare src1 and src2 in FP3.

Parameters
src1Source field element in FP3
src2Source number in FP
paramInformation on the cubic extension field
Returns
-1 if src1 < src2
0 if src1 == src2
1 if src1 > src2

Definition at line 338 of file mphell-fp3.c.

◆ fp3_elt_copy()

void fp3_elt_copy ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Copy src into dst, src and dst must belong to the same FP3.

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

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

◆ fp3_elt_cube_root()

void fp3_elt_cube_root ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^(1/3)

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

Definition at line 910 of file mphell-fp3.c.

◆ fp3_elt_dec()

void fp3_elt_dec ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- src - 1.

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

Definition at line 412 of file mphell-fp3.c.

◆ fp3_elt_div()

void fp3_elt_div ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp3_elt_srcptr  src2,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src1 / src2.

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

Definition at line 635 of file mphell-fp3.c.

◆ fp3_elt_div_fp_elt()

void fp3_elt_div_fp_elt ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp3_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 cubic extension field
stackTemporary memory stack to use

Definition at line 624 of file mphell-fp3.c.

◆ fp3_elt_free()

void fp3_elt_free ( fp3_elt src)

Free space used by src.

Parameters
srccubic extension field element to free

Definition at line 206 of file mphell-fp3.c.

◆ fp3_elt_get_pool_elt()

void fp3_elt_get_pool_elt ( fp3_elt dst,
const fp3_param  param,
uint8_t  stack 
)

Allocate and initialise space for a temporary cubic extension field element.

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

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

◆ fp3_elt_inc()

void fp3_elt_inc ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- src + 1.

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

Definition at line 386 of file mphell-fp3.c.

◆ fp3_elt_init()

void fp3_elt_init ( fp3_elt_ptr  dst,
const fp3_param  param 
)

Initialise a cubic extension field element.

Parameters
dstCubic extension field element to initialise
paramInformation on cubic extension field

Definition at line 182 of file mphell-fp3.c.

◆ fp3_elt_inv()

void fp3_elt_inv ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^(-1)

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

Definition at line 580 of file mphell-fp3.c.

◆ fp3_elt_inv_fp_elt()

void fp3_elt_inv_fp_elt ( fp3_elt_ptr  dst,
fp_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^(-1)

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

Definition at line 572 of file mphell-fp3.c.

◆ fp3_elt_isone()

bool fp3_elt_isone ( fp3_elt_srcptr  src,
const fp3_param  param 
)

Test if src is one.

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

Definition at line 370 of file mphell-fp3.c.

◆ fp3_elt_ispower_number()

int8_t fp3_elt_ispower_number ( fp3_elt_srcptr  src,
number_srcptr  n,
const fp3_param  param,
uint8_t  stack 
)

Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDSGAARD HANSEN.

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

Definition at line 767 of file mphell-fp3.c.

◆ fp3_elt_ispower_ui()

int8_t fp3_elt_ispower_ui ( fp3_elt_srcptr  src,
const block  n,
const fp3_param  param,
uint8_t  stack 
)

Test if src is a n-power in FP3, using A NOTE ON POWERS IN FINITE FIELDS from ANDREAS AABRANDT AND VAGN LUNDSGAARD HANSEN.

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

Definition at line 726 of file mphell-fp3.c.

◆ fp3_elt_issquare()

bool fp3_elt_issquare ( fp3_elt_srcptr  src,
const fp3_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 cubic extension field
stackTemporary memory stack to use
Returns
true if src is a square in FP3, false otherwise

Definition at line 708 of file mphell-fp3.c.

◆ fp3_elt_iszero()

bool fp3_elt_iszero ( fp3_elt_srcptr  src,
const fp3_param  param 
)

Test if src is zero.

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

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

◆ fp3_elt_lift()

void fp3_elt_lift ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

If Montgomery arithmetic is used, lift src (which is into Montgomery form) to classical FP3.

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

Definition at line 293 of file mphell-fp3.c.

◆ fp3_elt_mul()

void fp3_elt_mul ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp3_elt_srcptr  src2,
const fp3_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 cubic extension prime field
stackTemporary memory stack to use

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

◆ fp3_elt_mul2()

void fp3_elt_mul2 ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- 2 * src.

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

Definition at line 465 of file mphell-fp3.c.

◆ fp3_elt_mul3()

void fp3_elt_mul3 ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- 3 * src.

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

Definition at line 492 of file mphell-fp3.c.

◆ fp3_elt_mul4()

void fp3_elt_mul4 ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- 4 * src.

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

Definition at line 474 of file mphell-fp3.c.

◆ fp3_elt_mul8()

void fp3_elt_mul8 ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- 8 * src.

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

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

◆ fp3_elt_mul_fp_elt()

void fp3_elt_mul_fp_elt ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp3_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 cubic extension prime field
stackTemporary memory stack to use

Definition at line 456 of file mphell-fp3.c.

◆ fp3_elt_neg()

void fp3_elt_neg ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- (-src)

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

Definition at line 446 of file mphell-fp3.c.

◆ fp3_elt_neg_fp_elt()

void fp3_elt_neg_fp_elt ( fp3_elt_ptr  dst,
fp_elt_srcptr  src,
const fp3_param  param 
)

Set dst <- (-src)

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

Definition at line 438 of file mphell-fp3.c.

◆ fp3_elt_pow_number()

void fp3_elt_pow_number ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
number_srcptr  n,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^n.

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

Definition at line 669 of file mphell-fp3.c.

◆ fp3_elt_pow_ui()

void fp3_elt_pow_ui ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const block  n,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^n.

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

Definition at line 646 of file mphell-fp3.c.

◆ fp3_elt_random()

void fp3_elt_random ( fp3_elt_ptr  dst,
const fp3_param  param,
uint8_t  stack 
)

Set dst to a random element of FP3, the random process is chosen at the MHELL initialisation.

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

Definition at line 285 of file mphell-fp3.c.

◆ fp3_elt_relax_pool_elt()

void fp3_elt_relax_pool_elt ( fp3_elt dst,
const fp3_param  param,
uint8_t  stack 
)

Free space of a temporary cubic extension field element.

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

Definition at line 59 of file mphell-fp3.c.

◆ fp3_elt_set()

void fp3_elt_set ( fp3_elt_ptr  dst,
number_srcptr  src1,
number_srcptr  src2,
number_srcptr  src3,
const bool  isreduced,
const fp3_param  param,
uint8_t  stack 
)

Set dst to src1 + src2*x + src3*x^2, if Montgomery arithmetic is used, is_reduced == false -> transform dst into its Montgomery form.

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

Definition at line 248 of file mphell-fp3.c.

◆ fp3_elt_set_fp_elt()

void fp3_elt_set_fp_elt ( fp3_elt_ptr  dst,
fp_elt_srcptr  src,
const fp3_param  param 
)

Set dst to src.

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

Definition at line 240 of file mphell-fp3.c.

◆ fp3_elt_set_fp_elts()

void fp3_elt_set_fp_elts ( fp3_elt_ptr  dst,
fp_elt_srcptr  src1,
fp_elt_srcptr  src2,
fp_elt_srcptr  src3,
const fp3_param  param 
)

Set dst to src1 + src2*x + src3*x^2.

Parameters
dstDestination cubic extension field element
src1Source fp_elt
src2Source fp_elt
src3Source fp_elt
paramInformation on the cubic extension field

Definition at line 257 of file mphell-fp3.c.

◆ fp3_elt_set_number()

void fp3_elt_set_number ( fp3_elt_ptr  dst,
number_srcptr  src,
const bool  isreduced,
const fp3_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 cubic 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 cubic extension field
stackTemporary memory stack to use

Definition at line 231 of file mphell-fp3.c.

◆ fp3_elt_set_one()

void fp3_elt_set_one ( fp3_elt_ptr  dst,
const fp3_param  param 
)

Set dst to one (or its Montgomery form if Montgomery arithmetic is used)

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

Definition at line 214 of file mphell-fp3.c.

◆ fp3_elt_set_str()

void fp3_elt_set_str ( fp3_elt_ptr  dst,
const char *  str,
const uint8_t  base,
const bool  isreduced,
const fp3_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 cubic extension field element
strSource polynomial coefficient under string format in base "base", separated by a "," without space. ex: "123,456,789" will create the polynomial 123 + 456.X + 789.X^2
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 cubic extension field
stackTemporary memory stack to use

Definition at line 265 of file mphell-fp3.c.

◆ fp3_elt_set_ui()

void fp3_elt_set_ui ( fp3_elt_ptr  dst,
const uint64_t  src,
const bool  isreduced,
const fp3_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 cubic 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 cubic extension field
stackTemporary memory stack to use

Definition at line 222 of file mphell-fp3.c.

◆ fp3_elt_sqr()

void fp3_elt_sqr ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^2.

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

Definition at line 566 of file mphell-fp3.c.

◆ fp3_elt_sqr_fp_elt()

void fp3_elt_sqr_fp_elt ( fp3_elt_ptr  dst,
fp_elt_srcptr  src,
const fp3_param  param,
uint8_t  stack 
)

Set dst <- src^2.

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

Definition at line 558 of file mphell-fp3.c.

◆ fp3_elt_sqrt()

void fp3_elt_sqrt ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src,
const fp3_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 cubic extension field
stackTemporary memory stack to use

Definition at line 833 of file mphell-fp3.c.

◆ fp3_elt_str()

void fp3_elt_str ( char **  str,
fp3_elt_srcptr  src,
const uint8_t  base,
const bool  lift,
const fp3_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 + 789.X^2 will be written as "123,456,789"
srcSource cubic 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 cubic extension field
stackTemporary memory stack to use

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

◆ fp3_elt_sub()

void fp3_elt_sub ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp3_elt_srcptr  src2,
const fp3_param  param 
)

Set dst <- src1 - src2.

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

Definition at line 429 of file mphell-fp3.c.

◆ fp3_elt_sub_fp_elt()

void fp3_elt_sub_fp_elt ( fp3_elt_ptr  dst,
fp3_elt_srcptr  src1,
fp_elt_srcptr  src2,
const fp3_param  param 
)

Set dst <- src1 - src2.

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

Definition at line 420 of file mphell-fp3.c.

◆ fp3_elt_unity_nth_root()

void fp3_elt_unity_nth_root ( fp3_elt_ptr  dst,
const block  n,
const fp3_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 1099 of file mphell-fp3.c.

◆ fp3_free()

void fp3_free ( fp3_param  param)

Free the space of the cubic extension field informations structure.

Parameters
paramcubic extension field informations structure

Definition at line 143 of file mphell-fp3.c.

◆ fp3_get_characteristic()

void fp3_get_characteristic ( number_ptr  c,
const fp3_param  param 
)

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

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

Definition at line 156 of file mphell-fp3.c.

◆ fp3_get_size()

void fp3_get_size ( number_ptr  c,
const fp3_param  param 
)

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

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

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

◆ fp3_str()

void fp3_str ( char **  str,
const fp3_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 cubic extension field
baseBase to use to write str, can be 2, 10 or 16
stackTemporary memory stack to use

Definition at line 301 of file mphell-fp3.c.