Struct saltyrtc_client::crypto::KeyPair
source · [−]pub struct KeyPair { /* private fields */ }
Expand description
Wrapper for holding a public/private key pair and encrypting/decrypting messages.
Implementations
sourceimpl KeyPair
impl KeyPair
sourcepub fn from_private_key(private_key: PrivateKey) -> Self
pub fn from_private_key(private_key: PrivateKey) -> Self
Create a new key pair from an existing private key.
The private key is consumed and transferred into the KeyPair
.
sourcepub fn from_keypair(public_key: PublicKey, private_key: PrivateKey) -> Self
pub fn from_keypair(public_key: PublicKey, private_key: PrivateKey) -> Self
Create a new key pair from an existing public and private key.
The two keys are consumed and transferred into the KeyPair
.
sourcepub fn public_key(&self) -> &PublicKey
pub fn public_key(&self) -> &PublicKey
Return a reference to the public key.
sourcepub fn public_key_hex(&self) -> String
pub fn public_key_hex(&self) -> String
Return the public key as hex-encoded string.
sourcepub fn private_key(&self) -> &PrivateKey
pub fn private_key(&self) -> &PrivateKey
Return a reference to the private key.
Warning: Be careful with this! The only reason to access the private key is probably to be able to restore it when working with trusted keys.
sourcepub fn private_key_hex(&self) -> String
pub fn private_key_hex(&self) -> String
Return the private key as hex-encoded string.
Warning: Be careful with this! The only reason to access the private key is probably to be able to restore it when working with trusted keys.