lnd+server+keychain: remove unused code
This commit is contained in:
parent
08d6a61e2a
commit
36b90382d3
@ -347,33 +347,6 @@ func (b *BtcWalletKeyRing) DerivePrivKey(keyDesc KeyDescriptor) (
|
|||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScalarMult performs a scalar multiplication (ECDH-like operation) between
|
|
||||||
// the target key descriptor and remote public key. The output returned will be
|
|
||||||
// the sha256 of the resulting shared point serialized in compressed format. If
|
|
||||||
// k is our private key, and P is the public key, we perform the following
|
|
||||||
// operation:
|
|
||||||
//
|
|
||||||
// sx := k*P s := sha256(sx.SerializeCompressed())
|
|
||||||
//
|
|
||||||
// NOTE: This is part of the keychain.SecretKeyRing interface.
|
|
||||||
func (b *BtcWalletKeyRing) ScalarMult(keyDesc KeyDescriptor,
|
|
||||||
pub *btcec.PublicKey) ([]byte, error) {
|
|
||||||
|
|
||||||
privKey, err := b.DerivePrivKey(keyDesc)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
s := &btcec.PublicKey{}
|
|
||||||
x, y := btcec.S256().ScalarMult(pub.X, pub.Y, privKey.D.Bytes())
|
|
||||||
s.X = x
|
|
||||||
s.Y = y
|
|
||||||
|
|
||||||
h := sha256.Sum256(s.SerializeCompressed())
|
|
||||||
|
|
||||||
return h[:], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECDH performs a scalar multiplication (ECDH-like operation) between the
|
// ECDH performs a scalar multiplication (ECDH-like operation) between the
|
||||||
// target key descriptor and remote public key. The output returned will be
|
// target key descriptor and remote public key. The output returned will be
|
||||||
// the sha256 of the resulting shared point serialized in compressed format. If
|
// the sha256 of the resulting shared point serialized in compressed format. If
|
||||||
|
@ -186,16 +186,6 @@ type SecretKeyRing interface {
|
|||||||
// MaxKeyRangeScan keys. In order for this to work, the caller MUST set
|
// MaxKeyRangeScan keys. In order for this to work, the caller MUST set
|
||||||
// the KeyFamily within the partially populated KeyLocator.
|
// the KeyFamily within the partially populated KeyLocator.
|
||||||
DerivePrivKey(keyDesc KeyDescriptor) (*btcec.PrivateKey, error)
|
DerivePrivKey(keyDesc KeyDescriptor) (*btcec.PrivateKey, error)
|
||||||
|
|
||||||
// ScalarMult performs a scalar multiplication (ECDH-like operation)
|
|
||||||
// between the target key descriptor and remote public key. The output
|
|
||||||
// returned will be the sha256 of the resulting shared point serialized
|
|
||||||
// in compressed format. If k is our private key, and P is the public
|
|
||||||
// key, we perform the following operation:
|
|
||||||
//
|
|
||||||
// sx := k*P
|
|
||||||
// s := sha256(sx.SerializeCompressed())
|
|
||||||
ScalarMult(keyDesc KeyDescriptor, pubKey *btcec.PublicKey) ([]byte, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DigestSignerRing is an interface that abstracts away basic low-level ECDSA
|
// DigestSignerRing is an interface that abstracts away basic low-level ECDSA
|
||||||
|
16
lnd.go
16
lnd.go
@ -27,7 +27,6 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/btcsuite/btcwallet/wallet"
|
"github.com/btcsuite/btcwallet/wallet"
|
||||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
@ -471,19 +470,6 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
|||||||
cfg.registeredChains.RegisterChain(primaryChain, activeChainControl)
|
cfg.registeredChains.RegisterChain(primaryChain, activeChainControl)
|
||||||
|
|
||||||
// TODO(roasbeef): add rotation
|
// TODO(roasbeef): add rotation
|
||||||
idPrivKey, err := activeChainControl.wallet.DerivePrivKey(keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamilyNodeKey,
|
|
||||||
Index: 0,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
err := fmt.Errorf("unable to derive node private key: %v", err)
|
|
||||||
ltndLog.Error(err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
idPrivKey.Curve = btcec.S256()
|
|
||||||
|
|
||||||
idKeyDesc, err := activeChainControl.keyRing.DeriveKey(
|
idKeyDesc, err := activeChainControl.keyRing.DeriveKey(
|
||||||
keychain.KeyLocator{
|
keychain.KeyLocator{
|
||||||
Family: keychain.KeyFamilyNodeKey,
|
Family: keychain.KeyFamilyNodeKey,
|
||||||
@ -623,7 +609,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
|||||||
// connections.
|
// connections.
|
||||||
server, err := newServer(
|
server, err := newServer(
|
||||||
cfg, cfg.Listeners, chanDB, towerClientDB, activeChainControl,
|
cfg, cfg.Listeners, chanDB, towerClientDB, activeChainControl,
|
||||||
idPrivKey, &idKeyDesc, walletInitParams.ChansToRestore, chainedAcceptor,
|
&idKeyDesc, walletInitParams.ChansToRestore, chainedAcceptor,
|
||||||
torController,
|
torController,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
5
mock.go
5
mock.go
@ -359,11 +359,6 @@ func (m *mockSecretKeyRing) DerivePrivKey(keyDesc keychain.KeyDescriptor) (*btce
|
|||||||
return m.rootKey, nil
|
return m.rootKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockSecretKeyRing) ScalarMult(keyDesc keychain.KeyDescriptor,
|
|
||||||
pubKey *btcec.PublicKey) ([]byte, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *mockSecretKeyRing) ECDH(_ keychain.KeyDescriptor,
|
func (m *mockSecretKeyRing) ECDH(_ keychain.KeyDescriptor,
|
||||||
pubKey *btcec.PublicKey) ([32]byte, error) {
|
pubKey *btcec.PublicKey) ([32]byte, error) {
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ func noiseDial(idKey keychain.SingleKeyECDH,
|
|||||||
// passed listener address.
|
// passed listener address.
|
||||||
func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
|
func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
|
||||||
towerClientDB *wtdb.ClientDB, cc *chainControl,
|
towerClientDB *wtdb.ClientDB, cc *chainControl,
|
||||||
privKey *btcec.PrivateKey, nodeKeyDesc *keychain.KeyDescriptor,
|
nodeKeyDesc *keychain.KeyDescriptor,
|
||||||
chansToRestore walletunlocker.ChannelsToRecover,
|
chansToRestore walletunlocker.ChannelsToRecover,
|
||||||
chanPredicate chanacceptor.ChannelAcceptor,
|
chanPredicate chanacceptor.ChannelAcceptor,
|
||||||
torController *tor.Controller) (*server, error) {
|
torController *tor.Controller) (*server, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user