MPHELL  4.0.0
Functions
mphell-weierstrass.h File Reference

Declaration of Weierstrass ECC function. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void weierstrass_compute_disc (ec_curve E, uint8_t stack)
 Set the discriminant of E: disc = -16(4a^3 + 27b^2) More...
 
bool weierstrass_verify_random_generation (ec_curve E, const char *seed, uint8_t stack)
 Test if E if generated from the seed "seed". More...
 
void weierstrass_curve_random_generation (fe_ptr a, fe_ptr b, char *seed_res, field_srcptr k, uint8_t stack)
 Generate a 160 bits seed and coefficients a and b defining a Weiestrass elliptic curve. The curve is not tested to be secure !!! More...
 
void weierstrass_point_set_neutral (ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
 Set dst to the neutral element: (0,1,0) for projective coordinates and (1,1,0) for jacobian coordinates. More...
 
void weierstrass_point_set_aff (ec_point_ptr P, fe_srcptr x, fe_srcptr y, field_srcptr k)
 Set dest to the affine point (x, y) More...
 
void weierstrass_point_set_aff_str (ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack)
 Set dest to the affine point (str_x,str_y) More...
 
bool weierstrass_belongs (ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
 Test if P belongs to E. More...
 
void weierstrass_point_random (ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
 Set P to a random point on E. More...
 
void weierstrass_point_norm (ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
 Set P in affine coordinates. More...
 
void weierstrass_point_get_x_affine (field_elt x, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
 Convert P->x to its affine representation. More...
 
void weierstrass_point_get_y_affine (field_elt y, ec_point_ptr P, ec_curve_srcptr E, uint8_t stack)
 Convert P->y to its affine representation. More...
 
bool weierstrass_point_is_neutral (ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack)
 Test if P is the neutral element. More...
 
bool weierstrass_point_are_equal (ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
 Test if P1 and P2 are equal on E (BUT do not test if they belong to the curve) More...
 
void weierstrass_point_neg (ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E)
 Set P3 to -P1. More...
 
void weierstrass_point_add_ZADDU (ec_point_ptr P3, ec_point_ptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
 Co-Z point addition with update: Set P3 = (X3,Y3,Z3) to P1 + P2 using Co-Z addition and update P1 such that Z1 = Z3. More...
 
void weierstrass_point_add_ZADDC (ec_point_ptr P3, ec_point_ptr P4, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
 Conjugate Co-Z point addition: Set P3 to P1 + P2 and P4 to P1 - P2 such that Z3=Z4. More...
 
void weierstrass_point_add_ZDAU (ec_point_ptr P3, ec_point_srcptr P1, ec_point_ptr P2, ec_curve_srcptr E, uint8_t stack)
 Co-Z point doubling-addition with update: Set P3 to 2*P1 + P2 and update P2 such that Z2 = Z3. More...
 
void weierstrass_point_DBLU (ec_point_ptr P3, ec_point_ptr P4, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Co-Z point doubling with update: Set P3 to 2*P1 and P4 such that P1 = P4 and Z4 = Z3 and assume that P1->z==1. More...
 
void weierstrass_point_TPLU (ec_point_ptr P3, ec_point_ptr P4, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Co-Z point tripling with update: Set P3 to 3*P1 and P4 such that P4 = P1 and Z4 = Z3. More...
 
void weierstrass_Zmontgomery_Kim (ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Perform the Montgomery ladder, taken from Kim et al's 2017 work, compute P3=[n]P1 it has the drawback to perform an inversion at the end of the computation to have affine coordinates and its formula is not complete and does not work for n = -1 neither 0 see .c for details. More...
 
void weierstrass_Zmontgomery_ladder (ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Set P3 to n * P1 using Montgomery ladder with Co-Z addition formula. More...
 
void weierstrass_Zjoye_mul (ec_point_ptr P3, number_srcptr n, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Set P3 to n * P1 using Joye’s double-add algorithm with Co-Z addition formula.The formulae are not complete and does not work for n = -1 see .c for details. More...
 
void weierstrass_point_add_unified (ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
 Set P3 to P1 + P2, using unified formulae (protection against SPA) More...
 
void weierstrass_point_add_dedicated (ec_point_ptr P3, ec_point_srcptr P1, ec_point_srcptr P2, ec_curve_srcptr E, uint8_t stack)
 Set P3 to P1 + P2, using dedicated formulae (not protected against SPA, but faster) More...
 
void weierstrass_point_dbl_dedicated (ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack)
 Set P3 to 2 * P1, using dedicated formulae (not protected against SPA, but faster) More...
 
void weierstrass_point_of_order_2 (ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack)
 Set dst to one of the point of order 2 of the curve E assuming that at least one exist. More...
 
void weierstrass_points_of_order_2 (ec_point_ptr dst1, ec_point_ptr dst2, ec_point_ptr dst3, ec_curve_srcptr E, uint8_t stack)
 Set dst1, dst2, dst3 to the points of order 2 of the curve E assuming they are different otherwise they are all equal to the unique point of order 2. More...
 

Detailed Description

Declaration of Weierstrass ECC function.

Definition in file mphell-weierstrass.h.

Function Documentation

◆ weierstrass_belongs()

bool weierstrass_belongs ( ec_point_srcptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Test if P belongs to E.

Parameters
PPoint
EElliptic curve
stackTemporary memory stack to use
Returns
true if P belongs to E
false otherwise

Definition at line 442 of file mphell-weierstrass.c.

◆ weierstrass_compute_disc()

void weierstrass_compute_disc ( ec_curve  E,
uint8_t  stack 
)

Set the discriminant of E: disc = -16(4a^3 + 27b^2)

Parameters
EElliptic curve
stackTemporary memory stack to use

Definition at line 70 of file mphell-weierstrass.c.

◆ weierstrass_curve_random_generation()

void weierstrass_curve_random_generation ( fe_ptr  a,
fe_ptr  b,
char *  seed_res,
field_srcptr  k,
uint8_t  stack 
)

Generate a 160 bits seed and coefficients a and b defining a Weiestrass elliptic curve. The curve is not tested to be secure !!!

Parameters
aDestination coefficient, generated from a random seed
bDestination coefficient, generated from a random seed
seed_resDestination seed (of 160 bits) used to generate an elliptic curve
kBase field, must be created by the user before use.
stackTemporary memory stack to use

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

◆ weierstrass_point_add_dedicated()

void weierstrass_point_add_dedicated ( ec_point_ptr  P3,
ec_point_srcptr  P1,
ec_point_srcptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P3 to P1 + P2, using dedicated formulae (not protected against SPA, but faster)

--> Interface

Parameters
P3Destination point
P1Point
P2Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1921 of file mphell-weierstrass.c.

◆ weierstrass_point_add_unified()

void weierstrass_point_add_unified ( ec_point_ptr  P3,
ec_point_srcptr  P1,
ec_point_srcptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P3 to P1 + P2, using unified formulae (protection against SPA)

Parameters
P3Destination point
P1Point
P2Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1951 of file mphell-weierstrass.c.

◆ weierstrass_point_add_ZADDC()

void weierstrass_point_add_ZADDC ( ec_point_ptr  P3,
ec_point_ptr  P4,
ec_point_srcptr  P1,
ec_point_srcptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Conjugate Co-Z point addition: Set P3 to P1 + P2 and P4 to P1 - P2 such that Z3=Z4.

Parameters
P3Destination point
P4Destination point
P1Point (X1, Y1, Z)
P2Point (X2, Y2, Z)
EElliptic curve
stackTemporary memory stack to use

Definition at line 815 of file mphell-weierstrass.c.

◆ weierstrass_point_add_ZADDU()

void weierstrass_point_add_ZADDU ( ec_point_ptr  P3,
ec_point_ptr  P1,
ec_point_srcptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Co-Z point addition with update: Set P3 = (X3,Y3,Z3) to P1 + P2 using Co-Z addition and update P1 such that Z1 = Z3.

--> COZ

Parameters
P3Destination point
P1Point (X1, Y1, Z)
P2Point (X2, Y2, Z)
EElliptic curve
stackTemporary memory stack to use

Definition at line 775 of file mphell-weierstrass.c.

◆ weierstrass_point_add_ZDAU()

void weierstrass_point_add_ZDAU ( ec_point_ptr  P3,
ec_point_srcptr  P1,
ec_point_ptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Co-Z point doubling-addition with update: Set P3 to 2*P1 + P2 and update P2 such that Z2 = Z3.

Parameters
P3Destination point
P1Point (X1, Y1, Z2)
P2Point (X2, Y2, Z2)
EElliptic curve
stackTemporary memory stack to use

Definition at line 866 of file mphell-weierstrass.c.

◆ weierstrass_point_are_equal()

bool weierstrass_point_are_equal ( ec_point_srcptr  P1,
ec_point_srcptr  P2,
ec_curve_srcptr  E,
uint8_t  stack 
)

Test if P1 and P2 are equal on E (BUT do not test if they belong to the curve)

Parameters
P1Point
P2Point
EElliptic curve
stackTemporary memory stack to use
Returns
True if P1 == P2, False otherwise

Definition at line 677 of file mphell-weierstrass.c.

◆ weierstrass_point_dbl_dedicated()

void weierstrass_point_dbl_dedicated ( ec_point_ptr  P3,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P3 to 2 * P1, using dedicated formulae (not protected against SPA, but faster)

Parameters
P3Destination point
P1Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1981 of file mphell-weierstrass.c.

◆ weierstrass_point_DBLU()

void weierstrass_point_DBLU ( ec_point_ptr  P3,
ec_point_ptr  P4,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Co-Z point doubling with update: Set P3 to 2*P1 and P4 such that P1 = P4 and Z4 = Z3 and assume that P1->z==1.

Parameters
P3Destination point
P4Destination point
P1Point with P1->z==1
EElliptic curve
stackTemporary memory stack to use

Definition at line 940 of file mphell-weierstrass.c.

◆ weierstrass_point_get_x_affine()

void weierstrass_point_get_x_affine ( field_elt  x,
ec_point_ptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Convert P->x to its affine representation.

Parameters
xP->x in affine coordinates
PPoint
EElliptic curve
stackTemporary memory stack to use

Definition at line 578 of file mphell-weierstrass.c.

◆ weierstrass_point_get_y_affine()

void weierstrass_point_get_y_affine ( field_elt  y,
ec_point_ptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Convert P->y to its affine representation.

Parameters
xP->y in affine coordinates
PPoint
EElliptic curve
stackTemporary memory stack to use

Definition at line 604 of file mphell-weierstrass.c.

◆ weierstrass_point_is_neutral()

bool weierstrass_point_is_neutral ( ec_point_srcptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Test if P is the neutral element.

Parameters
PPoint to test
EElliptic curve
stackTemporary memory stack to use
Returns
True if P is neutral, False otherwise

Definition at line 633 of file mphell-weierstrass.c.

◆ weierstrass_point_neg()

void weierstrass_point_neg ( ec_point_ptr  P3,
ec_point_srcptr  P1,
ec_curve_srcptr  E 
)

Set P3 to -P1.

Parameters
P3Destination point
P1Point
EElliptic curve

Definition at line 2007 of file mphell-weierstrass.c.

◆ weierstrass_point_norm()

void weierstrass_point_norm ( ec_point_ptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P in affine coordinates.

Parameters
PPoint
EElliptic curve
stackTemporary memory stack to use

Definition at line 537 of file mphell-weierstrass.c.

◆ weierstrass_point_of_order_2()

void weierstrass_point_of_order_2 ( ec_point_ptr  dst,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set dst to one of the point of order 2 of the curve E assuming that at least one exist.

--> Miscellaneaous

Parameters
dstDestination point
EElliptic curve
stackTemporary memory stack to use

Definition at line 2019 of file mphell-weierstrass.c.

◆ weierstrass_point_random()

void weierstrass_point_random ( ec_point_ptr  P,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P to a random point on E.

Parameters
PDestination point
EElliptic curve
stackTemporary memory stack to use

Definition at line 511 of file mphell-weierstrass.c.

◆ weierstrass_point_set_aff()

void weierstrass_point_set_aff ( ec_point_ptr  P,
fe_srcptr  x,
fe_srcptr  y,
field_srcptr  k 
)

Set dest to the affine point (x, y)

Parameters
PDestination point
xx-coordinate of the affine point (x, y)
yy-coordinate of the affine point (x, y)
kBase field

Definition at line 423 of file mphell-weierstrass.c.

◆ weierstrass_point_set_aff_str()

void weierstrass_point_set_aff_str ( ec_point_ptr  P,
const char *  str_x,
const char *  str_y,
const bool  is_reduced,
const uint8_t  base,
field_srcptr  k,
uint8_t  stack 
)

Set dest to the affine point (str_x,str_y)

Parameters
PDestination point
str_xx-coordinate of the affine point (x, y) under string form
str_yy-coordinate of the affine point (x, y) under string form
is_reducedSet true if str_x and str_y are already reduced in k, false otherwise
baseBase (either 10 or 16) used for str_x and str_y
kBase field
stackTemporary memory stack to use

Definition at line 432 of file mphell-weierstrass.c.

◆ weierstrass_point_set_neutral()

void weierstrass_point_set_neutral ( ec_point_ptr  dst,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set dst to the neutral element: (0,1,0) for projective coordinates and (1,1,0) for jacobian coordinates.

Parameters
dstDestination point
EElliptic curve
stackTemporary memory stack to use

Definition at line 397 of file mphell-weierstrass.c.

◆ weierstrass_point_TPLU()

void weierstrass_point_TPLU ( ec_point_ptr  P3,
ec_point_ptr  P4,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Co-Z point tripling with update: Set P3 to 3*P1 and P4 such that P4 = P1 and Z4 = Z3.

Parameters
P3Destination point
P4Destination point
P1Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1001 of file mphell-weierstrass.c.

◆ weierstrass_points_of_order_2()

void weierstrass_points_of_order_2 ( ec_point_ptr  dst1,
ec_point_ptr  dst2,
ec_point_ptr  dst3,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set dst1, dst2, dst3 to the points of order 2 of the curve E assuming they are different otherwise they are all equal to the unique point of order 2.

Parameters
dst1Destination point
dst2Destination point
dst3Destination point
EElliptic curve
stackTemporary memory stack to use

Definition at line 2166 of file mphell-weierstrass.c.

◆ weierstrass_verify_random_generation()

bool weierstrass_verify_random_generation ( ec_curve  E,
const char *  seed,
uint8_t  stack 
)

Test if E if generated from the seed "seed".

Parameters
EElliptic curve to test
seedSeed (of 160 bits) used to generate an elliptic curve
stackTemporary memory stack to use
Returns
true if E is generated from seed
false otherwise

Definition at line 100 of file mphell-weierstrass.c.

◆ weierstrass_Zjoye_mul()

void weierstrass_Zjoye_mul ( ec_point_ptr  P3,
number_srcptr  n,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P3 to n * P1 using Joye’s double-add algorithm with Co-Z addition formula.The formulae are not complete and does not work for n = -1 see .c for details.

Parameters
P3Destination point
P1Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1843 of file mphell-weierstrass.c.

◆ weierstrass_Zmontgomery_Kim()

void weierstrass_Zmontgomery_Kim ( ec_point_ptr  P3,
number_srcptr  n,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Perform the Montgomery ladder, taken from Kim et al's 2017 work, compute P3=[n]P1 it has the drawback to perform an inversion at the end of the computation to have affine coordinates and its formula is not complete and does not work for n = -1 neither 0 see .c for details.

Parameters
P3Destination point
nNumber element for the scalar multiplication (different from -1 mod #E)
P1Input point
EElliptic curve on which the points belong
stackTemporary memory stack to use

Definition at line 1757 of file mphell-weierstrass.c.

◆ weierstrass_Zmontgomery_ladder()

void weierstrass_Zmontgomery_ladder ( ec_point_ptr  P3,
number_srcptr  n,
ec_point_srcptr  P1,
ec_curve_srcptr  E,
uint8_t  stack 
)

Set P3 to n * P1 using Montgomery ladder with Co-Z addition formula.

--> COZ multiplication

Parameters
P3Destination point
P1Point
EElliptic curve
stackTemporary memory stack to use

Definition at line 1496 of file mphell-weierstrass.c.