From 3da9c6bbb9910ce7f8fc29f9c5da758dbb50cb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vejpustek?= Date: Tue, 6 Aug 2024 17:07:05 +0200 Subject: [PATCH] fix(crypto): forbid public key derivation for curve25519, ed25519 and cardano [no changelog] --- crypto/bip32.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crypto/bip32.c b/crypto/bip32.c index cb67834764..b78d31159b 100644 --- a/crypto/bip32.c +++ b/crypto/bip32.c @@ -209,6 +209,8 @@ int hdnode_private_ckd_bip32(HDNode *inout, uint32_t i) { memcpy(data + 1, inout->private_key, 32); } else { // public derivation if (!inout->curve->params) { + // SLIP-10 doesn't support private key to private key non-hardened + // derivation for curve25519 and ed25519 return 0; } if (hdnode_fill_public_key(inout) != 0) { @@ -321,6 +323,13 @@ int hdnode_public_ckd_cp(const ecdsa_curve *curve, const curve_point *parent, int hdnode_public_ckd(HDNode *inout, uint32_t i) { curve_point parent = {0}, child = {0}; + if (!inout->curve->params) { + // SLIP-10 doesn't support public key to public key derivation for + // curve25519 and ed25519, Cardano BIP32-ed22519 public key to public key + // derivation is not implemented + return 0; + } + if (!ecdsa_read_pubkey(inout->curve->params, inout->public_key, &parent)) { return 0; }