mirror of
https://github.com/neocturne/libuecc.git
synced 2025-03-04 17:03:31 +01:00
Add _legacy suffix to functions accessing points in compressed/coordinate representation
This commit is contained in:
parent
256e972b36
commit
5f143b1c29
2 changed files with 63 additions and 9 deletions
|
@ -99,7 +99,15 @@ DEPRECATED extern const ecc_25519_work_t ecc_25519_work_default_base;
|
||||||
|
|
||||||
|
|
||||||
/** Loads a point with given coordinates into its unpacked representation */
|
/** Loads a point with given coordinates into its unpacked representation */
|
||||||
int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y);
|
int ecc_25519_load_xy_legacy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a point with given coordinates into its unpacked representation
|
||||||
|
*
|
||||||
|
* \deprecated Use \ref ecc_25519_load_xy_legacy
|
||||||
|
*/
|
||||||
|
DEPRECATED int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a point's x and y coordinates
|
* Stores a point's x and y coordinates
|
||||||
|
@ -108,14 +116,40 @@ int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_in
|
||||||
* \param y Returns the y coordinate of the point. May be NULL.
|
* \param y Returns the y coordinate of the point. May be NULL.
|
||||||
* \param in The unpacked point to store.
|
* \param in The unpacked point to store.
|
||||||
*/
|
*/
|
||||||
void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in);
|
void ecc_25519_store_xy_legacy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores a point's x and y coordinates
|
||||||
|
*
|
||||||
|
* \param x Returns the x coordinate of the point. May be NULL.
|
||||||
|
* \param y Returns the y coordinate of the point. May be NULL.
|
||||||
|
* \param in The unpacked point to store.
|
||||||
|
*
|
||||||
|
* \deprecated Use \ref ecc_25519_store_xy_legacy
|
||||||
|
*/
|
||||||
|
DEPRECATED void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in);
|
||||||
|
|
||||||
|
|
||||||
/** Loads a packed point into its unpacked representation */
|
/** Loads a packed point into its unpacked representation */
|
||||||
int ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in);
|
int ecc_25519_load_packed_legacy(ecc_25519_work_t *out, const ecc_int256_t *in);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a packed point into its unpacked representation
|
||||||
|
*
|
||||||
|
* \deprecated Use \ref ecc_25519_load_packed_legacy
|
||||||
|
*/
|
||||||
|
DEPRECATED int ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in);
|
||||||
|
|
||||||
|
|
||||||
/** Stores a point into its packed representation */
|
/** Stores a point into its packed representation */
|
||||||
void ecc_25519_store_packed(ecc_int256_t *out, const ecc_25519_work_t *in);
|
void ecc_25519_store_packed_legacy(ecc_int256_t *out, const ecc_25519_work_t *in);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores a point into its packed representation
|
||||||
|
*
|
||||||
|
* \deprecated Use \ref ecc_25519_store_packed_legacy
|
||||||
|
*/
|
||||||
|
DEPRECATED void ecc_25519_store_packed(ecc_int256_t *out, const ecc_25519_work_t *in);
|
||||||
|
|
||||||
|
|
||||||
/** Checks if a point is the identity element of the Elliptic Curve group */
|
/** Checks if a point is the identity element of the Elliptic Curve group */
|
||||||
|
|
|
@ -524,7 +524,7 @@ static void recip(uint32_t out[32], const uint32_t z[32]) {
|
||||||
/* 2^255 - 21 */ mult(out, t1, z11);
|
/* 2^255 - 21 */ mult(out, t1, z11);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y) {
|
int ecc_25519_load_xy_legacy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y) {
|
||||||
int i;
|
int i;
|
||||||
uint32_t X2[32], Y2[32], aX2[32], dX2[32], dX2Y2[32], aX2_Y2[32], _1_dX2Y2[32], r[32];
|
uint32_t X2[32], Y2[32], aX2[32], dX2[32], dX2Y2[32], aX2_Y2[32], _1_dX2Y2[32], r[32];
|
||||||
|
|
||||||
|
@ -553,7 +553,12 @@ int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_in
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in) {
|
int ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y) {
|
||||||
|
return ecc_25519_load_xy_legacy(out, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ecc_25519_store_xy_legacy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in) {
|
||||||
uint32_t X[32], Y[32], Z[32];
|
uint32_t X[32], Y[32], Z[32];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -574,7 +579,12 @@ void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in) {
|
void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in) {
|
||||||
|
ecc_25519_store_xy_legacy(x, y, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ecc_25519_load_packed_legacy(ecc_25519_work_t *out, const ecc_int256_t *in) {
|
||||||
int i;
|
int i;
|
||||||
uint32_t X2[32] /* X^2 */, aX2[32] /* aX^2 */, dX2[32] /* dX^2 */, _1_aX2[32] /* 1-aX^2 */, _1_dX2[32] /* 1-aX^2 */;
|
uint32_t X2[32] /* X^2 */, aX2[32] /* aX^2 */, dX2[32] /* dX^2 */, _1_aX2[32] /* 1-aX^2 */, _1_dX2[32] /* 1-aX^2 */;
|
||||||
uint32_t _1_1_dX2[32] /* 1/(1-aX^2) */, Y2[32] /* Y^2 */, Y[32], Yt[32];
|
uint32_t _1_1_dX2[32] /* 1/(1-aX^2) */, Y2[32] /* Y^2 */, Y[32], Yt[32];
|
||||||
|
@ -607,13 +617,23 @@ int ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_25519_store_packed(ecc_int256_t *out, const ecc_25519_work_t *in) {
|
int ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in) {
|
||||||
|
return ecc_25519_load_packed_legacy(out, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ecc_25519_store_packed_legacy(ecc_int256_t *out, const ecc_25519_work_t *in) {
|
||||||
ecc_int256_t y;
|
ecc_int256_t y;
|
||||||
|
|
||||||
ecc_25519_store_xy(out, &y, in);
|
ecc_25519_store_xy_legacy(out, &y, in);
|
||||||
out->p[31] |= (y.p[0] << 7);
|
out->p[31] |= (y.p[0] << 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ecc_25519_store_packed(ecc_int256_t *out, const ecc_25519_work_t *in) {
|
||||||
|
ecc_25519_store_packed_legacy(out, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ecc_25519_is_identity(const ecc_25519_work_t *in) {
|
int ecc_25519_is_identity(const ecc_25519_work_t *in) {
|
||||||
uint32_t Y_Z[32];
|
uint32_t Y_Z[32];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue