Skip to content

Conversation

@gballet
Copy link
Member

@gballet gballet commented Jul 12, 2019

Implements signData for trezor. This has been tested with both the pre-1.8 version of the firmware and the latest. Fixes #19812

To work, this PR needs #19827

@gballet gballet requested review from holiman and karalabe July 12, 2019 06:58
@gballet gballet force-pushed the clef-signdata-with-trezor branch from 3e2094c to 9c9734e Compare July 12, 2019 07:04
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transaction -> signing request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transaction -> signing request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xUSB -> USB?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transaction -> signing request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about passing a hash vs. the data itself. Won't some hardware wallet or Clef itself need the entire data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the message itself is passed, I'm going to change the variable name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter name is still hash

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit ugly :P. A cleaner solution perhaps would be to look at the account.URL and if it's a keystore, ask for password, for everything else just blindly forward?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting you (from memory) when you asked me to look into the Trezor stuff: "I would like a quick and ugly solution". Boom, delivered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this method should be renamed signData? Also please rename the hash variables everywhere to data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read the comment and update it too accordingly :P

@karalabe karalabe added this to the 1.9.1 milestone Jul 18, 2019
@gballet gballet force-pushed the clef-signdata-with-trezor branch from 7bcd24e to 407128b Compare July 18, 2019 14:36
w.deriveChain = chain
}

// signHash implements accounts.Wallet, however signing arbitrary data is not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grmbl


// SignData sends a blob of data to the USB device and waits for the user to confirm
// or deny the signing request.
func (w *ledgerDriver) SignData(path accounts.DerivationPath, hash []byte) (common.Address, []byte, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter name is still hash

if addr := response.GetAddressHex(); len(addr) > 0 { // Newer firmwares use hexadecimal fomats
address = common.HexToAddress(addr)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls drop empty line.


func (w *wallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
return w.signHash(account, accounts.TextHash(text))
return w.signData(account, accounts.TextHash(text))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrong now. If we changed the signature to sign data, then we can't hash the text here now. What does sign text even do? It's not my method. Ping @holiman ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra catch here that I've spotted yesterday during a debug session: the Trezor actually adds the prefix no matter what, so right now the prefix is added twice. So the whole prefix management has to be changed, I'm still untangling some bits, and it would be interesting to discuss it.

return nil, err
// Only ask for the passphrase if the account is keystore based
pw := ""
if strings.Compare(wallet.URL().Scheme, "keystore") == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet.URL().Scheme == "keystore"

@karalabe
Copy link
Member

Putting this into the 1.9.x backlog. We need Trezor firmware support before we can continue (trezor/trezor-firmware#148).

@lexuansang93
Copy link

1

@karalabe
Copy link
Member

Closing this as it's not supported by Trezor. We can only pick it up if they implement it upstream. Closing until then.

@karalabe karalabe closed this Jun 25, 2020
@holiman
Copy link
Contributor

holiman commented Jun 25, 2020

reference: trezor/trezor-firmware#148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmd/clef: support trezor signing

5 participants