Skip to content

Commit

Permalink
Allow SharedSecret to be created from byte array
Browse files Browse the repository at this point in the history
This was accidentally removed in 8b2edad. See also the discussion
on rust-bitcoin#402
  • Loading branch information
dspicher committed Mar 10, 2022
1 parent 39e47fb commit 6b2c4d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ecdh.rs
Expand Up @@ -47,6 +47,14 @@ 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 {
let mut data = [0u8; SHARED_SECRET_SIZE];
data[..SHARED_SECRET_SIZE].copy_from_slice(&arr);
Self(data)
}
}

impl SharedSecret {
/// Creates a new shared secret from a pubkey and secret key.
#[inline]
Expand Down

0 comments on commit 6b2c4d4

Please sign in to comment.