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

@@ -2,3 +2,13 @@ int ed25519_ref10_seckey(unsigned char *sk);
int ed25519_ref10_seckey_expand(unsigned char *sk,const unsigned char *seed);
int ed25519_ref10_pubkey(unsigned char *pk,const unsigned char *sk);
int ed25519_ref10_keygen(unsigned char *pk,unsigned char *sk);
int ed25519_ref10_sign(
unsigned char *sm,unsigned long long *smlen,
const unsigned char *m,unsigned long long mlen,
const unsigned char *sk
);
int ed25519_ref10_open(
unsigned char *m,unsigned long long *mlen,
const unsigned char *sm,unsigned long long smlen,
const unsigned char *pk
);

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

@@ -11,21 +11,15 @@ int crypto_sign(
)
{
unsigned char pk[32];
unsigned char az[64];
unsigned char nonce[64];
unsigned char hram[64];
ge_p3 R;
memmove(pk,sk + 32,32);
crypto_hash_sha512(az,sk,32);
az[0] &= 248;
az[31] &= 63;
az[31] |= 64;
crypto_sign_pubkey(pk,sk);
*smlen = mlen + 64;
memmove(sm + 64,m,mlen);
memmove(sm + 32,az + 32,32);
memmove(sm + 32,sk + 32,32);
crypto_hash_sha512(nonce,sm + 32,mlen + 32);
memmove(sm + 32,pk,32);
@@ -35,7 +29,7 @@ int crypto_sign(
crypto_hash_sha512(hram,sm,mlen + 64);
sc_reduce(hram);
sc_muladd(sm + 32,hram,az,nonce);
sc_muladd(sm + 32,hram,sk,nonce);
return 0;
}