Skip to content

Instantly share code, notes, and snippets.

@axic
Last active May 25, 2016 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axic/8993b9f181e862c8d7014c39f286b66a to your computer and use it in GitHub Desktop.
Save axic/8993b9f181e862c8d7014c39f286b66a to your computer and use it in GitHub Desktop.
How to get started with Trezor-Ethereum (for developers only!)

Ethereum support in Trezor is in early development. The following steps can help you to get started.

First of all have a read at the protocol discussion thread.

To summarize the key decisions:

  • Transaction data is taken as raw binary, all fields of the transaction separately (in order they appear).
  • Every field is optional and it defaults to 0 if something is not supplied.
  • Trezor will internally recreate the RLP of those fields, hash it and create a signature.
  • The above is in a streaming manner and thus no RLP data is kept nor returned to the client.
  • Only the signature fields (v, r, s) are returned. The callee then needs to recreate the RLP structure and include the signature fields.

The firmware resides at https://github.com/axic/trezor-mcu/tree/ethereum. It should compile without issues and should run without crashing. But could destroy your computer, your Ethers or whatever else. It is PoC software at this stage. (The transaction flow is at https://github.com/axic/trezor-mcu/blob/ethereum/firmware/ethereum.c)

The only way to interface is via the trezorctl commandline tool (available here, but not all methods are merged in the tree yet).

An example message flow:

SENDING <EthereumSignTx> (100 bytes):
nonce: "hex(00)"
gas_price: "hex(04a817c800)"
gas_limit: "hex(88b8)"
to: "hex(fb6916095ca1df60bb79ce92ce3ea74c37c5d359)"
value: "hex(0eebe0b40e8000)"
data_initial_chunk: "hex(317374205472657a6f72207472616e73616374696f6e205c6f2f2061786963)"

RECEIVED <ButtonRequest> (2 bytes):
code: ButtonRequest_SignTx

SENDING <ButtonAck> (0 bytes):

RECEIVED <EthereumTxRequest> (70 bytes):
signature_v: 27
signature_r: "hex(1cf2adbf49922165967d071ba6b301f60b00bc5f5a9b96f74a6266a12daf237e)"
signature_s: "hex(728d59b86095c4d84b4992df458f6653eaed1badc03b4e901ac1e7c6726fd3de)"

Based on this, a tool like helpeth can be used to assemble the final transaction:

helpeth assembleTx 0x0 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359 0x0eebe0b40e8000 0x317374205472657a6f72207472616e73616374696f6e205c6f2f2061786963 0x88b8 0x04a817c800 27 0x1cf2adbf49922165967d071ba6b301f60b00bc5f5a9b96f74a6266a12daf237e 0x728d59b86095c4d84b4992df458f6653eaed1badc03b4e901ac1e7c6726fd3de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment