Currently, LND is only support SW wallet. In order to improve this problem in the future, we can discuss it in this FR.
lndbtcd, bitcoind, or other backendBelow is the minimum change range for enabling outsourced signing in lnd,
Basically, HW wallet should create 3 new classes to inherit ‘signer’, ‘btcwallet’, and ‘producer’ respectively, and redirect ‘sign key’, ‘get public key’, and ‘get Commitment Secret / CommitmentPoint’ related operations to TrustZone.
lndwallet/btcwallet/signer::SignOutputRaw(tx, signDesc)
Query (family) public keys from TZ in BIP44 format, eg, m/1017'/coinType'/keyFamily'/0/index, and all lnd private keys will never leave trust zone
keychain/btcwallet::DerivePrivKey(keyDesc)
Create new producer class and update related utilities to generate the correspond "commitment" point through TZ.
if there is any suggestion, please advise.
Is your end goal to be able to _fund_ channels from a hardware wallet, or use lnd as a generic interface to interact with a hardware wallet (do regular on-chain sends, watch only support, etc)?
Is your end goal to be able to _fund_ channels from a hardware wallet, or use
lndas a generic interface to interact with a hardware wallet (do regular on-chain sends, watch only support, etc)?
For short term, the target is unlock/fund protected by HW.
For long term, the target is all lnd behaviors related privkey are all protected by HW.
A generic interface like HWI in Bitcoin is a reference.
Is there any idea or suggestion? Is it possible in this stage?
In order to fund channels from a hardware wallet, the idea is to move all the family private
keys from lnd's btc wallet to TrustZone HW. In current lnd commitment flow, for every new lnd commitment, it will need to send an old CommitSecret to the other side. Our thought is TrustZone will either provide an interface for lnd to query CommitSecrets or just send out the RevocationRoot private key to lnd (SW side) to generate CommitSecret. However, our concern is either way it looks like we lose the benefit of all the private keys / CommitSecret to be in HW? Is there any suggestion on this path?
@ksedgwic and I are looking at a similar use case. @htczion's last comment brings up the important topic of policy controls.
There are several attack vectors that can drain the funds from a lightning wallet even if the keys are adequately protected. One vector is, as you mentioned above, disclosing a commit secret before a new commitment has been made. Another vector is mistakenly publishing an out of date commitment transaction.
In general, it is not possible to protect a Lightning wallet with a stateless secure enclave. @ksedgwic and I are working to define the policy controls that a secure enclave must implement in order to provide meaningful security.
As to the code changes, I think you you are on the right track. I was thinking of the following strategy:
Signer interface operations with a method to get the xpub of each key family (account xpub). This is necessary because the account xpub computation requires hardened derivation from the seed. Lower key derivation can be done in btcwallet.Signer that is configured.Signer, Producer and NodeSigner interfacesIt doesn't look like the btcsuite/btcwallet module supports starting a wallet in watch-only mode or importing account pubkeys.
@Roasbeef what would you recommend for managing the public keys in a hardware wallet situation? Enhance btcsuite/btcwallet? or create a completely new module to replace lnd/lnwallet/btcwallet? The latter approach would seem to create a lot of code duplication.
I brain dumped a path to supporting the above, and much more in this post: https://groups.google.com/a/lightning.engineering/forum/#!topic/lnd/3rF65UxvDtM
I brain dumped a path to supporting the above, and much more in this post: https://groups.google.com/a/lightning.engineering/forum/#!topic/lnd/3rF65UxvDtM
@Roasbeef
Will this new btcsuite/btcwallet protect the keys(funding key...) during every commitment transaction, or just funding and settlement transaction?
Refer to https://github.com/lightningnetwork/lnd/issues/3085
Hi, Roasbeef
As you say, after this saga is complete,
hardware wallet is able to be a external signer, if it provide the gRPC services properly, right?
But lnd do signing autolly after wallet unlocked.
It's not adapt to the mechnism of hardware wallet,
let user have to confirm sign request by entering password everytime.
It seems not be metioned in chapters.
How dose external signer handle the frequent signReq when sendPayment or negotiation of closeChannel?
Most helpful comment
@ksedgwic and I are looking at a similar use case. @htczion's last comment brings up the important topic of policy controls.
There are several attack vectors that can drain the funds from a lightning wallet even if the keys are adequately protected. One vector is, as you mentioned above, disclosing a commit secret before a new commitment has been made. Another vector is mistakenly publishing an out of date commitment transaction.
In general, it is not possible to protect a Lightning wallet with a stateless secure enclave. @ksedgwic and I are working to define the policy controls that a secure enclave must implement in order to provide meaningful security.