1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00

ed25519-donna: Add ed25519_scalarmult

This commit is contained in:
Saleem Rashid 2017-06-01 16:08:55 +01:00 committed by Pavol Rusnak
parent 6e51be6fe2
commit 1caade58b3
4 changed files with 26 additions and 0 deletions

View File

@ -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); 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); 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) #if defined(__cplusplus)
} }
#endif #endif

View File

@ -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); 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); 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) #if defined(__cplusplus)
} }
#endif #endif

View File

@ -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; 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 #ifndef ED25519_SUFFIX
#include "curve25519-donna-scalarmult-base.h" #include "curve25519-donna-scalarmult-base.h"

View File

@ -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); 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); 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(curve25519_key mypublic, const curve25519_key secret, const curve25519_key basepoint);
void curve25519_scalarmult_basepoint(curve25519_key mypublic, const curve25519_key secret); void curve25519_scalarmult_basepoint(curve25519_key mypublic, const curve25519_key secret);