2019-04-24 06:03:48 +03:00
|
|
|
package wtclient
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcd/btcec"
|
|
|
|
"github.com/lightningnetwork/lnd/keychain"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DeriveSessionKey accepts an session key index for an existing session and
|
|
|
|
// derives the HD private key to be used to authenticate the brontide transport
|
|
|
|
// and authenticate requests sent to the tower. The key will use the
|
|
|
|
// keychain.KeyFamilyTowerSession and the provided index, giving a BIP43
|
|
|
|
// derivation path of:
|
|
|
|
//
|
|
|
|
// * m/1017'/coinType'/8/0/index
|
2020-04-28 11:06:25 +03:00
|
|
|
func DeriveSessionKey(keyRing ECDHKeyRing,
|
2019-04-24 06:03:48 +03:00
|
|
|
index uint32) (*btcec.PrivateKey, error) {
|
|
|
|
|
|
|
|
return keyRing.DerivePrivKey(keychain.KeyDescriptor{
|
|
|
|
KeyLocator: keychain.KeyLocator{
|
|
|
|
Family: keychain.KeyFamilyTowerSession,
|
|
|
|
Index: index,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|