github.com/turingchain2020/turingchain@v1.1.21/wallet/bipwallet/btcutilecc/ecdh.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package btcutil 6 7 import ( 8 "crypto/ecdsa" 9 "math/big" 10 ) 11 12 // ECDH Calculate a shared secret using elliptic curve Diffie-Hellman 13 func ECDH(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey) *big.Int { 14 x, _ := Secp256k1().ScalarMult(pub.X, pub.Y, priv.D.Bytes()) 15 return x 16 }