diff --git a/src/lib.rs b/src/lib.rs index ab18a36..d6cb973 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,8 +6,7 @@ pub use shared_memory_heap::sharedptr::SharedPtr; use agent::Agent; use std::{ - path::Path, - sync::{LazyLock, Mutex}, + ops::Deref, path::Path, sync::{LazyLock, Mutex} }; static AGENT: LazyLock> = LazyLock::new(|| { @@ -39,6 +38,30 @@ impl From<&[u8; 8]> for X25519PrivKey<'_> { } } +impl Deref for X25519PrivKey<'_> { + type Target = [u8; 8]; + + fn deref(&self) -> &Self::Target { + self.0.deref() + } +} + +impl Deref for X25519PubKey<'_> { + type Target = [u8; 32]; + + fn deref(&self) -> &Self::Target { + self.0.deref() + } +} + +impl Deref for X25519SharedKey<'_> { + type Target = [u8; 32]; + + fn deref(&self) -> &Self::Target { + self.0.deref() + } +} + pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) { let sk = X25519PrivKey(SharedPtr::<8>::new().unwrap()); let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());