mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
chore(legacy): Disable Taproot where it's not supported.
This commit is contained in:
parent
10717ddb99
commit
98ad54b7ee
@ -149,15 +149,12 @@ int cryptoMessageSign(const CoinInfo *coin, HDNode *node,
|
|||||||
InputScriptType script_type, bool no_script_type,
|
InputScriptType script_type, bool no_script_type,
|
||||||
const uint8_t *message, size_t message_len,
|
const uint8_t *message, size_t message_len,
|
||||||
uint8_t *signature) {
|
uint8_t *signature) {
|
||||||
uint8_t hash[HASHER_DIGEST_LENGTH] = {0};
|
|
||||||
cryptoMessageHash(coin, message, message_len, hash);
|
|
||||||
|
|
||||||
uint8_t pby = 0;
|
|
||||||
int result = hdnode_sign_digest(node, hash, signature + 1, &pby, NULL);
|
|
||||||
if (result == 0) {
|
|
||||||
uint8_t script_type_info = 0;
|
uint8_t script_type_info = 0;
|
||||||
if (!no_script_type) {
|
|
||||||
switch (script_type) {
|
switch (script_type) {
|
||||||
|
case InputScriptType_SPENDADDRESS:
|
||||||
|
// p2pkh
|
||||||
|
script_type_info = 0;
|
||||||
|
break;
|
||||||
case InputScriptType_SPENDP2SHWITNESS:
|
case InputScriptType_SPENDP2SHWITNESS:
|
||||||
// segwit-in-p2sh
|
// segwit-in-p2sh
|
||||||
script_type_info = 4;
|
script_type_info = 4;
|
||||||
@ -167,11 +164,20 @@ int cryptoMessageSign(const CoinInfo *coin, HDNode *node,
|
|||||||
script_type_info = 8;
|
script_type_info = 8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// p2pkh
|
// unsupported script type
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (no_script_type) {
|
||||||
script_type_info = 0;
|
script_type_info = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t hash[HASHER_DIGEST_LENGTH] = {0};
|
||||||
|
cryptoMessageHash(coin, message, message_len, hash);
|
||||||
|
|
||||||
|
uint8_t pby = 0;
|
||||||
|
int result = hdnode_sign_digest(node, hash, signature + 1, &pby, NULL);
|
||||||
|
if (result == 0) {
|
||||||
signature[0] = 31 + pby + script_type_info;
|
signature[0] = 31 + pby + script_type_info;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -67,8 +67,7 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (coin->xpub_magic && (script_type == InputScriptType_SPENDADDRESS ||
|
if (coin->xpub_magic && (script_type == InputScriptType_SPENDADDRESS ||
|
||||||
script_type == InputScriptType_SPENDMULTISIG ||
|
script_type == InputScriptType_SPENDMULTISIG)) {
|
||||||
script_type == InputScriptType_SPENDTAPROOT)) {
|
|
||||||
hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub,
|
hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub,
|
||||||
sizeof(resp->xpub));
|
sizeof(resp->xpub));
|
||||||
} else if (coin->has_segwit &&
|
} else if (coin->has_segwit &&
|
||||||
@ -89,6 +88,10 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) {
|
|||||||
msg->ignore_xpub_magic && coin->xpub_magic) {
|
msg->ignore_xpub_magic && coin->xpub_magic) {
|
||||||
hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub,
|
hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub,
|
||||||
sizeof(resp->xpub));
|
sizeof(resp->xpub));
|
||||||
|
} else if (coin->has_taproot && script_type == InputScriptType_SPENDTAPROOT &&
|
||||||
|
coin->xpub_magic) {
|
||||||
|
hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub,
|
||||||
|
sizeof(resp->xpub));
|
||||||
} else {
|
} else {
|
||||||
fsm_sendFailure(FailureType_Failure_DataError,
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
_("Invalid combination of coin and script_type"));
|
_("Invalid combination of coin and script_type"));
|
||||||
|
Loading…
Reference in New Issue
Block a user