1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-05-21 16:28:46 +00:00

wallet: fix GetPublicKey msg, regenerate protobuf

This commit is contained in:
Pavol Rusnak 2017-05-08 18:04:05 +02:00
parent 9e42a45b10
commit e6d93c5933
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
12 changed files with 103 additions and 70 deletions

View File

@ -5,12 +5,17 @@ from trezor.utils import unimport
async def layout_get_public_key(session_id, msg): async def layout_get_public_key(session_id, msg):
from trezor.messages.HDNodeType import HDNodeType from trezor.messages.HDNodeType import HDNodeType
from trezor.messages.PublicKey import PublicKey from trezor.messages.PublicKey import PublicKey
from ..common import coins
from ..common import seed from ..common import seed
node = await seed.get_root(session_id) address_n = msg.address_n or ()
node.derive_path(msg.address_n or ()) coin_name = msg.coin_name or 'Bitcoin'
node_xpub = node.serialize_public() node = await seed.get_root(session_id)
node.derive_path(address_n)
coin = coins.by_name(coin_name)
node_xpub = node.serialize_public(coin.xpub_magic)
node_type = HDNodeType( node_type = HDNodeType(
depth=node.depth(), depth=node.depth(),
child_num=node.child_num(), child_num=node.child_num(),

View File

@ -11,4 +11,7 @@ class CoinType(p.MessageType):
6: ('address_type_p2wpkh', p.UVarintType, 0), # default=6 6: ('address_type_p2wpkh', p.UVarintType, 0), # default=6
7: ('address_type_p2wsh', p.UVarintType, 0), # default=10 7: ('address_type_p2wsh', p.UVarintType, 0), # default=10
8: ('signed_message_header', p.UnicodeType, 0), 8: ('signed_message_header', p.UnicodeType, 0),
9: ('xpub_magic', p.UVarintType, 0), # default=76067358
10: ('xprv_magic', p.UVarintType, 0), # default=76066276
11: ('segwit', p.BoolType, 0),
} }

View File

@ -11,5 +11,6 @@ class EthereumSignTx(p.MessageType):
6: ('value', p.BytesType, 0), 6: ('value', p.BytesType, 0),
7: ('data_initial_chunk', p.BytesType, 0), 7: ('data_initial_chunk', p.BytesType, 0),
8: ('data_length', p.UVarintType, 0), 8: ('data_length', p.UVarintType, 0),
9: ('chain_id', p.UVarintType, 0),
} }
MESSAGE_WIRE_TYPE = 58 MESSAGE_WIRE_TYPE = 58

View File

@ -0,0 +1,9 @@
# Automatically generated by pb2py
import protobuf as p
class FirmwareRequest(p.MessageType):
FIELDS = {
1: ('offset', p.UVarintType, 0),
2: ('length', p.UVarintType, 0),
}
MESSAGE_WIRE_TYPE = 8

View File

@ -4,5 +4,6 @@ import protobuf as p
class FirmwareUpload(p.MessageType): class FirmwareUpload(p.MessageType):
FIELDS = { FIELDS = {
1: ('payload', p.BytesType, 0), # required 1: ('payload', p.BytesType, 0), # required
2: ('hash', p.BytesType, 0),
} }
MESSAGE_WIRE_TYPE = 7 MESSAGE_WIRE_TYPE = 7

View File

@ -6,5 +6,6 @@ class GetPublicKey(p.MessageType):
1: ('address_n', p.UVarintType, p.FLAG_REPEATED), 1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('ecdsa_curve_name', p.UnicodeType, 0), 2: ('ecdsa_curve_name', p.UnicodeType, 0),
3: ('show_display', p.BoolType, 0), 3: ('show_display', p.BoolType, 0),
4: ('coin_name', p.UnicodeType, 0), # default=u'Bitcoin'
} }
MESSAGE_WIRE_TYPE = 11 MESSAGE_WIRE_TYPE = 11

View File

@ -7,6 +7,7 @@ ChangePin = const(4)
WipeDevice = const(5) WipeDevice = const(5)
FirmwareErase = const(6) FirmwareErase = const(6)
FirmwareUpload = const(7) FirmwareUpload = const(7)
FirmwareRequest = const(8)
GetEntropy = const(9) GetEntropy = const(9)
Entropy = const(10) Entropy = const(10)
GetPublicKey = const(11) GetPublicKey = const(11)

View File

@ -9,6 +9,7 @@ class RecoveryDevice(p.MessageType):
4: ('language', p.UnicodeType, 0), # default=u'english' 4: ('language', p.UnicodeType, 0), # default=u'english'
5: ('label', p.UnicodeType, 0), 5: ('label', p.UnicodeType, 0),
6: ('enforce_wordlist', p.BoolType, 0), 6: ('enforce_wordlist', p.BoolType, 0),
7: ('u2f_counter', p.UVarintType, 0), 8: ('type', p.UVarintType, 0),
9: ('u2f_counter', p.UVarintType, 0),
} }
MESSAGE_WIRE_TYPE = 45 MESSAGE_WIRE_TYPE = 45

