#ifndef WOLF_CRYPT_GE_OPERATIONS_H
#define WOLF_CRYPT_GE_OPERATIONS_H
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/fe_operations.h>
#if defined(HAVE_ED25519) || defined(WOLFSSL_CURVE25519_USE_ED25519)
#ifdef ED25519_SMALL
ALIGN16 typedef byte ge[F25519_SIZE];
#elif defined(CURVED25519_ASM_64BIT)
ALIGN16 typedef sword64 ge[4];
#elif defined(CURVED25519_ASM_32BIT)
ALIGN16 typedef sword32 ge[8];
#elif defined(CURVED25519_128BIT)
ALIGN16 typedef sword64 ge[5];
#else
ALIGN16 typedef sword32 ge[10];
#endif
typedef struct {
ge X;
ge Y;
ge Z;
} ge_p2;
typedef struct {
ge X;
ge Y;
ge Z;
ge T;
} ge_p3;
#ifdef __cplusplus
extern "C" {
#endif
WOLFSSL_LOCAL int ge_compress_key(byte* out, const byte* xIn, const byte* yIn,
word32 keySz);
WOLFSSL_LOCAL int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s);
WOLFSSL_LOCAL int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
const ge_p3 *A, const unsigned char *b);
WOLFSSL_LOCAL void ge_scalarmult_base(ge_p3 *h,const unsigned char *a);
WOLFSSL_LOCAL void sc_reduce(byte* s);
WOLFSSL_LOCAL void sc_muladd(byte* s, const byte* a, const byte* b,
const byte* c);
WOLFSSL_LOCAL void ge_tobytes(unsigned char *s,const ge_p2 *h);
#ifndef ED25519_SMALL
WOLFSSL_LOCAL void ge_tobytes_nct(unsigned char *s,const ge_p2 *h);
#else
#define ge_tobytes_nct ge_tobytes
#endif
#ifndef GE_P3_TOBYTES_IMPL
#define ge_p3_tobytes(s, h) ge_tobytes((s), (const ge_p2 *)(h))
#else
WOLFSSL_LOCAL void ge_p3_tobytes(unsigned char *s,const ge_p3 *h);
#endif
#ifndef ED25519_SMALL
typedef struct {
ge X;
ge Y;
ge Z;
ge T;
} ge_p1p1;
typedef struct {
ge yplusx;
ge yminusx;
ge xy2d;
} ge_precomp;
typedef struct {
ge YplusX;
ge YminusX;
ge Z;
ge T2d;
} ge_cached;
#ifdef CURVED25519_ASM
WOLFSSL_LOCAL void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p);
WOLFSSL_LOCAL void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p);
WOLFSSL_LOCAL void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p);
#define ge_p3_dbl(r, p) ge_p2_dbl((ge_p1p1 *)(r), (const ge_p2 *)(p))
WOLFSSL_LOCAL void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q);
WOLFSSL_LOCAL void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q);
WOLFSSL_LOCAL void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
WOLFSSL_LOCAL void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif