1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

chore(legacy): Disable Taproot where it's not supported.

This commit is contained in:
Andrew Kozlik 2021-11-13 12:42:54 +01:00 committed by Andrew Kozlik
parent 10717ddb99
commit 98ad54b7ee
2 changed files with 28 additions and 19 deletions

View File

@ -149,15 +149,12 @@ 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 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_SPENDADDRESS:
// p2pkh
script_type_info = 0;
break;
case InputScriptType_SPENDP2SHWITNESS:
// segwit-in-p2sh
script_type_info = 4;
@ -167,11 +164,20 @@ int cryptoMessageSign(const CoinInfo *coin, HDNode *node,
script_type_info = 8;
break;
default:
// p2pkh
// unsupported script type
return 1;
}
if (no_script_type) {
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;
}
return result;

View File

@ -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"));