Skip to content

Commit 75eabbd

Browse files
committed
fix(legacy): stellar adaption and support for ada testnet message signing
1 parent e27250f commit 75eabbd

31 files changed

+748
-925
lines changed

common/protob/messages-cardano.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ message CardanoSignMessage {
538538
required CardanoDerivationType derivation_type = 3;
539539
required uint32 network_id = 4; // network id - mainnet or testnet
540540
optional CardanoAddressType address_type = 5; // one of the CardanoAddressType
541+
optional uint32 protocol_magic = 6; // network's protocol magic - needed for Byron addresses on testnets
541542
}
542543

543544
/**

legacy/firmware/ada.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,9 @@ bool ada_sign_messages(const CardanoSignMessage *msg,
19811981
fsm_sendFailure(FailureType_Failure_ProcessError, "Deriving root failed");
19821982
return false;
19831983
}
1984-
if (!derive_bytes(&address_params, msg->network_id, MAINNET_PROTOCOL_MAGIC,
1984+
if (!derive_bytes(&address_params, msg->network_id,
1985+
msg->has_protocol_magic ? msg->protocol_magic
1986+
: MAINNET_PROTOCOL_MAGIC,
19851987
address_bytes, &address_bytes_len)) {
19861988
return false;
19871989
}

legacy/firmware/ethereum_onekey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static bool eip1559;
5555
static struct SHA3_CTX keccak_ctx = {0};
5656

5757
static uint32_t signing_access_list_count;
58-
static EthereumAccessListOneKey signing_access_list[8];
58+
static EthereumAccessListOneKey signing_access_list[16];
5959
_Static_assert(sizeof(signing_access_list) ==
6060
sizeof(((EthereumSignTxEIP1559OneKey *)NULL)->access_list),
6161
"access_list buffer size mismatch");

legacy/firmware/fsm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,8 @@ static const CoinInfo *fsm_getCoin(bool has_name, const char *name) {
301301
return coin;
302302
}
303303

304-
static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
305-
size_t address_n_count,
306-
uint32_t *fingerprint) {
304+
HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n,
305+
size_t address_n_count, uint32_t *fingerprint) {
307306
static CONFIDENTIAL HDNode node;
308307
if (fingerprint) {
309308
*fingerprint = 0;

legacy/firmware/fsm_msg_ada.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ void fsm_msgCardanoGetAddress(CardanoGetAddress *msg) {
9696
if (msg->has_show_display && msg->show_display) {
9797
char desc[20] = {0};
9898
char addr_type[32] = {0};
99-
snprintf(desc, 20, "Cardano %s", _("Address:"));
99+
snprintf(desc, 20, "Cardano %s", _("Address"));
100100
if (msg->address_parameters.address_type == CardanoAddressType_BASE) {
101-
snprintf(addr_type, 32, "Base %s", _("Address:"));
101+
snprintf(addr_type, 32, "Base %s", _("Address"));
102102
} else if (msg->address_parameters.address_type ==
103103
CardanoAddressType_REWARD) {
104-
snprintf(addr_type, 32, "Reward %s", _("Address:"));
104+
snprintf(addr_type, 32, "Reward %s", _("Address"));
105105
}
106106
if (msg->address_parameters.address_n_count > 0) {
107107
if (!fsm_layoutAddress(resp->address, addr_type, desc, false, 0,
@@ -268,8 +268,9 @@ void fsm_msgCardanoSignMessage(CardanoSignMessage *msg) {
268268
"Invalid path");
269269
CHECK_PIN
270270

271-
if ((msg->network_id != 0) && (msg->network_id != 1)) {
272-
fsm_sendFailure(FailureType_Failure_ProcessError, "Invalid Networ ID");
271+
if (!msg->has_protocol_magic && (msg->network_id != 1)) {
272+
fsm_sendFailure(FailureType_Failure_ProcessError,
273+
"Invalid Network ID, need protocol magic provide");
273274
return;
274275
}
275276
if (!ada_sign_messages(msg, resp)) {

legacy/firmware/fsm_msg_algorand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void fsm_msgAlgorandGetAddress(AlgorandGetAddress *msg) {
3939

4040
if (msg->has_show_display && msg->show_display) {
4141
char desc[20] = {0};
42-
snprintf(desc, 20, "%s %s", "Algorand", _("Address:"));
42+
snprintf(desc, 20, "%s %s", "Algorand", _("Address"));
4343
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
4444
msg->address_n_count, true, NULL, 0, 0, NULL)) {
4545
return;

legacy/firmware/fsm_msg_aptos.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void fsm_msgAptosGetAddress(const AptosGetAddress *msg) {
4040

4141
if (msg->has_show_display && msg->show_display) {
4242
char desc[16] = {0};
43-
strcat(desc, "Aptos");
44-
strcat(desc, _("Address:"));
43+
strcat(desc, "Aptos ");
44+
strcat(desc, _("Address"));
4545
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
4646
msg->address_n_count, true, NULL, 0, 0, NULL)) {
4747
return;

legacy/firmware/fsm_msg_coin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void fsm_msgGetAddress(const GetAddress *msg) {
308308
} else {
309309
strcat(desc, coin->coin_name);
310310
strcat(desc, " ");
311-
strlcpy(desc + strlen(desc), _("Address:"), sizeof(desc));
311+
strlcpy(desc + strlen(desc), _("Address"), sizeof(desc));
312312
}
313313

314314
uint32_t multisig_xpub_magic = coin->xpub_magic;

legacy/firmware/fsm_msg_conflux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void fsm_msgConfluxGetAddress(const ConfluxGetAddress *msg) {
6666
}
6767
if (msg->has_show_display && msg->show_display) {
6868
char desc[20] = {0};
69-
snprintf(desc, 20, "%s %s", "Conflux", _("Address:"));
69+
snprintf(desc, 20, "%s %s", "Conflux", _("Address"));
7070
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
7171
msg->address_n_count, false, NULL, 0, 0, NULL)) {
7272
return;

legacy/firmware/fsm_msg_cosmos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void fsm_msgCosmosGetAddress(CosmosGetAddress *msg) {
5959
strcat(desc, "Cosmos");
6060
}
6161
strcat(desc, " ");
62-
strcat(desc, _("Address:"));
62+
strcat(desc, _("Address"));
6363
if (!fsm_layoutAddress(resp->address, NULL, desc, false, 0, msg->address_n,
6464
msg->address_n_count, true, NULL, 0, 0, NULL)) {
6565
return;

0 commit comments

Comments
 (0)