Trezor communication

Hello everyone, your annoying useless user is back again with useless questions (not useless to me of course :sweat_smile:). So I’ve been looking more in detail into the communication between a client and the device (trezor One).

Thanks to @matejcik, I could understand how trezor communication works in detail. Furthermore, @matejcik advised me to use bridge to communicate with my device. However, I can’t use the bridge transport to communicate with Trezor for several reasons, the most important one being : I am integrating my script, that handles communication with Trezor One, in a much larger tool which will be used to execute multiple pin verification tests on the device. Seeing as Trezor Bridge is too complex and implements all message types, my tutor asked me to develop a much lighter version (implementing only messages necessary to the pin verification test).

Therefore, I have been looking into the python-trezor module in order to reproduce/recreate a simpler form of communication using the usb-hid transport layer. I have some questions regarding this ordeal :

  • in order to communicate with trezor using the usb-hid transport layer, I need to do 3 things :
  1. Define message types and messages using the protobuf library, and compile them into python objects using the pb2py script in trezor-common/protob directory.
  2. After these messages are serialized, they have to be divided into chunks following the protocol v1 encapsulation (TLV + magic numbers + chunking into 64 bytes packets)
  3. Send these messages through the usb-hid layer.

First of all, is it possible to do this through the usb-hid handler or is it no longer supported by Trezor devices ?
Assuming it’s the case :

  • steps 1 and 2 of the previous list seem easy enough (i hope) to accomplish, however step 3 seems to be a little more complicated, any help/documentation on how to do so would be appreciated.

2 posts were merged into an existing topic: Trezor Communication Inquiries