Function bdk_chain::bitcoin::secp256k1::ecdh::shared_secret_point

pub fn shared_secret_point(point: &PublicKey, scalar: &SecretKey) -> [u8; 64]
Expand description

Creates a shared point from public key and secret key.

Important: use of a strong cryptographic hash function may be critical to security! Do NOT use unless you understand cryptographical implications. If not, use SharedSecret instead.

Can be used like SharedSecret but caller is responsible for then hashing the returned buffer. This allows for the use of a custom hash function since SharedSecret uses SHA256.

§Returns

64 bytes representing the (x,y) co-ordinates of a point on the curve (32 bytes each).

§Examples


let s = Secp256k1::new();
let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
let (sk2, pk2) = s.generate_keypair(&mut rand::thread_rng());

let point1 = ecdh::shared_secret_point(&pk2, &sk1);
let secret1 = sha512::Hash::hash(&point1);
let point2 = ecdh::shared_secret_point(&pk1, &sk2);
let secret2 = sha512::Hash::hash(&point2);
assert_eq!(secret1, secret2)