func ECDH_Ecdsa(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey) ([]byte, error) {
	if pub == nil || priv == nil {
		return nil, ErrKeyExchange
	} else if priv.Curve != pub.Curve {
		return nil, ErrKeyExchange
	} else if !priv.Curve.IsOnCurve(pub.X, pub.Y) {
		return nil, ErrKeyExchange
	}

	x, _ := pub.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes())
	if x == nil {
		return nil, ErrKeyExchange
	}

	shared := sha256.Sum256(x.Bytes())
	return shared[:Aes256KeySize], nil
}
// ECDH computes a shared key from a private key and a peer's public key.
ECDH computes a shared key from a private key and a peer's public key.
// ECDH computes a shared key from a private key and a peer ' s public key .
func ECDH_Ecdsa(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey) ([]byte, error) {
	if pub == nil || priv == nil {
		return nil, ErrKeyExchange
	} else if priv.Curve != pub.Curve {
		return nil, ErrKeyExchange
	} else if !priv.Curve.IsOnCurve(pub.X, pub.Y) {
		return nil, ErrKeyExchange
	}
	x, _ := pub.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes())
	if x == nil {
		return nil, ErrKeyExchange
	}
	shared := sha256.Sum256(x.Bytes())
	return shared[:Aes256KeySize], nil
}
func ECDH_Ecdsa ( priv * ecdsa . PrivateKey , pub * ecdsa . PublicKey ) ( [ ] byte , error ) { if pub == nil || priv == nil { return nil , ErrKeyExchange } else if priv . Curve != pub . Curve { return nil , ErrKeyExchange } else if ! priv . Curve . IsOnCurve ( pub . X , pub . Y ) { return nil , ErrKeyExchange } x , _ := pub . Curve . ScalarMult ( pub . X , pub . Y , priv . D . Bytes ( ) ) if x == nil { return nil , ErrKeyExchange } shared := sha256 . Sum256 ( x . Bytes ( ) ) return shared [ : Aes256KeySize ] , nil }
ECDH computes a shared key from a private key and a peer's public key.
ECDH computes a shared key from a private key and a peer ' s public key .