diff --git a/src/lib.rs b/src/lib.rs index d58a80c..98f4767 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,14 @@ pub struct X25519PubKey<'a>(SharedPtr<'a, 32>); #[derive(Debug)] pub struct X25519SharedKey<'a>(SharedPtr<'a, 32>); +impl From<&[u8; 32]> for X25519PubKey<'_> { + fn from(value: &[u8; 32]) -> Self { + let mut pk = SharedPtr::<32>::new().unwrap(); + pk.copy_from_slice(value); + X25519PubKey(pk) + } +} + pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) { let sk = X25519PrivKey(SharedPtr::<8>::new().unwrap()); let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());