feat: get rid of lifetime annotations
This commit is contained in:
22
src/lib.rs
22
src/lib.rs
@@ -16,13 +16,13 @@ static AGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
|
||||
});
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct X25519PrivKey<'a>(SharedPtr<'a, 8>);
|
||||
pub struct X25519PrivKey(SharedPtr<8>);
|
||||
#[derive(Debug)]
|
||||
pub struct X25519PubKey<'a>(SharedPtr<'a, 32>);
|
||||
pub struct X25519PubKey(SharedPtr<32>);
|
||||
#[derive(Debug)]
|
||||
pub struct X25519SharedKey<'a>(SharedPtr<'a, 32>);
|
||||
pub struct X25519SharedKey(SharedPtr<32>);
|
||||
|
||||
impl From<&[u8; 32]> for X25519PubKey<'_> {
|
||||
impl From<&[u8; 32]> for X25519PubKey {
|
||||
fn from(value: &[u8; 32]) -> Self {
|
||||
let mut pk = SharedPtr::<32>::new().unwrap();
|
||||
pk.copy_from_slice(value);
|
||||
@@ -30,7 +30,7 @@ impl From<&[u8; 32]> for X25519PubKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&[u8; 8]> for X25519PrivKey<'_> {
|
||||
impl From<&[u8; 8]> for X25519PrivKey {
|
||||
fn from(value: &[u8; 8]) -> Self {
|
||||
let mut sk = SharedPtr::<8>::new().unwrap();
|
||||
sk.copy_from_slice(value);
|
||||
@@ -38,7 +38,7 @@ impl From<&[u8; 8]> for X25519PrivKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519PrivKey<'_> {
|
||||
impl Deref for X25519PrivKey {
|
||||
type Target = [u8; 8];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -46,7 +46,7 @@ impl Deref for X25519PrivKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519PubKey<'_> {
|
||||
impl Deref for X25519PubKey {
|
||||
type Target = [u8; 32];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -54,7 +54,7 @@ impl Deref for X25519PubKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for X25519SharedKey<'_> {
|
||||
impl Deref for X25519SharedKey {
|
||||
type Target = [u8; 32];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -62,7 +62,7 @@ impl Deref for X25519SharedKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) {
|
||||
pub fn x25519_keygen() -> (X25519PrivKey, X25519PubKey) {
|
||||
let sk = X25519PrivKey(SharedPtr::<8>::new().unwrap());
|
||||
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn x25519_keygen<'a>() -> (X25519PrivKey<'a>, X25519PubKey<'a>) {
|
||||
(sk, pk)
|
||||
}
|
||||
|
||||
pub fn x22519_pubkey<'a>(sk: &X25519PrivKey) -> X25519PubKey<'a> {
|
||||
pub fn x22519_pubkey(sk: &X25519PrivKey) -> X25519PubKey {
|
||||
let pk = X25519PubKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
let mut agent = AGENT.lock().unwrap();
|
||||
@@ -87,7 +87,7 @@ pub fn x22519_pubkey<'a>(sk: &X25519PrivKey) -> X25519PubKey<'a> {
|
||||
pk
|
||||
}
|
||||
|
||||
pub fn x25519<'a>(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey<'a> {
|
||||
pub fn x25519(sk: &X25519PrivKey, pk: &X25519PubKey) -> X25519SharedKey {
|
||||
let out = X25519SharedKey(SharedPtr::<32>::new().unwrap());
|
||||
|
||||
let mut agent = AGENT.lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user