finish porting to amd64-64-24k

This commit is contained in:
cathugger 2019-01-20 01:29:02 +02:00
parent 596ebfc71a
commit 9972a833a8
No known key found for this signature in database
GPG key ID: 9BADDA2DAF6F01A8
3 changed files with 44 additions and 16 deletions

View file

@ -81,6 +81,9 @@ extern int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]);
extern void ge25519_pack(unsigned char r[32], const ge25519 *p); extern void ge25519_pack(unsigned char r[32], const ge25519 *p);
extern void ge25519_batchpack_destructive_1(bytes32 out[], ge25519_p3 in[], fe25519 *inz[], fe25519 tmp[], size_t num);
extern void ge25519_batchpack_destructive_finish(bytes32 out, ge25519_p3 *unf);
extern int ge25519_isneutral_vartime(const ge25519 *p); extern int ge25519_isneutral_vartime(const ge25519 *p);
extern void ge25519_add(ge25519 *r, const ge25519 *p, const ge25519 *q); extern void ge25519_add(ge25519 *r, const ge25519 *p, const ge25519 *q);

View file

@ -2,6 +2,7 @@
#define ED25519_SECRETKEYBYTES 64 #define ED25519_SECRETKEYBYTES 64
#define ED25519_PUBLICKEYBYTES 32 #define ED25519_PUBLICKEYBYTES 32
#ifdef ED25519_ref10 #ifdef ED25519_ref10
#include "ref10/ed25519.h" #include "ref10/ed25519.h"
#define ed25519_seckey ed25519_ref10_seckey #define ed25519_seckey ed25519_ref10_seckey
@ -10,6 +11,8 @@
#define ed25519_keygen ed25519_ref10_keygen #define ed25519_keygen ed25519_ref10_keygen
#include "ref10/ge.h" #include "ref10/ge.h"
#define GEZ(x) ((x).Z)
/* The basepoint multiplied by 8. */ /* The basepoint multiplied by 8. */
static const ge_cached ge_eightpoint = { static const ge_cached ge_eightpoint = {
/* YplusX */ /* YplusX */
@ -36,13 +39,38 @@ static const ge_cached ge_eightpoint = {
inline static void ge_initeightpoint() {} inline static void ge_initeightpoint() {}
#endif #endif
#ifdef ED25519_amd64_51_30k
#define ED25519_amd64_common
#else
#ifdef ED25519_amd64_64_24k
#define ED25519_amd64_common
#endif
#endif
#ifdef ED25519_amd64_51_30k #ifdef ED25519_amd64_51_30k
#include "amd64-51-30k/ed25519.h" #include "amd64-51-30k/ed25519.h"
#include "amd64-51-30k/ge25519.h"
#define ed25519_seckey ed25519_amd64_51_30k_seckey #define ed25519_seckey ed25519_amd64_51_30k_seckey
#define ed25519_seckey_expand ed25519_amd64_51_30k_seckey_expand #define ed25519_seckey_expand ed25519_amd64_51_30k_seckey_expand
#define ed25519_pubkey ed25519_amd64_51_30k_pubkey #define ed25519_pubkey ed25519_amd64_51_30k_pubkey
#define ed25519_keygen ed25519_amd64_51_30k_keygen #define ed25519_keygen ed25519_amd64_51_30k_keygen
#include "amd64-51-30k/ge25519.h" #endif
#ifdef ED25519_amd64_64_24k
#include "amd64-64-24k/ed25519.h"
#include "amd64-64-24k/ge25519.h"
#define ed25519_seckey ed25519_amd64_64_seckey
#define ed25519_seckey_expand ed25519_amd64_64_seckey_expand
#define ed25519_pubkey ed25519_amd64_64_pubkey
#define ed25519_keygen ed25519_amd64_64_keygen
#endif
// common
#ifdef ED25519_amd64_common
#define fe fe25519
#define ge_p1p1 ge25519_p1p1 #define ge_p1p1 ge25519_p1p1
#define ge_p3 ge25519_p3 #define ge_p3 ge25519_p3
#define ge_cached ge25519_pniels #define ge_cached ge25519_pniels
@ -50,6 +78,14 @@ inline static void ge_initeightpoint() {}
#define ge_p3_tobytes ge25519_pack #define ge_p3_tobytes ge25519_pack
#define ge_add ge25519_pnielsadd_p1p1 #define ge_add ge25519_pnielsadd_p1p1
#define ge_p3_batchtobytes_destructive_1 ge25519_batchpack_destructive_1
#define ge_p3_batchtobytes_destructive_finish ge25519_batchpack_destructive_finish
#define GEZ(x) ((x).z)
#endif
#ifdef ED25519_amd64_51_30k
static inline void ge_scalarmult_base(ge_p3 *gepk,const unsigned char *sk) static inline void ge_scalarmult_base(ge_p3 *gepk,const unsigned char *sk)
{ {
sc25519 scsk; sc25519 scsk;
@ -72,20 +108,8 @@ static const ge25519_pniels ge_eightpoint = {
inline static void ge_initeightpoint() {} inline static void ge_initeightpoint() {}
#endif #endif
#ifdef ED25519_amd64_64_24k
#include "amd64-64-24k/ed25519.h"
#define ed25519_seckey ed25519_amd64_64_seckey
#define ed25519_seckey_expand ed25519_amd64_64_seckey_expand
#define ed25519_pubkey ed25519_amd64_64_pubkey
#define ed25519_keygen ed25519_amd64_64_keygen
#include "amd64-64-24k/ge25519.h"
#define ge_p1p1 ge25519_p1p1
#define ge_p3 ge25519_p3
#define ge_cached ge25519_pniels
#define ge_p1p1_to_p3 ge25519_p1p1_to_p3
#define ge_p3_tobytes ge25519_pack
#define ge_add ge25519_pnielsadd_p1p1
#ifdef ED25519_amd64_64_24k
static inline void ge_scalarmult_base(ge_p3 *gepk,const unsigned char *sk) static inline void ge_scalarmult_base(ge_p3 *gepk,const unsigned char *sk)
{ {
sc25519 scsk; sc25519 scsk;
@ -108,6 +132,7 @@ static const ge25519_pniels ge_eightpoint = {
inline static void ge_initeightpoint() {} inline static void ge_initeightpoint() {}
#endif #endif
#ifdef ED25519_donna #ifdef ED25519_donna
#define ED25519_CUSTOMRANDOM #define ED25519_CUSTOMRANDOM
#define ED25519_CUSTOMHASH #define ED25519_CUSTOMHASH

4
main.c
View file

@ -520,7 +520,7 @@ end:
#ifdef BATCHKEYGEN #ifdef BATCHKEYGEN
#ifndef BATCHNUM #ifndef BATCHNUM
#define BATCHNUM 64 #define BATCHNUM 256
#endif #endif
static void *dobatchwork(void *task) static void *dobatchwork(void *task)
@ -547,7 +547,7 @@ static void *dobatchwork(void *task)
#endif #endif
for (size_t b = 0;b < BATCHNUM;++b) for (size_t b = 0;b < BATCHNUM;++b)
batchgez[b] = &ge_batch[b].Z; batchgez[b] = &GEZ(ge_batch[b]);
PREFILTER PREFILTER