amd64-{51-30k,64-24k} impls should work now

This commit is contained in:
cathugger
2017-09-27 15:41:59 +03:00
parent 59f318aa64
commit 966cf38205
16 changed files with 135 additions and 66 deletions

View File

@@ -4,5 +4,6 @@
#define crypto_sign_seckey_expand ed25519_amd64_64_seckey_expand
#define crypto_sign_pubkey ed25519_amd64_64_pubkey
#define crypto_sign_open ed25519_amd64_64_open
#define crypto_sign_open_batch ed25519_amd64_64_open_batch
#include "ed25519.h"

View File

@@ -2,3 +2,19 @@ int ed25519_amd64_64_seckey(unsigned char *sk);
int ed25519_amd64_64_seckey_expand(unsigned char *sk,const unsigned char *seed);
int ed25519_amd64_64_pubkey(unsigned char *pk,const unsigned char *sk);
int ed25519_amd64_64_keygen(unsigned char *pk,unsigned char *sk);
int ed25519_amd64_64_sign(
unsigned char *sm,unsigned long long *smlen,
const unsigned char *m,unsigned long long mlen,
const unsigned char *sk
);
int ed25519_amd64_64_open(
unsigned char *m,unsigned long long *mlen,
const unsigned char *sm,unsigned long long smlen,
const unsigned char *pk
);
int ed25519_amd64_64_open_batch(
unsigned char* const m[],unsigned long long mlen[],
unsigned char* const sm[],const unsigned long long smlen[],
unsigned char* const pk[],
unsigned long long num
);

View File

@@ -1,3 +1,8 @@
#include <sodium/randombytes.h>
#define randombytes(b,n) \
(randombytes(b,n), 0)
static inline int randombytes_wrap(unsigned char *b,size_t l)
{
randombytes(b,l);
return 0;
}
#define randombytes randombytes_wrap

View File

@@ -10,24 +10,18 @@ int crypto_sign(
)
{
unsigned char pk[32];
unsigned char az[64];
unsigned char nonce[64];
unsigned char hram[64];
sc25519 sck, scs, scsk;
ge25519 ger;
memmove(pk,sk + 32,32);
/* sk: 32-byte scalar a, 32-byte randomizer z */
crypto_sign_pubkey(pk,sk);
/* pk: 32-byte public key A */
crypto_hash_sha512(az,sk,32);
az[0] &= 248;
az[31] &= 127;
az[31] |= 64;
/* az: 32-byte scalar a, 32-byte randomizer z */
*smlen = mlen + 64;
memmove(sm + 64,m,mlen);
memmove(sm + 32,az + 32,32);
memmove(sm + 32,sk + 32,32);
/* sm: 32-byte uninit, 32-byte z, mlen-byte m */
crypto_hash_sha512(nonce, sm+32, mlen+32);
@@ -45,7 +39,7 @@ int crypto_sign(
/* hram: 64-byte H(R,A,m) */
sc25519_from64bytes(&scs, hram);
sc25519_from32bytes(&scsk, az);
sc25519_from32bytes(&scsk, sk);
sc25519_mul(&scs, &scs, &scsk);
sc25519_add(&scs, &scs, &sck);
/* scs: S = nonce + H(R,A,m)a */