mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
keychain/derivation: adds watchtower session key family
This commit is contained in:
24
watchtower/wtclient/derivation.go
Normal file
24
watchtower/wtclient/derivation.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
func DeriveSessionKey(keyRing SecretKeyRing,
|
||||
index uint32) (*btcec.PrivateKey, error) {
|
||||
|
||||
return keyRing.DerivePrivKey(keychain.KeyDescriptor{
|
||||
KeyLocator: keychain.KeyLocator{
|
||||
Family: keychain.KeyFamilyTowerSession,
|
||||
Index: index,
|
||||
},
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user