Skip to content

Commit 6b2c4d4

Browse files
committed
Allow SharedSecret to be created from byte array
This was accidentally removed in 8b2edad. See also the discussion on #402
1 parent 39e47fb commit 6b2c4d4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ecdh.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ const SHARED_SECRET_SIZE: usize = constants::SECRET_KEY_SIZE;
4747
pub struct SharedSecret([u8; SHARED_SECRET_SIZE]);
4848
impl_display_secret!(SharedSecret);
4949

50+
impl From<[u8; SHARED_SECRET_SIZE]> for SharedSecret {
51+
fn from(arr: [u8; SHARED_SECRET_SIZE]) -> Self {
52+
let mut data = [0u8; SHARED_SECRET_SIZE];
53+
data[..SHARED_SECRET_SIZE].copy_from_slice(&arr);
54+
Self(data)
55+
}
56+
}
57+
5058
impl SharedSecret {
5159
/// Creates a new shared secret from a pubkey and secret key.
5260
#[inline]

0 commit comments

Comments
 (0)