From 30ab354e229658c050c54b7bab17388424a114c8 Mon Sep 17 00:00:00 2001 From: Dominik Spicher Date: Thu, 10 Mar 2022 15:57:29 +0100 Subject: [PATCH] Allow SharedSecret to be created from byte array This was accidentally removed in 8b2edad. See also the discussion on https://github.com/rust-bitcoin/rust-secp256k1/pull/402 --- src/ecdh.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ecdh.rs b/src/ecdh.rs index e36553e5a..0d8beeb77 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -71,6 +71,11 @@ impl SharedSecret { pub fn secret_bytes(&self) -> [u8; SHARED_SECRET_SIZE] { self.0 } + + /// Creates a shared secret from a byte serialization. + pub fn from_bytes(bytes:[u8; SHARED_SECRET_SIZE]) -> SharedSecret { + SharedSecret(bytes) + } } impl Borrow<[u8]> for SharedSecret {