multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease review: - 2d746f68: replace imports - 4008f0fd: use ecdsa.Signature - 849e33d1: remove btcec.S256() - b8f6ebbd: use v2 library correctly - fa80bca9: bump go modules
This commit is contained in:
350 files changed
+2421
-1289
No files matched your search
+10
-4
@@ -3,7 +3,7 @@ package keychain
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
)
|
||||
|
||||
// NewPubKeyECDH wraps the given key of the key ring so it adheres to the
|
||||
@@ -72,10 +72,16 @@ func (p *PrivKeyECDH) PubKey() *btcec.PublicKey {
|
||||
//
|
||||
// NOTE: This is part of the SingleKeyECDH interface.
|
||||
func (p *PrivKeyECDH) ECDH(pub *btcec.PublicKey) ([32]byte, error) {
|
||||
s := &btcec.PublicKey{}
|
||||
s.X, s.Y = btcec.S256().ScalarMult(pub.X, pub.Y, p.PrivKey.D.Bytes())
|
||||
var (
|
||||
pubJacobian btcec.JacobianPoint
|
||||
s btcec.JacobianPoint
|
||||
)
|
||||
pub.AsJacobian(&pubJacobian)
|
||||
|
||||
return sha256.Sum256(s.SerializeCompressed()), nil
|
||||
btcec.ScalarMultNonConst(&p.PrivKey.Key, &pubJacobian, &s)
|
||||
s.ToAffine()
|
||||
sPubKey := btcec.NewPublicKey(&s.X, &s.Y)
|
||||
return sha256.Sum256(sPubKey.SerializeCompressed()), nil
|
||||
}
|
||||
|
||||
var _ SingleKeyECDH = (*PubKeyECDH)(nil)
|
||||
|
||||
Reference in new issue
Block a user