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