pub struct KeyPair<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> {
pub public_key: PublicKey,
pub secret_key: SecretKey,
}
Expand description
Public/private keypair for use with crate::dryocbox::DryocBox
, aka
libsodium box
Fields§
§public_key: PublicKey
Public key
secret_key: SecretKey
Secret key
Implementations§
source§impl KeyPair<Locked<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>, Locked<HeapByteArray<CRYPTO_BOX_SECRETKEYBYTES>>>
impl KeyPair<Locked<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>, Locked<HeapByteArray<CRYPTO_BOX_SECRETKEYBYTES>>>
sourcepub fn new_locked_keypair() -> Result<Self, Error>
Available on crate feature nightly
only.
pub fn new_locked_keypair() -> Result<Self, Error>
nightly
only.Returns a new locked keypair.
sourcepub fn gen_locked_keypair() -> Result<Self, Error>
Available on crate feature nightly
only.
pub fn gen_locked_keypair() -> Result<Self, Error>
nightly
only.Returns a new randomly generated locked keypair.
source§impl KeyPair<LockedRO<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>, LockedRO<HeapByteArray<CRYPTO_BOX_SECRETKEYBYTES>>>
impl KeyPair<LockedRO<HeapByteArray<CRYPTO_BOX_PUBLICKEYBYTES>>, LockedRO<HeapByteArray<CRYPTO_BOX_SECRETKEYBYTES>>>
sourcepub fn gen_readonly_locked_keypair() -> Result<Self, Error>
Available on crate feature nightly
only.
pub fn gen_readonly_locked_keypair() -> Result<Self, Error>
nightly
only.Returns a new randomly generated locked, read-only keypair.
source§impl<PublicKey: NewByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> KeyPair<PublicKey, SecretKey>
impl<PublicKey: NewByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> KeyPair<PublicKey, SecretKey>
sourcepub fn from_secret_key(secret_key: SecretKey) -> Self
pub fn from_secret_key(secret_key: SecretKey) -> Self
Derives a keypair from secret_key
, and consumes it, and returns a new
keypair.
source§impl KeyPair<StackByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, StackByteArray<CRYPTO_BOX_SECRETKEYBYTES>>
impl KeyPair<StackByteArray<CRYPTO_BOX_PUBLICKEYBYTES>, StackByteArray<CRYPTO_BOX_SECRETKEYBYTES>>
sourcepub fn gen_with_defaults() -> Self
pub fn gen_with_defaults() -> Self
Randomly generates a new keypair, using default types (stack-allocated byte arrays). Provided for convenience.
source§impl<'a, PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + TryFrom<&'a [u8]> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + TryFrom<&'a [u8]> + Zeroize> KeyPair<PublicKey, SecretKey>
impl<'a, PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + TryFrom<&'a [u8]> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + TryFrom<&'a [u8]> + Zeroize> KeyPair<PublicKey, SecretKey>
source§impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> KeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> KeyPair<PublicKey, SecretKey>
sourcepub fn kx_new_client_session<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize>(
&self,
server_public_key: &PublicKey
) -> Result<Session<SessionKey>, Error>
pub fn kx_new_client_session<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize>( &self, server_public_key: &PublicKey ) -> Result<Session<SessionKey>, Error>
Creates new client session keys using this keypair and
server_public_key
, assuming this keypair is for the client.
sourcepub fn kx_new_server_session<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize>(
&self,
client_public_key: &PublicKey
) -> Result<Session<SessionKey>, Error>
pub fn kx_new_server_session<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize>( &self, client_public_key: &PublicKey ) -> Result<Session<SessionKey>, Error>
Creates new server session keys using this keypair and
client_public_key
, assuming this keypair is for the server.
Trait Implementations§
source§impl<PublicKey: Clone + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: Clone + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Clone for KeyPair<PublicKey, SecretKey>
impl<PublicKey: Clone + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: Clone + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Clone for KeyPair<PublicKey, SecretKey>
source§impl<PublicKey: Debug + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: Debug + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Debug for KeyPair<PublicKey, SecretKey>
impl<PublicKey: Debug + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: Debug + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Debug for KeyPair<PublicKey, SecretKey>
source§impl<PublicKey: NewByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Default for KeyPair<PublicKey, SecretKey>
impl<PublicKey: NewByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Default for KeyPair<PublicKey, SecretKey>
source§impl<'de, PublicKey, SecretKey> Deserialize<'de> for KeyPair<PublicKey, SecretKey>where
PublicKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize,
SecretKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize,
impl<'de, PublicKey, SecretKey> Deserialize<'de> for KeyPair<PublicKey, SecretKey>where
PublicKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize,
SecretKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Drop for KeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> Drop for KeyPair<PublicKey, SecretKey>
source§impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> PartialEq for KeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_BOX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_BOX_SECRETKEYBYTES> + Zeroize> PartialEq for KeyPair<PublicKey, SecretKey>
Auto Trait Implementations§
impl<PublicKey, SecretKey> Freeze for KeyPair<PublicKey, SecretKey>
impl<PublicKey, SecretKey> RefUnwindSafe for KeyPair<PublicKey, SecretKey>where
PublicKey: RefUnwindSafe,
SecretKey: RefUnwindSafe,
impl<PublicKey, SecretKey> Send for KeyPair<PublicKey, SecretKey>
impl<PublicKey, SecretKey> Sync for KeyPair<PublicKey, SecretKey>
impl<PublicKey, SecretKey> Unpin for KeyPair<PublicKey, SecretKey>
impl<PublicKey, SecretKey> UnwindSafe for KeyPair<PublicKey, SecretKey>where
PublicKey: UnwindSafe,
SecretKey: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more