Skip to main content

derive_shared_key_ecdh

Function derive_shared_key_ecdh 

Source
pub fn derive_shared_key_ecdh(
    private_key: &SecretKey,
    public_key: &PublicKey,
) -> [u8; 32]
Expand description

Derive a shared secret key using ECDH as specified in DIP-15

This uses libsecp256k1_ecdh which computes: SHA256((y[31]&0x1|0x2) || x) where (x, y) is the EC point result of scalar multiplication

§Arguments

  • private_key - The private key for this side of the exchange
  • public_key - The public key from the other party

§Returns

A 32-byte shared secret key