mirror of
https://github.com/neocturne/libuecc.git
synced 2025-07-06 23:19:07 +02:00
Reworked the API
This commit is contained in:
parent
f67c3f36b9
commit
bccf64ec1b
4 changed files with 96 additions and 58 deletions
|
@ -27,14 +27,14 @@
|
|||
#ifndef _LIBUECC_ECC_H_
|
||||
#define _LIBUECC_ECC_H_
|
||||
|
||||
typedef struct _ecc_public_key_256 {
|
||||
typedef union _ecc_int_256 {
|
||||
unsigned char p[32];
|
||||
} ecc_public_key_256;
|
||||
|
||||
typedef struct _ecc_secret_key_256 {
|
||||
/* old name */
|
||||
unsigned char s[32];
|
||||
} ecc_secret_key_256;
|
||||
} ecc_int_256, ecc_secret_key_256, ecc_public_key_256;
|
||||
|
||||
/* a point on the curve unpacked for efficient calculation */
|
||||
typedef struct _ecc_25519_work {
|
||||
unsigned int X[32];
|
||||
unsigned int Y[32];
|
||||
|
@ -43,20 +43,36 @@ typedef struct _ecc_25519_work {
|
|||
} ecc_25519_work;
|
||||
|
||||
|
||||
void ecc_25519_load(ecc_25519_work *out, const ecc_public_key_256 *in);
|
||||
void ecc_25519_store(ecc_public_key_256 *out, const ecc_25519_work *in);
|
||||
void ecc_25519_load_xy(ecc_25519_work *out, const ecc_int_256 *x, const ecc_int_256 *y);
|
||||
void ecc_25519_store_xy(ecc_int_256 *x, ecc_int_256 *y, const ecc_25519_work *in);
|
||||
|
||||
void ecc_25519_load_packed(ecc_25519_work *out, const ecc_int_256 *in);
|
||||
void ecc_25519_store_packed(ecc_int_256 *out, const ecc_25519_work *in);
|
||||
|
||||
int ecc_25519_is_identity(const ecc_25519_work *in);
|
||||
void ecc_25519_add(ecc_25519_work *out, const ecc_25519_work *in1, const ecc_25519_work *in2);
|
||||
void ecc_25519_double(ecc_25519_work *out, const ecc_25519_work *in);
|
||||
void ecc_25519_scalarmult(ecc_25519_work *out, const ecc_secret_key_256 *n, const ecc_25519_work *base);
|
||||
void ecc_25519_scalarmult_base(ecc_25519_work *out, const ecc_secret_key_256 *n);
|
||||
void ecc_25519_scalarmult(ecc_25519_work *out, const ecc_int_256 *n, const ecc_25519_work *base);
|
||||
void ecc_25519_scalarmult_base(ecc_25519_work *out, const ecc_int_256 *n);
|
||||
|
||||
int ecc_25519_secret_is_zero(const ecc_secret_key_256 *in);
|
||||
void ecc_25519_secret_add(ecc_secret_key_256 *out, const ecc_secret_key_256 *in1, const ecc_secret_key_256 *in2);
|
||||
void ecc_25519_secret_sub(ecc_secret_key_256 *out, const ecc_secret_key_256 *in1, const ecc_secret_key_256 *in2);
|
||||
void ecc_25519_secret_reduce(ecc_secret_key_256 *out, const ecc_secret_key_256 *in);
|
||||
void ecc_25519_secret_mult(ecc_secret_key_256 *out, const ecc_secret_key_256 *in1, const ecc_secret_key_256 *in2);
|
||||
void ecc_25519_secret_sanitize(ecc_secret_key_256 *out, const ecc_secret_key_256 *in);
|
||||
/* operations on elements of the prime field F_q for q = 2^252 + 27742317777372353535851937790883648493 */
|
||||
int ecc_25519_gf_is_zero(const ecc_int_256 *in);
|
||||
void ecc_25519_gf_add(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2);
|
||||
void ecc_25519_gf_sub(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2);
|
||||
void ecc_25519_gf_reduce(ecc_int_256 *out, const ecc_int_256 *in);
|
||||
void ecc_25519_gf_mult(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2);
|
||||
|
||||
void ecc_25519_gf_sanitize_secret(ecc_int_256 *out, const ecc_int_256 *in);
|
||||
|
||||
/* defines for the old names */
|
||||
#define ecc_25519_load ecc_25519_load_packed
|
||||
#define ecc_25519_store ecc_25519_store_packed
|
||||
|
||||
#define ecc_25519_secret_is_zero ecc_25519_gf_is_zero
|
||||
#define ecc_25519_secret_add ecc_25519_gf_add
|
||||
#define ecc_25519_secret_sub ecc_25519_gf_sub
|
||||
#define ecc_25519_secret_reduce ecc_25519_gf_reduce
|
||||
#define ecc_25519_secret_mult ecc_25519_gf_mult
|
||||
#define ecc_25519_secret_sanitize ecc_25519_gf_sanitize_secret
|
||||
|
||||
#endif /* _LIBUECC_ECC_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue