mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 10:51:00 +00:00
refactor(crypto): Clean up ed25519_publickey_ext() API.
This commit is contained in:
parent
b9e2ca9a9d
commit
093fbecb7a
@ -490,8 +490,7 @@ int hdnode_fill_public_key(HDNode *node) {
|
||||
curve25519_scalarmult_basepoint(node->public_key + 1, node->private_key);
|
||||
#if USE_CARDANO
|
||||
} else if (node->curve == &ed25519_cardano_info) {
|
||||
ed25519_publickey_ext(node->private_key, node->private_key_extension,
|
||||
node->public_key + 1);
|
||||
ed25519_publickey_ext(node->private_key, node->public_key + 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -59,17 +59,11 @@ ED25519_FN(ed25519_publickey) (const ed25519_secret_key sk, ed25519_public_key p
|
||||
|
||||
#if USE_CARDANO
|
||||
void
|
||||
ED25519_FN(ed25519_publickey_ext) (const ed25519_secret_key sk, const ed25519_secret_key skext, ed25519_public_key pk) {
|
||||
ED25519_FN(ed25519_publickey_ext) (const ed25519_secret_key extsk, ed25519_public_key pk) {
|
||||
bignum256modm a = {0};
|
||||
ge25519 ALIGN(16) A;
|
||||
hash_512bits extsk = {0};
|
||||
|
||||
/* we don't stretch the key through hashing first since its already 64 bytes */
|
||||
|
||||
memcpy(extsk, sk, 32);
|
||||
memcpy(extsk+32, skext, 32);
|
||||
expand256_modm(a, extsk, 32);
|
||||
memzero(&extsk, sizeof(extsk));
|
||||
ge25519_scalarmult_base_niels(&A, ge25519_niels_base_multiples, a);
|
||||
memzero(&a, sizeof(a));
|
||||
ge25519_pack(pk, &A);
|
||||
|
@ -17,7 +17,7 @@ typedef unsigned char ed25519_cosi_signature[32];
|
||||
|
||||
void ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk);
|
||||
#if USE_CARDANO
|
||||
void ed25519_publickey_ext(const ed25519_secret_key sk, const ed25519_secret_key skext, ed25519_public_key pk);
|
||||
void ed25519_publickey_ext(const ed25519_secret_key extsk, ed25519_public_key pk);
|
||||
#endif
|
||||
|
||||
int ed25519_sign_open(const unsigned char *m, size_t mlen, const ed25519_public_key pk, const ed25519_signature RS);
|
||||
|
@ -89,7 +89,7 @@ START_TEST(test_ed25519_cardano_sign_vectors) {
|
||||
memcpy(secret_key_extension, fromhex(*(test_data + 1)), 32);
|
||||
MARK_SECRET_DATA(secret_key_extension, sizeof(secret_key_extension));
|
||||
|
||||
ed25519_publickey_ext(secret_key, secret_key_extension, public_key);
|
||||
ed25519_publickey_ext(secret_key, public_key);
|
||||
UNMARK_SECRET_DATA(public_key, sizeof(public_key));
|
||||
|
||||
ck_assert_mem_eq(public_key, fromhex(*(test_data + 2)), 32);
|
||||
|
Loading…
Reference in New Issue
Block a user