core: remove remaning utility code for Bitcoin only firmware

pull/446/head
Pavol Rusnak 5 years ago
parent c815bc410c
commit 908bbfffef
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -117,9 +117,9 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_sign(size_t n_args,
mp_get_buffer_raise(args[0], &sk, MP_BUFFER_READ); mp_get_buffer_raise(args[0], &sk, MP_BUFFER_READ);
mp_get_buffer_raise(args[1], &dig, MP_BUFFER_READ); mp_get_buffer_raise(args[1], &dig, MP_BUFFER_READ);
bool compressed = (n_args < 3) || (args[2] == mp_const_true); bool compressed = (n_args < 3) || (args[2] == mp_const_true);
int (*is_canonical)(uint8_t by, uint8_t sig[64]) = NULL;
#if !BITCOIN_ONLY #if !BITCOIN_ONLY
mp_int_t canonical = (n_args > 3) ? mp_obj_get_int(args[3]) : 0; mp_int_t canonical = (n_args > 3) ? mp_obj_get_int(args[3]) : 0;
int (*is_canonical)(uint8_t by, uint8_t sig[64]) = NULL;
switch (canonical) { switch (canonical) {
case CANONICAL_SIG_ETHEREUM: case CANONICAL_SIG_ETHEREUM:
is_canonical = ethereum_is_canonical; is_canonical = ethereum_is_canonical;

@ -1,16 +1,20 @@
# Automatically generated by pb2py # Automatically generated by pb2py
# fmt: off # fmt: off
from trezor import utils
Bitcoin = 1 Bitcoin = 1
Bitcoin_like = 2 if not utils.BITCOIN_ONLY:
Binance = 3 Bitcoin_like = 2
Cardano = 4 Binance = 3
Cardano = 4
Crypto = 5 Crypto = 5
EOS = 6 if not utils.BITCOIN_ONLY:
Ethereum = 7 EOS = 6
Lisk = 8 Ethereum = 7
Monero = 9 Lisk = 8
NEM = 10 Monero = 9
Ripple = 11 NEM = 10
Stellar = 12 Ripple = 11
Tezos = 13 Stellar = 12
U2F = 14 Tezos = 13
U2F = 14

@ -1,5 +1,7 @@
# Automatically generated by pb2py # Automatically generated by pb2py
# fmt: off # fmt: off
from trezor import utils
Initialize = 0 Initialize = 0
Ping = 1 Ping = 1
Success = 2 Success = 2
@ -64,116 +66,117 @@ DebugLinkMemoryRead = 110
DebugLinkMemory = 111 DebugLinkMemory = 111
DebugLinkMemoryWrite = 112 DebugLinkMemoryWrite = 112
DebugLinkFlashErase = 113 DebugLinkFlashErase = 113
EthereumGetPublicKey = 450 if not utils.BITCOIN_ONLY:
EthereumPublicKey = 451 EthereumGetPublicKey = 450
EthereumGetAddress = 56 EthereumPublicKey = 451
EthereumAddress = 57 EthereumGetAddress = 56
EthereumSignTx = 58 EthereumAddress = 57
EthereumTxRequest = 59 EthereumSignTx = 58
EthereumTxAck = 60 EthereumTxRequest = 59
EthereumSignMessage = 64 EthereumTxAck = 60
EthereumVerifyMessage = 65 EthereumSignMessage = 64
EthereumMessageSignature = 66 EthereumVerifyMessage = 65
NEMGetAddress = 67 EthereumMessageSignature = 66
NEMAddress = 68 NEMGetAddress = 67
NEMSignTx = 69 NEMAddress = 68
NEMSignedTx = 70 NEMSignTx = 69
NEMDecryptMessage = 75 NEMSignedTx = 70
NEMDecryptedMessage = 76 NEMDecryptMessage = 75
LiskGetAddress = 114 NEMDecryptedMessage = 76
LiskAddress = 115 LiskGetAddress = 114
LiskSignTx = 116 LiskAddress = 115
LiskSignedTx = 117 LiskSignTx = 116
LiskSignMessage = 118 LiskSignedTx = 117
LiskMessageSignature = 119 LiskSignMessage = 118
LiskVerifyMessage = 120 LiskMessageSignature = 119
LiskGetPublicKey = 121 LiskVerifyMessage = 120
LiskPublicKey = 122 LiskGetPublicKey = 121
TezosGetAddress = 150 LiskPublicKey = 122
TezosAddress = 151 TezosGetAddress = 150
TezosSignTx = 152 TezosAddress = 151
TezosSignedTx = 153 TezosSignTx = 152
TezosGetPublicKey = 154 TezosSignedTx = 153
TezosPublicKey = 155 TezosGetPublicKey = 154
StellarSignTx = 202 TezosPublicKey = 155
StellarTxOpRequest = 203 StellarSignTx = 202
StellarGetAddress = 207 StellarTxOpRequest = 203
StellarAddress = 208 StellarGetAddress = 207
StellarCreateAccountOp = 210 StellarAddress = 208
StellarPaymentOp = 211 StellarCreateAccountOp = 210
StellarPathPaymentOp = 212 StellarPaymentOp = 211
StellarManageOfferOp = 213 StellarPathPaymentOp = 212
StellarCreatePassiveOfferOp = 214 StellarManageOfferOp = 213
StellarSetOptionsOp = 215 StellarCreatePassiveOfferOp = 214
StellarChangeTrustOp = 216 StellarSetOptionsOp = 215
StellarAllowTrustOp = 217 StellarChangeTrustOp = 216
StellarAccountMergeOp = 218 StellarAllowTrustOp = 217
StellarManageDataOp = 220 StellarAccountMergeOp = 218
StellarBumpSequenceOp = 221 StellarManageDataOp = 220
StellarSignedTx = 230 StellarBumpSequenceOp = 221
CardanoSignTx = 303 StellarSignedTx = 230
CardanoTxRequest = 304 CardanoSignTx = 303
CardanoGetPublicKey = 305 CardanoTxRequest = 304
CardanoPublicKey = 306 CardanoGetPublicKey = 305
CardanoGetAddress = 307 CardanoPublicKey = 306
CardanoAddress = 308 CardanoGetAddress = 307
CardanoTxAck = 309 CardanoAddress = 308
CardanoSignedTx = 310 CardanoTxAck = 309
RippleGetAddress = 400 CardanoSignedTx = 310
RippleAddress = 401 RippleGetAddress = 400
RippleSignTx = 402 RippleAddress = 401
RippleSignedTx = 403 RippleSignTx = 402
MoneroTransactionInitRequest = 501 RippleSignedTx = 403
MoneroTransactionInitAck = 502 MoneroTransactionInitRequest = 501
MoneroTransactionSetInputRequest = 503 MoneroTransactionInitAck = 502
MoneroTransactionSetInputAck = 504 MoneroTransactionSetInputRequest = 503
MoneroTransactionInputsPermutationRequest = 505 MoneroTransactionSetInputAck = 504
MoneroTransactionInputsPermutationAck = 506 MoneroTransactionInputsPermutationRequest = 505
MoneroTransactionInputViniRequest = 507 MoneroTransactionInputsPermutationAck = 506
MoneroTransactionInputViniAck = 508 MoneroTransactionInputViniRequest = 507
MoneroTransactionAllInputsSetRequest = 509 MoneroTransactionInputViniAck = 508
MoneroTransactionAllInputsSetAck = 510 MoneroTransactionAllInputsSetRequest = 509
MoneroTransactionSetOutputRequest = 511 MoneroTransactionAllInputsSetAck = 510
MoneroTransactionSetOutputAck = 512 MoneroTransactionSetOutputRequest = 511
MoneroTransactionAllOutSetRequest = 513 MoneroTransactionSetOutputAck = 512
MoneroTransactionAllOutSetAck = 514 MoneroTransactionAllOutSetRequest = 513
MoneroTransactionSignInputRequest = 515 MoneroTransactionAllOutSetAck = 514
MoneroTransactionSignInputAck = 516 MoneroTransactionSignInputRequest = 515
MoneroTransactionFinalRequest = 517 MoneroTransactionSignInputAck = 516
MoneroTransactionFinalAck = 518 MoneroTransactionFinalRequest = 517
MoneroKeyImageExportInitRequest = 530 MoneroTransactionFinalAck = 518
MoneroKeyImageExportInitAck = 531 MoneroKeyImageExportInitRequest = 530
MoneroKeyImageSyncStepRequest = 532 MoneroKeyImageExportInitAck = 531
MoneroKeyImageSyncStepAck = 533 MoneroKeyImageSyncStepRequest = 532
MoneroKeyImageSyncFinalRequest = 534 MoneroKeyImageSyncStepAck = 533
MoneroKeyImageSyncFinalAck = 535 MoneroKeyImageSyncFinalRequest = 534
MoneroGetAddress = 540 MoneroKeyImageSyncFinalAck = 535
MoneroAddress = 541 MoneroGetAddress = 540
MoneroGetWatchKey = 542 MoneroAddress = 541
MoneroWatchKey = 543 MoneroGetWatchKey = 542
DebugMoneroDiagRequest = 546 MoneroWatchKey = 543
DebugMoneroDiagAck = 547 DebugMoneroDiagRequest = 546
MoneroGetTxKeyRequest = 550 DebugMoneroDiagAck = 547
MoneroGetTxKeyAck = 551 MoneroGetTxKeyRequest = 550
MoneroLiveRefreshStartRequest = 552 MoneroGetTxKeyAck = 551
MoneroLiveRefreshStartAck = 553 MoneroLiveRefreshStartRequest = 552
MoneroLiveRefreshStepRequest = 554 MoneroLiveRefreshStartAck = 553
MoneroLiveRefreshStepAck = 555 MoneroLiveRefreshStepRequest = 554
MoneroLiveRefreshFinalRequest = 556 MoneroLiveRefreshStepAck = 555
MoneroLiveRefreshFinalAck = 557 MoneroLiveRefreshFinalRequest = 556
EosGetPublicKey = 600 MoneroLiveRefreshFinalAck = 557
EosPublicKey = 601 EosGetPublicKey = 600
EosSignTx = 602 EosPublicKey = 601
EosTxActionRequest = 603 EosSignTx = 602
EosTxActionAck = 604 EosTxActionRequest = 603
EosSignedTx = 605 EosTxActionAck = 604
BinanceGetAddress = 700 EosSignedTx = 605
BinanceAddress = 701 BinanceGetAddress = 700
BinanceGetPublicKey = 702 BinanceAddress = 701
BinancePublicKey = 703 BinanceGetPublicKey = 702
BinanceSignTx = 704 BinancePublicKey = 703
BinanceTxRequest = 705 BinanceSignTx = 704
BinanceTransferMsg = 706 BinanceTxRequest = 705
BinanceOrderMsg = 707 BinanceTransferMsg = 706
BinanceCancelMsg = 708 BinanceOrderMsg = 707
BinanceSignedTx = 709 BinanceCancelMsg = 708
BinanceSignedTx = 709

@ -41,4 +41,6 @@ for msg_name in dir(MessageType):
# No Message begins with underscore so it's safe to skip those. # No Message begins with underscore so it's safe to skip those.
if msg_name[0] == "_": if msg_name[0] == "_":
continue continue
if msg_name == "utils": # skip imported trezor.utils
continue
type_to_name[getattr(MessageType, msg_name)] = msg_name type_to_name[getattr(MessageType, msg_name)] = msg_name

@ -57,6 +57,8 @@ do_rebuild() {
shift shift
local IGNORE="$1" local IGNORE="$1"
shift shift
local APPLY_BITCOIN_ONLY="$1"
shift
mkdir -p "$DESTDIR" mkdir -p "$DESTDIR"
rm -f "$DESTDIR"/[A-Z]*.py rm -f "$DESTDIR"/[A-Z]*.py
@ -64,6 +66,24 @@ do_rebuild() {
# note $SOURCES is unquoted - we want wildcard expansion and multiple args # note $SOURCES is unquoted - we want wildcard expansion and multiple args
$PROTOB/pb2py "$@" -o "$DESTDIR" $SOURCES $PROTOB/pb2py "$@" -o "$DESTDIR" $SOURCES
# TODO: make this less hackish
# maybe introduce attribute "altcoin" in protobuf?
if [ "$APPLY_BITCOIN_ONLY" == "TRUE" ]; then
sed -i "3ifrom trezor import utils\n" "$DESTDIR"/Feature.py
sed -i "3ifrom trezor import utils\n" "$DESTDIR"/MessageType.py
sed -i "/^EthereumGetPublicKey/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/MessageType.py
for altcoin in Ethereum NEM Lisk Tezos Stellar Cardano Ripple Monero DebugMonero Eos Binance; do
sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/Feature.py
sed -i "s:^$altcoin: $altcoin:" "$DESTDIR"/MessageType.py
done
sed -i "/^Bitcoin_like/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py
sed -i "/^EOS/iif not utils.BITCOIN_ONLY:" "$DESTDIR"/Feature.py
for feature in Bitcoin_like EOS U2F; do
sed -i "s:^$feature: $feature:" "$DESTDIR"/Feature.py
done
fi
# ENDTODO
# delete unused messages # delete unused messages
for F in $IGNORE; do for F in $IGNORE; do
rm -f "$DESTDIR"/"$F".py rm -f "$DESTDIR"/"$F".py
@ -92,7 +112,7 @@ else
func=do_rebuild func=do_rebuild
fi fi
$func core/src/trezor/messages "$CORE_PROTOBUF_SOURCES" "$CORE_MESSAGES_IGNORE" --no-init-py $func core/src/trezor/messages "$CORE_PROTOBUF_SOURCES" "$CORE_MESSAGES_IGNORE" TRUE --no-init-py
$func python/src/trezorlib/messages "$PYTHON_PROTOBUF_SOURCES" "$PYTHON_MESSAGES_IGNORE" -P ..protobuf $func python/src/trezorlib/messages "$PYTHON_PROTOBUF_SOURCES" "$PYTHON_MESSAGES_IGNORE" FALSE -P ..protobuf
exit $RETURN exit $RETURN

Loading…
Cancel
Save