symbol / symbol-cli

Command-line tool for Symbol
https://docs.symbolplatform.com/cli.html
Apache License 2.0
36 stars 24 forks source link

Trezor integration #387

Open fboucquez opened 3 years ago

fboucquez commented 3 years ago

Add the possibility to create Trezor profiles connected to a Trezor device.

I believe the Ledger integration has created all the abstractions to add Trezor profiles and SigningAccount objects, what we don't have yet is a Trezor Ledger Client that integrates with the Trezor native app

@Momo10101 do you have the API specification between the client and the native Trezor app? Have you used the emultor? Does it use binaries like Ledger Speculus?

Momo10101 commented 3 years ago

@fboucquez What do you mean by "Ledger integration has created all the abstractions to add Trezor profiles" and "Trezor Ledger Client" ?

Regarding the API its quite easy. Everything is protobuf based, you send a protobuf corresponding to the transaction you want to execute and you get back a protobuf with the result. You can see the symbol protobufs here:

https://github.com/symbol/trezor-firmware/blob/symbol-integration/common/protob/messages-symbol.proto

fboucquez commented 3 years ago

Hi @Momo10101 ,

I think there are 2 parts to the story.

1) How to create Ledger/Trezor CLI profile, the ledger implementation did the groundwork for another hardware wallet like Trezor. We just need to extend a few classes. 2) How a TS app (CLI or wallet) can connect and call a Trezor device, the "Trezor TS Client". This is to be done.

Basically a client like these (but for trezor):

https://github.com/symbol/desktop-wallet/blob/dev/src/core/utils/Ledger.ts https://github.com/fboucquez/symbol-ledger-typescript/blob/main/src/SymbolLedger.ts (to be moved/repackaged to the symbol orga probably inside Hermes)

In my opinion, the problem with protobuf is that it's another schema related to symbol transactions we need to maintain. We also need to create and mantain the mappers from/to catbuffer builders/symbol transaction and protobuf.

The nice thing about the ledger client is that it sends catbuffer serialized payloads, so the integration is fairly trivial. In this Trezor case, a Trezor TS client would be more complicated as it would need to translate symbol objects/builders to/back protobuf. I am imagining the Trezor native app would also need to serialize protobuf to catbuffer in order to hash/sign.

What about: 1) A super simple protobuf API that receives a catbuffer serialized payload so it's trivial on both sides to maintain and process. 2) If 1 doesn't work, what about generating the protobuf and/or mappers using custom catbuffer generators? So if we add/modify a transaction in the catbuffer schemas, the protobuf API and/or mappers are free.

Makes sense?