From f521d4c7a97076db34681c598d7965c7d05713b0 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 10 May 2017 21:01:03 +0100 Subject: [PATCH] math/f{25519,goldi}.[ch]: Export the piece type. --- math/f25519.c | 6 ++++-- math/f25519.h | 7 +++++++ math/fgoldi.c | 6 ++++-- math/fgoldi.h | 7 +++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/math/f25519.c b/math/f25519.c index 6dfc511c..a58a68a9 100644 --- a/math/f25519.c +++ b/math/f25519.c @@ -34,13 +34,15 @@ /*----- Basic setup -------------------------------------------------------*/ +typedef f25519_piece piece; + #if F25519_IMPL == 26 /* Elements x of GF(2^255 - 19) are represented by ten signed integers x_i: x * = SUM_{0<=i<10} x_i 2^ceil(51i/2), mostly following Bernstein's original * paper. */ -typedef int32 piece; typedef int64 dblpiece; + typedef int64 dblpiece; typedef uint32 upiece; typedef uint64 udblpiece; #define P p26 #define PIECEWD(i) ((i)%2 ? 25 : 26) @@ -74,7 +76,7 @@ typedef uint32 upiece; typedef uint64 udblpiece; * except for pieces 5, 10, 15, 20, and 25 which have 9 bits. */ -typedef int16 piece; typedef int32 dblpiece; + typedef int32 dblpiece; typedef uint16 upiece; typedef uint32 udblpiece; #define P p10 #define PIECEWD(i) \ diff --git a/math/f25519.h b/math/f25519.h index fc755464..4a2a2191 100644 --- a/math/f25519.h +++ b/math/f25519.h @@ -55,6 +55,13 @@ typedef union { # define F25519_IMPL 10 #endif +#if F25519_IMPL == 26 + typedef int32 f25519_piece; +#endif +#if F25519_IMPL == 10 + typedef int16 f25519_piece; +#endif + /*----- Functions provided ------------------------------------------------*/ /* --- @f25519_set@ --- * diff --git a/math/fgoldi.c b/math/fgoldi.c index 5b2889fb..afc43329 100644 --- a/math/fgoldi.c +++ b/math/fgoldi.c @@ -37,12 +37,14 @@ * (hence the name). */ +typedef fgoldi_piece piece; + #if FGOLDI_IMPL == 28 /* We represent an element of GF(p) as 16 28-bit signed integer pieces x_i: * x = SUM_{0<=i<16} x_i 2^(28i). */ -typedef int32 piece; typedef int64 dblpiece; + typedef int64 dblpiece; typedef uint32 upiece; typedef uint64 udblpiece; #define PIECEWD(i) 28 #define NPIECE 16 @@ -61,7 +63,7 @@ typedef uint32 upiece; typedef uint64 udblpiece; * bits. */ -typedef int16 piece; typedef int32 dblpiece; + typedef int32 dblpiece; typedef uint16 upiece; typedef uint32 udblpiece; #define PIECEWD(i) ((i)%5 ? 11 : 12) #define NPIECE 40 diff --git a/math/fgoldi.h b/math/fgoldi.h index b05fd77e..4f6c043f 100644 --- a/math/fgoldi.h +++ b/math/fgoldi.h @@ -55,6 +55,13 @@ typedef union { # define FGOLDI_IMPL 12 #endif +#if FGOLDI_IMPL == 28 + typedef int32 fgoldi_piece; +#endif +#if FGOLDI_IMPL == 12 + typedef int16 fgoldi_piece; +#endif + /*----- Functions provided ------------------------------------------------*/ /* --- @fgoldi_load@ --- * -- 2.11.0