diff --git a/firmware/coins-gen.py b/firmware/coins-gen.py index b4ccf5f765..af5a3a8de1 100755 --- a/firmware/coins-gen.py +++ b/firmware/coins-gen.py @@ -29,6 +29,7 @@ def get_fields(coin): '%d' % coin['forkid'] if coin['forkid'] else '0', '"%s"' % coin['bech32_prefix'] if coin.get('bech32_prefix') is not None else 'NULL', '0x%08x' % (0x80000000 + coin['bip44']), + '%s_NAME' % 'secp256k1'.upper(), '&%s_info' % 'secp256k1', ] diff --git a/firmware/coins.c b/firmware/coins.c index 94766a1757..0618c60ddf 100644 --- a/firmware/coins.c +++ b/firmware/coins.c @@ -20,6 +20,7 @@ #include #include "coins.h" #include "address.h" +#include "curves.h" #include "ecdsa.h" #include "base58.h" #include "secp256k1.h" diff --git a/firmware/coins.h b/firmware/coins.h index 9ee822a5e5..eae9bbd61c 100644 --- a/firmware/coins.h +++ b/firmware/coins.h @@ -45,6 +45,7 @@ typedef struct _CoinInfo { uint32_t forkid; const char *bech32_prefix; uint32_t coin_type; + const char *curve_name; const curve_info *curve; } CoinInfo; diff --git a/firmware/fsm.c b/firmware/fsm.c index a4c48aa645..96760a97b7 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -389,7 +389,7 @@ void fsm_msgGetPublicKey(GetPublicKey *msg) const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; - const char *curve = SECP256K1_NAME; + const char *curve = coin->curve_name; if (msg->has_ecdsa_curve_name) { curve = msg->ecdsa_curve_name; } @@ -501,7 +501,7 @@ void fsm_msgSignTx(SignTx *msg) const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; - const HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, 0, 0); + const HDNode *node = fsm_getDerivedNode(coin->curve_name, 0, 0); if (!node) return; signing_init(msg->inputs_count, msg->outputs_count, coin, node, msg->version, msg->lock_time); @@ -670,7 +670,7 @@ void fsm_msgGetAddress(GetAddress *msg) const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; - HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n, msg->address_n_count); + HDNode *node = fsm_getDerivedNode(coin->curve_name, msg->address_n, msg->address_n_count); if (!node) return; hdnode_fill_public_key(node); @@ -852,7 +852,7 @@ void fsm_msgSignMessage(SignMessage *msg) const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; - HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n, msg->address_n_count); + HDNode *node = fsm_getDerivedNode(coin->curve_name, msg->address_n, msg->address_n_count); if (!node) return; layoutProgressSwipe(_("Signing"), 0);