View File

@ -0,0 +1,3 @@
# Automatically generated by pb2py
ScrambledWords = const(0)
Matrix = const(1)

View File

@ -2,4 +2,7 @@
import protobuf as p import protobuf as p
class WordRequest(p.MessageType): class WordRequest(p.MessageType):
FIELDS = {
1: ('type', p.UVarintType, 0),
}
MESSAGE_WIRE_TYPE = 46 MESSAGE_WIRE_TYPE = 46

View File

@ -0,0 +1,4 @@
# Automatically generated by pb2py
Plain = const(0)
Matrix9 = const(1)
Matrix6 = const(2)

View File

@ -1,66 +1,67 @@
WordRequest = 46 WordRequest = const(46)
DebugLinkMemoryWrite = 112 DebugLinkMemoryWrite = const(112)
ButtonAck = 27 ButtonAck = const(27)
MessageSignature = 40 MessageSignature = const(40)
EthereumAddress = 57 EthereumAddress = const(57)
EthereumTxAck = 60 EthereumTxAck = const(60)
Ping = 1 Ping = const(1)
EncryptedMessage = 50 EncryptedMessage = const(50)
DebugLinkStop = 103 DebugLinkStop = const(103)
EstimateTxSize = 43 EstimateTxSize = const(43)
GetPublicKey = 11 GetPublicKey = const(11)
GetFeatures = 55 GetFeatures = const(55)
GetECDHSessionKey = 61 GetECDHSessionKey = const(61)
PinMatrixRequest = 18 PinMatrixRequest = const(18)
ClearSession = 24 ClearSession = const(24)
LoadDevice = 13 LoadDevice = const(13)
VerifyMessage = 39 VerifyMessage = const(39)
EthereumSignTx = 58 EthereumSignTx = const(58)
PassphraseRequest = 41 PassphraseRequest = const(41)
TxAck = 22 TxAck = const(22)
ChangePin = 4 ChangePin = const(4)
DebugLinkLog = 104 DebugLinkLog = const(104)
FirmwareErase = 6 FirmwareErase = const(6)
TxRequest = 21 TxRequest = const(21)
EthereumGetAddress = 56 EthereumGetAddress = const(56)
DebugLinkState = 102 DebugLinkState = const(102)
EthereumTxRequest = 59 EthereumTxRequest = const(59)
FirmwareUpload = 7 FirmwareUpload = const(7)
SignedIdentity = 54 SignedIdentity = const(54)
Failure = 3 Failure = const(3)
EntropyRequest = 35 EntropyRequest = const(35)
ApplySettings = 25 ApplySettings = const(25)
DebugLinkFlashErase = 113 DebugLinkFlashErase = const(113)
Address = 30 Address = const(30)
Initialize = 0 Initialize = const(0)
PinMatrixAck = 19 PinMatrixAck = const(19)
SetU2FCounter = 63 SetU2FCounter = const(63)
SignTx = 15 SignTx = const(15)
DebugLinkGetState = 101 DebugLinkGetState = const(101)
Success = 2 FirmwareRequest = const(8)
ResetDevice = 14 Success = const(2)
WordAck = 47 ResetDevice = const(14)
SimpleSignTx = 16 WordAck = const(47)
GetAddress = 29 SimpleSignTx = const(16)
TxSize = 44 GetAddress = const(29)
PassphraseAck = 42 TxSize = const(44)
SignMessage = 38 PassphraseAck = const(42)
DecryptedMessage = 52 SignMessage = const(38)
DecryptMessage = 51 DecryptedMessage = const(52)
GetEntropy = 9 DecryptMessage = const(51)
EntropyAck = 36 GetEntropy = const(9)
WipeDevice = 5 EntropyAck = const(36)
CipherKeyValue = 23 WipeDevice = const(5)
Features = 17 CipherKeyValue = const(23)
RecoveryDevice = 45 Features = const(17)
SignIdentity = 53 RecoveryDevice = const(45)
DebugLinkDecision = 100 SignIdentity = const(53)
CipheredKeyValue = 48 DebugLinkDecision = const(100)
ButtonRequest = 26 CipheredKeyValue = const(48)
PublicKey = 12 ButtonRequest = const(26)
DebugLinkMemory = 111 PublicKey = const(12)
Entropy = 10 DebugLinkMemory = const(111)
Cancel = 20 Entropy = const(10)
DebugLinkMemoryRead = 110 Cancel = const(20)
EncryptMessage = 49 DebugLinkMemoryRead = const(110)
ECDHSessionKey = 62 EncryptMessage = const(49)
ECDHSessionKey = const(62)