MPHELL
4.0.0
|
Declaration of ECC functions. More...
#include "mphell-field.h"
#include "mphell-weierstrass.h"
#include "mphell-jacobi.h"
#include "mphell-edwards.h"
Go to the source code of this file.
Data Structures | |
struct | ec_point |
Define an elliptic curve point. More... | |
struct | ec_curve |
Define an elliptic curve. More... | |
Typedefs | |
typedef enum ec_type_enum | ec_type |
Define the type of curve. | |
typedef enum ec_algo_enum | ec_formula |
Define the type of coordinate. | |
typedef enum ec_known_curve_enum | ec_known_curve |
Define the hardcoded curves. | |
typedef struct ec_point | ec_point_t |
Define an elliptic curve point. | |
typedef ec_point_t | ec_point[1] |
Address of an ec_point structure. | |
typedef ec_point_t * | ec_point_ptr |
Define ec_point_ptr, use in all functions. | |
typedef const ec_point_t * | ec_point_srcptr |
Define ec_point_srcptr, use in all functions where the parameter is const. | |
typedef struct ec_curve | ec_curve_t |
Define an elliptic curve. | |
typedef ec_curve_t | ec_curve[1] |
Address of an ec_curve structure. | |
typedef ec_curve_t * | ec_curve_ptr |
Define ec_curve_ptr, use in all functions. | |
typedef const ec_curve_t * | ec_curve_srcptr |
Define ec_curve_srcptr, use in all functions where the parameter is const. | |
Enumerations | |
enum | ec_type_enum { WEIERSTRASS, EDWARDS, JACOBI_QUARTIC } |
Define the type of curve. More... | |
enum | ec_algo_enum { PROJECTIVE, JACOBIAN, EXTENDED_HOMOGENEOUS_PROJECTIVE, EXTENDED_EDWARDS } |
Define the type of coordinate. More... | |
enum | ec_known_curve_enum { NIST_192, NIST_224, NIST_256, NIST_384, NIST_521, BRAINPOOL_160, BRAINPOOL_192, BRAINPOOL_224, BRAINPOOL_256, BRAINPOOL_320, BRAINPOOL_384, BRAINPOOL_512, FR_256, JQ_256_3, ED_25519 } |
Define the hardcoded curves. More... | |
Functions | |
static void | ec_point_get_pool_elt (ec_point_ptr P, field_ptr k, uint8_t stack) |
Get an initialised point from the pool. More... | |
static void | ec_point_relax_pool_elt (ec_point_ptr P, field_ptr k, uint8_t stack) |
Relax an initialised point from the pool. More... | |
void | ec_alloc (ec_curve_ptr E, field_srcptr k) |
Allocate a curve. More... | |
void | ec_init (ec_curve_ptr E, field_srcptr k) |
Initialise a curve. More... | |
void | ec_create (ec_curve_ptr E, const char *id_curve, field_srcptr k, fe_srcptr a, fe_srcptr b, ec_point_srcptr G, number_srcptr h, number_srcptr n, const ec_type type, const ec_formula f, uint8_t stack) |
Create an elliptic curve E, the curve must be allocated and initialised (ec_alloc & ec_init) More... | |
void | ec_use_curve (ec_curve_ptr E, field_ptr k, const ec_known_curve id_curve, const ec_formula f, uint8_t stack) |
Create the elliptic curve (and the associated base field) id_curve, the curve and the field must me allocated (field_alloc & ec_alloc). More... | |
void | ec_random (ec_curve_ptr E, const char *id_curve, char *seed_res, field_srcptr k, const ec_type type, const ec_formula f, uint8_t stack) |
Create a random elliptic curve E, not cryptographically secure (not tested to be). Algorithm A.3.3.2 from ANS X9.62-1998. More... | |
bool | ec_verify_random_generation (ec_curve_ptr E, const char *seed, uint8_t stack) |
Test if E if generated from the seed "seed", using algorithm A.3.4.2 from ANS X9.62-1998. Only curve generated with the algorithm A.3.3.2 can be tested. More... | |
void | ec_set_fast_unified_coordinates (ec_curve_ptr E) |
Set the fastest unified coordinates system. More... | |
void | ec_set_fast_dedicated_coordinates (ec_curve_ptr E) |
Set the fastest dedicated coordinates system. More... | |
void | ec_compute_disc (ec_curve_ptr E, uint8_t stack) |
Set the discriminant of E. More... | |
void | ec_test_spec (ec_curve_ptr E, uint8_t stack) |
Set the E->ec_spec1 to true if E->a = -3 mod p, false otherwise. More... | |
void | ec_copy (ec_curve_ptr E_res, ec_curve_srcptr E) |
Copy E into E_res which has been previously allocated, beware: the same field is used, do not free it 2 times. More... | |
void | ec_clear (ec_curve_ptr E) |
Clear the elliptic curve E (remove the action of ec_init, but let the one of ec_alloc) More... | |
void | ec_free (ec_curve_ptr E) |
Free the elliptic curve E. More... | |
void | ec_point_alloc (ec_point_ptr P, field_srcptr k) |
Allocate an elliptic curve point. More... | |
void | ec_point_init (ec_point_ptr P, field_srcptr k) |
Initialise an elliptic curve point. More... | |
void | ec_point_clear (ec_point_ptr P, field_srcptr k) |
Clear the point P (remove the action of ec_point_init, but let the one of ec_point_alloc) More... | |
void | ec_point_free (ec_point_ptr P, field_srcptr k) |
Free the point P. More... | |
void | ec_point_copy (ec_point_ptr P3, ec_point_srcptr P, field_srcptr k) |
Copy P into P3. More... | |
void | ec_point_set (ec_point_ptr P, fe_srcptr x, fe_srcptr y, fe_srcptr z, fe_srcptr t, field_srcptr k) |
Set a point from its coordinates. More... | |
void | ec_point_set_str (ec_point_ptr P, const char *str_x, const char *str_y, const char *str_z, const char *str_t, const bool is_reduced, const uint8_t base, field_srcptr k, uint8_t stack) |
Set a point from its coordinates under string format. More... | |
void | ec_point_set_aff (ec_point_ptr P, fe_srcptr x, fe_srcptr y, const ec_type type, field_srcptr k, uint8_t stack) |
Set a point from its affine coordinates. More... | |
void | ec_point_set_aff_str (ec_point_ptr P, const char *str_x, const char *str_y, const bool is_reduced, const uint8_t base, const ec_type type, field_srcptr k, uint8_t stack) |
Set a point from its affine coordinates under string format. More... | |
void | ec_point_set_neutral (ec_point_ptr dst, ec_curve_srcptr E, uint8_t stack) |
Set dst to the neutral element. More... | |
void | ec_point_norm (ec_point_ptr P, ec_curve_srcptr E, uint8_t stack) |
Convert a point in projective or jacobian coordinate to an affine point (x,y) More... | |
void | ec_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 | ec_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... | |
void | ec_point_lift (ec_point_ptr P, field_srcptr k, uint8_t stack) |
Lift the coordinates from Montgomery basis to classical arithmetic. More... | |
bool | ec_belongs (ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack) |
Test if P belongs to E. More... | |
void | ec_point_random (ec_point_ptr P, ec_curve_srcptr E, uint8_t stack) |
Create a random point P on the elliptic curve E. More... | |
void | ec_curve_str (char **str, ec_curve_srcptr E, const uint8_t base, uint8_t stack) |
Allocate *str and write in it the description of E. More... | |
void | ec_curve_print (ec_curve_srcptr E, const uint8_t base, uint8_t stack) |
Print a description of E. More... | |
void | ec_point_str (char **str, ec_point_srcptr P, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack) |
Allocate *str and write in it the description of P. More... | |
void | ec_point_print (ec_point_srcptr P, const uint8_t base, const bool lift, field_srcptr k, uint8_t stack) |
Print a description of P. More... | |
bool | ec_point_is_neutral (ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack) |
Test if P is the neutral element. More... | |
bool | ec_point_are_equal (ec_point_srcptr P1, ec_point_srcptr P2, const ec_curve_srcptr E, uint8_t stack) |
Test if P1 and P2 are equal on E. More... | |
void | ec_point_neg (ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E) |
Set P3 to -P1. More... | |
void | ec_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 | ec_point_dbl_unified (ec_point_ptr P3, ec_point_srcptr P1, ec_curve_srcptr E, uint8_t stack) |
Set P3 to 2*P1, using unified formulae (protection against SPA) More... | |
void | ec_point_sub_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 | ec_point_mul_unified (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 for Weierstrass elliptic curve, and naive method for other elliptic curve type, using unified formulae (protection against SPA) More... | |
void | ec_point_add (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 | ec_point_dbl (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 | ec_point_sub (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 | ec_point_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 Montgomery for Weierstrass elliptic curve, and naive method for other elliptic curve type, using dedicated formulae (not protected against SPA execpt in WEIESTRASS / JACOBIAN case, but faster) More... | |
void | ec_point_mul_with_precomp (ec_point_ptr P3, number_srcptr n, ec_point *tab_P1, int16_t window_size, ec_curve_srcptr E, uint8_t stack) |
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also available for Weierstrass elliptic curve, using dedicated formulae (not protected against SPA, but faster) More... | |
void | ec_point_2mul_with_precomp (ec_point_ptr P3, number_srcptr n1, ec_point *tab_P1, number_srcptr n2, ec_point *tab_P2, int16_t win_size, ec_curve_srcptr E, uint8_t stack) |
Set P3 to n1 * P1 + n2 * P2 using 2 precomputated array. More... | |
void | jacobi_quartic_to_weierstrass (ec_curve_ptr E_res, ec_curve_srcptr E, uint8_t stack) |
Convert a jacobi quartic elliptic curve into a Weierstrass elliptic curve. More... | |
void | jacobi_quartic_point_to_weierstrass_point (ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack) |
Convert a point on a jacobi quartic elliptic curve to a point on a weierstrass elliptic curve. More... | |
void | weierstrass_to_jacobi_quartic (ec_curve_ptr E_res, ec_curve_srcptr E, const bool determined, fe_ptr teta, uint8_t stack) |
Convert a Weierstrass elliptic curve into a jacobi quartic elliptic curve. More... | |
void | weierstrass_point_to_jacobi_quartic_point (ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack) |
Convert a point on a weierstrass elliptic curve to a point on a jacobi quartic elliptic curve. More... | |
void | edwards_to_weierstrass (ec_curve_ptr E_res, ec_curve_srcptr E, uint8_t stack) |
Convert the Edwards elliptic curve E to the corresponding Weierstrass elliptic curve E_res. More... | |
void | edwards_point_to_weierstrass_point (ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, uint8_t stack) |
Convert the Edwards point P of the elliptic curve E to the corresponding Weierstrass elliptic curve point dst. More... | |
void | weierstrass_to_edwards (ec_curve_ptr E_res, ec_curve_srcptr E, const uint8_t n, fe_ptr alpha, fe_ptr beta, uint8_t stack) |
Convert the Weierstrass elliptic curve E to the one of the corresponding Edwards elliptic curve according to the choice (or not) of alpha and/or beta. More... | |
void | weierstrass_point_to_edwards_point (ec_point_ptr dst, ec_point_srcptr P, ec_curve_srcptr E, const uint8_t n, fe_ptr alpha, fe_ptr beta, uint8_t stack) |
Convert the point of the Weierstrass elliptic curve E to the elliptic curve of one of the corresponding Edwards elliptic curve according to the choice (or not) of alpha and/or beta. More... | |
Declaration of ECC functions.
Definition in file mphell-curve.h.
enum ec_algo_enum |
Define the type of coordinate.
Definition at line 56 of file mphell-curve.h.
enum ec_known_curve_enum |
Define the hardcoded curves.
Definition at line 74 of file mphell-curve.h.
enum ec_type_enum |
Define the type of curve.
Definition at line 39 of file mphell-curve.h.
void ec_alloc | ( | ec_curve_ptr | E, |
field_srcptr | k | ||
) |
Allocate a curve.
E | Elliptic curve to allocate |
k | Base field |
Definition at line 37 of file mphell-curve.c.
bool ec_belongs | ( | ec_point_srcptr | P, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Test if P belongs to E.
P | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 865 of file mphell-curve.c.
void ec_clear | ( | ec_curve_ptr | E | ) |
Clear the elliptic curve E (remove the action of ec_init, but let the one of ec_alloc)
E | Elliptic curve |
Definition at line 643 of file mphell-curve.c.
void ec_compute_disc | ( | ec_curve_ptr | E, |
uint8_t | stack | ||
) |
Set the discriminant of E.
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 580 of file mphell-curve.c.
void ec_copy | ( | ec_curve_ptr | E_res, |
ec_curve_srcptr | E | ||
) |
Copy E into E_res which has been previously allocated, beware: the same field is used, do not free it 2 times.
E_res | Resulting elliptic curve |
E | Elliptic curve |
Definition at line 618 of file mphell-curve.c.
void ec_create | ( | ec_curve_ptr | E, |
const char * | id_curve, | ||
field_srcptr | k, | ||
fe_srcptr | a, | ||
fe_srcptr | b, | ||
ec_point_srcptr | G, | ||
number_srcptr | h, | ||
number_srcptr | n, | ||
const ec_type | type, | ||
const ec_formula | f, | ||
uint8_t | stack | ||
) |
Create an elliptic curve E, the curve must be allocated and initialised (ec_alloc & ec_init)
E | Elliptic curve, previously allocated |
id_curve | Name of the curve |
k | Base field |
a | a coefficient for short Weierstrass and Jacobi Quartic elliptic curve |
b | b coefficient for short Weierstrass elliptic curve |
G | Base point |
h | Cofactor of the order of G |
n | Order of G |
type | Type of elliptic curve |
f | Type of coordinate system |
stack | Temporary memory stack to use |
Definition at line 62 of file mphell-curve.c.
void ec_curve_print | ( | ec_curve_srcptr | E, |
const uint8_t | base, | ||
uint8_t | stack | ||
) |
Print a description of E.
E | Elliptic curve |
base | Base used to print the parameters (either 10 or 16) |
stack | Temporary memory stack to use |
Definition at line 1036 of file mphell-curve.c.
void ec_curve_str | ( | char ** | str, |
ec_curve_srcptr | E, | ||
const uint8_t | base, | ||
uint8_t | stack | ||
) |
Allocate *str and write in it the description of E.
str | Pointer to a string, allocated by the function. |
E | Elliptic curve |
base | Base used to write the parameters (either 10 or 16) |
stack | Temporary memory stack to use |
Definition at line 932 of file mphell-curve.c.
void ec_free | ( | ec_curve_ptr | E | ) |
Free the elliptic curve E.
E | Elliptic curve |
Definition at line 655 of file mphell-curve.c.
void ec_init | ( | ec_curve_ptr | E, |
field_srcptr | k | ||
) |
Initialise a curve.
E | Elliptic curve to initialise |
k | Base field |
Definition at line 52 of file mphell-curve.c.
void ec_point_2mul_with_precomp | ( | ec_point_ptr | P3, |
number_srcptr | n1, | ||
ec_point * | tab_P1, | ||
number_srcptr | n2, | ||
ec_point * | tab_P2, | ||
int16_t | win_size, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Set P3 to n1 * P1 + n2 * P2 using 2 precomputated array.
P3 | Destination point |
n1 | Scalar to multiply P1 with |
tab_P1 | Array of precomputed [P1, 2P1, 3P1, ..., (2^e - 1)P1] |
n2 | Scalar to multiply P2 with |
tab_P2 | Array of precomputed [P2, 2P2, 3P2, ..., (2^e - 1)P2] |
win_size | Size of the windows |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1611 of file mphell-curve.c.
void ec_point_add | ( | 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)
P3 | Resulting point |
P1 | Source point |
P2 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1291 of file mphell-curve.c.
void ec_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)
P3 | Resulting point |
P1 | Source point |
P2 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1138 of file mphell-curve.c.
void ec_point_alloc | ( | ec_point_ptr | P, |
field_srcptr | k | ||
) |
Allocate an elliptic curve point.
P | Point to allocate |
k | Base field |
Definition at line 673 of file mphell-curve.c.
bool ec_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.
P1 | Point |
P2 | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1095 of file mphell-curve.c.
void ec_point_clear | ( | ec_point_ptr | P, |
field_srcptr | k | ||
) |
Clear the point P (remove the action of ec_point_init, but let the one of ec_point_alloc)
P | Point to clear |
k | Base field |
Definition at line 691 of file mphell-curve.c.
void ec_point_copy | ( | ec_point_ptr | P3, |
ec_point_srcptr | P, | ||
field_srcptr | k | ||
) |
Copy P into P3.
P3 | Destination point |
P | Point |
k | Base field |
Definition at line 709 of file mphell-curve.c.
void ec_point_dbl | ( | 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)
P3 | Resulting point |
P1 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1312 of file mphell-curve.c.
void ec_point_dbl_unified | ( | ec_point_ptr | P3, |
ec_point_srcptr | P1, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Set P3 to 2*P1, using unified formulae (protection against SPA)
P3 | Resulting point |
P1 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1162 of file mphell-curve.c.
void ec_point_free | ( | ec_point_ptr | P, |
field_srcptr | k | ||
) |
Free the point P.
P | Point to free |
k | Base field |
Definition at line 700 of file mphell-curve.c.
|
inlinestatic |
Get an initialised point from the pool.
P | Point |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 202 of file mphell-curve.h.
void ec_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.
x | P->x in affine coordinates |
P | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 818 of file mphell-curve.c.
void ec_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.
y | P->y in affine coordinates |
P | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 837 of file mphell-curve.c.
void ec_point_init | ( | ec_point_ptr | P, |
field_srcptr | k | ||
) |
Initialise an elliptic curve point.
P | Point to allocate |
k | Base field |
Definition at line 682 of file mphell-curve.c.
bool ec_point_is_neutral | ( | ec_point_srcptr | P, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Test if P is the neutral element.
P | Point to test |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1075 of file mphell-curve.c.
void ec_point_lift | ( | ec_point_ptr | P, |
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Lift the coordinates from Montgomery basis to classical arithmetic.
P | Point |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 856 of file mphell-curve.c.
void ec_point_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 Montgomery for Weierstrass elliptic curve, and naive method for other elliptic curve type, using dedicated formulae (not protected against SPA execpt in WEIESTRASS / JACOBIAN case, but faster)
P3 | Destination point |
n | Scalar to multiply P1 with |
P1 | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1779 of file mphell-curve.c.
void ec_point_mul_unified | ( | 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 for Weierstrass elliptic curve, and naive method for other elliptic curve type, using unified formulae (protection against SPA)
P3 | Destination point |
n | Scalar to multiply P1 with |
P1 | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1242 of file mphell-curve.c.
void ec_point_mul_with_precomp | ( | ec_point_ptr | P3, |
number_srcptr | n, | ||
ec_point * | tab_P1, | ||
int16_t | win_size, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Set P3 to n * P1 using naive double and add method, Montgomery and Joye multiplication are also available for Weierstrass elliptic curve, using dedicated formulae (not protected against SPA, but faster)
P3 | Destination point |
n | Scalar to multiply P1 with |
tab_P1 | Array of precomputed [P1, 3P1, 5P1, ..., (2^e - 1)P1] |
win_size | Size of the windows |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1559 of file mphell-curve.c.
void ec_point_neg | ( | ec_point_ptr | P3, |
ec_point_srcptr | P1, | ||
ec_curve_srcptr | E | ||
) |
Set P3 to -P1.
P3 | Resulting point |
P1 | Source point |
E | Elliptic curve |
Definition at line 1117 of file mphell-curve.c.
void ec_point_norm | ( | ec_point_ptr | P, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert a point in projective or jacobian coordinate to an affine point (x,y)
P | Point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 799 of file mphell-curve.c.
void ec_point_print | ( | ec_point_srcptr | P, |
const uint8_t | base, | ||
const bool | lift, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Print a description of P.
P | Point |
base | Base used to print the coordinates (either 10 or 16) |
lift | If Montgomery is used, lift P coordinates to classical fp. |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 1064 of file mphell-curve.c.
void ec_point_random | ( | ec_point_ptr | P, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Create a random point P on the elliptic curve E.
P | Destination point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 885 of file mphell-curve.c.
|
inlinestatic |
Relax an initialised point from the pool.
P | Point |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 218 of file mphell-curve.h.
void ec_point_set | ( | ec_point_ptr | P, |
fe_srcptr | x, | ||
fe_srcptr | y, | ||
fe_srcptr | z, | ||
fe_srcptr | t, | ||
field_srcptr | k | ||
) |
Set a point from its coordinates.
P | Destination point |
x | x-coordinate of P |
y | y-coordinate of P |
z | z-coordinate of P |
t | t-coordinate of P |
k | Base field |
Definition at line 718 of file mphell-curve.c.
void ec_point_set_aff | ( | ec_point_ptr | P, |
fe_srcptr | x, | ||
fe_srcptr | y, | ||
const ec_type | type, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set a point from its affine coordinates.
P | Destination point |
x | x-coordinate of P |
y | y-coordinate of P |
type | Type of elliptic curve |
stack | Temporary memory stack to use |
Definition at line 739 of file mphell-curve.c.
void ec_point_set_aff_str | ( | ec_point_ptr | P, |
const char * | str_x, | ||
const char * | str_y, | ||
const bool | is_reduced, | ||
const uint8_t | base, | ||
const ec_type | type, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set a point from its affine coordinates under string format.
P | Destination point |
x | x-coordinate of P under string form |
y | y-coordinate of P under string form |
is_reduced | True if the coordinates are already reduced in k, false otherwise |
base | Base used to read the coordinate (either 10 or 16) |
type | Type of elliptic curve |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 759 of file mphell-curve.c.
void ec_point_set_neutral | ( | ec_point_ptr | dst, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Set dst to the neutral element.
dst | Destination point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 780 of file mphell-curve.c.
void ec_point_set_str | ( | ec_point_ptr | P, |
const char * | str_x, | ||
const char * | str_y, | ||
const char * | str_z, | ||
const char * | str_t, | ||
const bool | is_reduced, | ||
const uint8_t | base, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Set a point from its coordinates under string format.
P | Destination point |
x | x-coordinate of P under string form |
y | y-coordinate of P under string form |
z | z-coordinate of P under string form |
t | t-coordinate of P under string form |
is_reduced | True if the coordinates are already in Montgomery form, false otherwise |
base | Base used to read the coordinate (either 10 or 16) |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 728 of file mphell-curve.c.
void ec_point_str | ( | char ** | str, |
ec_point_srcptr | P, | ||
const uint8_t | base, | ||
const bool | lift, | ||
field_srcptr | k, | ||
uint8_t | stack | ||
) |
Allocate *str and write in it the description of P.
str | Pointer to a string, allocated by the function. |
P | Point |
base | Base used to write the coordinates (either 10 or 16) |
lift | If Montgomery is used, lift P coordinates to classical fp. |
k | Base field |
stack | Temporary memory stack to use |
Definition at line 1045 of file mphell-curve.c.
void ec_point_sub | ( | 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)
P3 | Resulting point |
P1 | Source point |
P2 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1332 of file mphell-curve.c.
void ec_point_sub_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)
P3 | Resulting point |
P1 | Source point |
P2 | Source point |
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 1185 of file mphell-curve.c.
void ec_random | ( | ec_curve_ptr | E, |
const char * | id_curve, | ||
char * | seed_res, | ||
field_srcptr | k, | ||
const ec_type | type, | ||
const ec_formula | f, | ||
uint8_t | stack | ||
) |
Create a random elliptic curve E, not cryptographically secure (not tested to be). Algorithm A.3.3.2 from ANS X9.62-1998.
E | Elliptic curve, previously allocated |
id_curve | Name of the curve |
seed_res | Random seed use to generate the curve, 160 bits under hexadecimal form. Use a string of length 41 to store it. |
type | Type of elliptic curve |
f | Type of coordinate system |
stack | Temporary memory stack to use |
Definition at line 495 of file mphell-curve.c.
void ec_set_fast_dedicated_coordinates | ( | ec_curve_ptr | E | ) |
Set the fastest dedicated coordinates system.
E | Elliptic curve |
Definition at line 562 of file mphell-curve.c.
void ec_set_fast_unified_coordinates | ( | ec_curve_ptr | E | ) |
Set the fastest unified coordinates system.
E | Elliptic curve |
Definition at line 544 of file mphell-curve.c.
void ec_test_spec | ( | ec_curve_ptr | E, |
uint8_t | stack | ||
) |
Set the E->ec_spec1 to true if E->a = -3 mod p, false otherwise.
E | Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 599 of file mphell-curve.c.
void ec_use_curve | ( | ec_curve_ptr | E, |
field_ptr | k, | ||
const ec_known_curve | id_curve, | ||
const ec_formula | f, | ||
uint8_t | stack | ||
) |
Create the elliptic curve (and the associated base field) id_curve, the curve and the field must me allocated (field_alloc & ec_alloc).
E | Elliptic curve, previously allocated |
k | Base field, previously allocated |
id_curve | Name of the curve, see ec_known_curve_enum |
f | Type of coordinate system |
stack | Temporary memory stack to use |
Definition at line 114 of file mphell-curve.c.
bool ec_verify_random_generation | ( | ec_curve_ptr | E, |
const char * | seed, | ||
uint8_t | stack | ||
) |
Test if E if generated from the seed "seed", using algorithm A.3.4.2 from ANS X9.62-1998. Only curve generated with the algorithm A.3.3.2 can be tested.
E | Elliptic curve to test |
seed | Seed (of 160 bits) used to generate an elliptic curve, under hexadecimal form. |
stack | Temporary memory stack to use |
Definition at line 523 of file mphell-curve.c.
void edwards_point_to_weierstrass_point | ( | ec_point_ptr | dst, |
ec_point_srcptr | P, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert the Edwards point P of the elliptic curve E to the corresponding Weierstrass elliptic curve point dst.
dst | Elliptic curve destination point |
P | Elliptic curve point |
E | Edwards Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 2247 of file mphell-curve.c.
void edwards_to_weierstrass | ( | ec_curve_ptr | E_res, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert the Edwards elliptic curve E to the corresponding Weierstrass elliptic curve E_res.
E_res | Weierstrass Elliptic curve |
E | Edwards Elliptic curve |
stack | Temporary memory stack to use |
Definition at line 2144 of file mphell-curve.c.
void jacobi_quartic_point_to_weierstrass_point | ( | ec_point_ptr | dst, |
ec_point_srcptr | P1, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert a point on a jacobi quartic elliptic curve to a point on a weierstrass elliptic curve.
dst | Resulting point (weierstrass point) |
P | Source point (jacobi quartic point) |
E | Elliptic curve (Jacobi quartic) |
stack | Temporary memory stack to use |
Definition at line 1816 of file mphell-curve.c.
void jacobi_quartic_to_weierstrass | ( | ec_curve_ptr | E_res, |
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert a jacobi quartic elliptic curve into a Weierstrass elliptic curve.
E_res | Resulting elliptic curve (Weierstrass) |
E | Source elliptic curve (Jacobi quartic) |
stack | Temporary memory stack to use |
Definition at line 1888 of file mphell-curve.c.
void weierstrass_point_to_edwards_point | ( | ec_point_ptr | dst, |
ec_point_srcptr | P, | ||
ec_curve_srcptr | E, | ||
const uint8_t | n, | ||
fe_ptr | alpha, | ||
fe_ptr | beta, | ||
uint8_t | stack | ||
) |
Convert the point of the Weierstrass elliptic curve E to the elliptic curve of one of the corresponding Edwards elliptic curve according to the choice (or not) of alpha and/or beta.
dst | Edwards Elliptic curve destination point |
P | Weierstrass Elliptic curve point |
E | Edwards Elliptic curve |
n | Integer indicating the number of variables between alpha and beta fixed by the user 2 if the both are fixed 1 if only alpha is fixed and 0 if the choice is let to the program |
alpha | Field element |
beta | Field element |
stack | Temporary memory stack to use |
Definition at line 2430 of file mphell-curve.c.
void weierstrass_point_to_jacobi_quartic_point | ( | ec_point_ptr | dst, |
ec_point_srcptr | P1, | ||
ec_curve_srcptr | E, | ||
uint8_t | stack | ||
) |
Convert a point on a weierstrass elliptic curve to a point on a jacobi quartic elliptic curve.
dst | Resulting point (jacobi quartic point) |
P | Source point (Weierstrass point) |
E | Elliptic curve (Jacobi quartic) |
stack | Temporary memory stack to use |
Definition at line 1949 of file mphell-curve.c.
void weierstrass_to_edwards | ( | ec_curve_ptr | E_res, |
ec_curve_srcptr | E, | ||
const uint8_t | n, | ||
fe_ptr | alpha, | ||
fe_ptr | beta, | ||
uint8_t | stack | ||
) |
Convert the Weierstrass elliptic curve E to the one of the corresponding Edwards elliptic curve according to the choice (or not) of alpha and/or beta.
E_res | Edwards Elliptic curve |
E | Weierstrass Elliptic curve |
n | Integer indicating the number of variables between alpha and beta fixed by the user 2 if the both are fixed 1 if only alpha is fixed and 0 if the choice is let to the program |
alpha | Field element |
beta | Field element |
stack | Temporary memory stack to use |
Definition at line 2308 of file mphell-curve.c.
void weierstrass_to_jacobi_quartic | ( | ec_curve_ptr | E_res, |
ec_curve_srcptr | E, | ||
const bool | determined, | ||
fe_ptr | teta, | ||
uint8_t | stack | ||
) |
Convert a Weierstrass elliptic curve into a jacobi quartic elliptic curve.
E_res | Resulting elliptic curve (Jacobi quartic) |
E | Source elliptic curve (Weierstrass) |
determined | Boolean equals to false if theta is not specified then we make the assumption that b_j=1 otherwise theta is specified |
teta | Field element such as (teta, 0) is a 2-torsion point on E |
stack | Temporary memory stack to use |
Definition at line 2028 of file mphell-curve.c.