summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-07 19:07:37 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-07 19:07:37 +0100
commitbccf64ec1b9b1b139259c03907f00d97430d43c5 (patch)
tree9f3cb6f5fb0d498c596f446968923c748034531c /include
parentf67c3f36b9c4a2ab90bf7cf1380ecdb58528a133 (diff)
downloadlibuecc-bccf64ec1b9b1b139259c03907f00d97430d43c5.tar
libuecc-bccf64ec1b9b1b139259c03907f00d97430d43c5.zip
Reworked the API
Diffstat (limited to 'include')
-rw-r--r--include/libuecc/ecc.h46
1 files changed, 31 insertions, 15 deletions
diff --git a/include/libuecc/ecc.h b/include/libuecc/ecc.h
index cf584cf..b8f8bc5 100644
--- a/include/libuecc/ecc.h
+++ b/include/libuecc/ecc.h
@@ -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);
-
-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);
+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);
+
+/* 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_ */