From f78ac8caca9d7ad7842642b881aca880609b38f8 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ecdh.rs b/src/ecdh.rs index e36553e5a..5f15ed19b 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -47,6 +47,12 @@ const SHARED_SECRET_SIZE: usize = constants::SECRET_KEY_SIZE; pub struct SharedSecret([u8; SHARED_SECRET_SIZE]); impl_display_secret!(SharedSecret); +impl From<[u8; SHARED_SECRET_SIZE]> for SharedSecret { + fn from(arr: [u8; SHARED_SECRET_SIZE]) -> Self { + SharedSecret(arr) + } +} + impl SharedSecret { /// Creates a new shared secret from a pubkey and secret key. #[inline]