watchtower: use ECDH interface for watchtower session

This commit is contained in:
Oliver Gugger
2020-04-28 10:06:31 +02:00
parent 535a22c590
commit f97e7b9951
12 changed files with 53 additions and 93 deletions

View File

@@ -20,29 +20,6 @@ func NewSecretKeyRing() *SecretKeyRing {
}
}
// DerivePrivKey derives the private key for a given key descriptor. If
// this method is called twice with the same argument, it will return the same
// private key.
func (m *SecretKeyRing) DerivePrivKey(
desc keychain.KeyDescriptor) (*btcec.PrivateKey, error) {
m.mu.Lock()
defer m.mu.Unlock()
if key, ok := m.keys[desc.KeyLocator]; ok {
return key, nil
}
privKey, err := btcec.NewPrivateKey(btcec.S256())
if err != nil {
return nil, err
}
m.keys[desc.KeyLocator] = privKey
return privKey, nil
}
// DeriveKey attempts to derive an arbitrary key specified by the
// passed KeyLocator. This may be used in several recovery scenarios,
// or when manually rotating something like our current default node