dcrwallet icon indicating copy to clipboard operation
dcrwallet copied to clipboard

multi: Import xprivs for use with trezor watching only wallet.

Open JoeGruffins opened this issue 4 years ago • 2 comments

Background

Trezor is a hardware wallet. We can make simple transactions with it. It stores private keys on the device and doesn't give them out. If you want something signed with a private key, you send that data to the trezor to be signed and get the signature back. There is an effort to get staking working securely and infallibly on trezor. For an old staking pool, or a solo staker, this is mostly fine.

Problem

For the new vspd api (v3) we need to send the private key used to derive the sstxsubmission so that the pool can vote for us. Normally, a trezor cannot export a private key.

Solution

Rather than trying create an exception, we have decided to create a psuedo-key from other data that only the user can access from their trezor. We will use this data as a private key and import it into dcrwallet as an xpriv. From that xpriv dcrwallet will create voting keys for trezor ticket purchases.

Specific Changes Needed

db

We need to add more imported private accounts to the wallet. Plus we need to make sure these specific accounts aren't used for other transactions. (How to?)

The "imported" account has a lot of special exceptions. It is much less of an account that a placeholder for imported addresses. All accounts are keyed in the db by a uint32, and imported accounts start half way. We can use the halfway point plus one for our purposes. Our voting accounts are almost identical to derived accounts. The only difference is the type.

grpc

We can add a method to import voting extended private keys. It takes the xpriv, password, and some other arguments and stores an encrypted xpriv in the database at the next imported account index.

We need to specify the voting account when purchasing tickets. For this a couple of arguments need to be added to Purchase tickets, including the voting account number.

voting

These changes should allow for voting with a watching only wallet, but I do not propose making this possible yet. The objective is to allow voting from the new vspd. If watching only wallet voting is needed, that can be done later.

revoking

Revoking using the xprivs is however necessary as part of these changes. edit: Voting and revoking may work out of the box.

change log
2020
11/28 Initial issue.
12/14 Update db, grpc, and voting sections.

JoeGruffins avatar Nov 28 '20 06:11 JoeGruffins

Working on it.

JoeGruffins avatar Dec 12 '20 03:12 JoeGruffins

Waiting for the next trezor release, which should have ticket purchasing enabled. Also related is this: https://github.com/trezor/trezor-firmware/issues/1508 but who knows how long it will take for this to get moving.

JoeGruffins avatar May 17 '21 00:05 JoeGruffins