ed25519-donna: Add ed25519_scalarmult

pull/25/head
Saleem Rashid 7 years ago committed by Pavol Rusnak
parent 6e51be6fe2
commit 1caade58b3

@ -12,6 +12,8 @@ void ed25519_publickey_keccak(const ed25519_secret_key sk, ed25519_public_key pk
int ed25519_sign_open_keccak(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
void ed25519_sign_keccak(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
int ed25519_scalarmult_keccak(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
#if defined(__cplusplus)
}
#endif

@ -12,6 +12,8 @@ void ed25519_publickey_sha3(const ed25519_secret_key sk, ed25519_public_key pk);
int ed25519_sign_open_sha3(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
void ed25519_sign_sha3(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
int ed25519_scalarmult_sha3(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
#if defined(__cplusplus)
}
#endif

@ -139,6 +139,26 @@ ED25519_FN(ed25519_sign_open) (const unsigned char *m, size_t mlen, const ed2551
return ed25519_verify(RS, checkR, 32) ? 0 : -1;
}
int
ED25519_FN(ed25519_scalarmult) (ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk) {
bignum256modm a;
ge25519 ALIGN(16) A, P;
hash_512bits extsk;
ed25519_extsk(extsk, sk);
expand256_modm(a, extsk, 32);
if (!ge25519_unpack_negative_vartime(&P, pk)) {
return -1;
}
ge25519_scalarmult(&A, &P, a);
curve25519_neg(A.x, A.x);
ge25519_pack(res, &A);
return 0;
}
#ifndef ED25519_SUFFIX
#include "curve25519-donna-scalarmult-base.h"

@ -18,6 +18,8 @@ void ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk);
int ed25519_sign_open(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
void ed25519_sign(const unsigned char *m, size_t mlen, const ed25519_secret_key sk, const ed25519_public_key pk, ed25519_signature RS);
int ed25519_scalarmult(ed25519_public_key res, const ed25519_secret_key sk, const ed25519_public_key pk);
void curve25519_scalarmult(curve25519_key mypublic, const curve25519_key secret, const curve25519_key basepoint);
void curve25519_scalarmult_basepoint(curve25519_key mypublic, const curve25519_key secret);

Loading…
Cancel
Save