[][src]Struct safe_crypto::SecretEncryptKey

pub struct SecretEncryptKey { /* fields omitted */ }

Reference counted secret encryption key used to decrypt data previously encrypted with PublicEncryptKey. Use gen_encrypt_keypair() to generate a public and secret key pair.

Methods

impl SecretEncryptKey[src]

pub fn from_bytes(secret_key: [u8; 32]) -> Self[src]

Construct secret key from given bytes. Useful when secret key was serialised before.

pub fn shared_secret(&self, their_pk: &PublicEncryptKey) -> SharedSecretKey[src]

Computes a shared secret from our secret key and the recipient's public key.

pub fn into_bytes(self) -> [u8; 32][src]

Get the inner secret key representation.

pub fn anonymously_decrypt<T>(
    &self,
    ciphertext: &[u8],
    my_pk: &PublicEncryptKey
) -> Result<T, Error> where
    T: Serialize + DeserializeOwned
[src]

Decrypts serialised ciphertext encrypted using anonymous encryption.

With anonymous encryption we won't be able to verify the sender and tell who sent the ciphertext.

Returns deserialised type T in case of success. Can return Error in case of a deserialisation error, if the ciphertext is not valid, or if it can not be decrypted.

pub fn anonymously_decrypt_bytes(
    &self,
    ciphertext: &[u8],
    my_pk: &PublicEncryptKey
) -> Result<Vec<u8>, Error>
[src]

Decrypts bytestring ciphertext encrypted using anonymous encryption.

With anonymous encryption we won't be able to verify the sender and tell who sent the ciphertext.

Returns plaintext in case of success. Can return Error if the ciphertext is not valid or if it can not be decrypted.

Trait Implementations

impl Eq for SecretEncryptKey[src]

impl Clone for SecretEncryptKey[src]

impl PartialEq<SecretEncryptKey> for SecretEncryptKey[src]

impl Debug for SecretEncryptKey[src]

impl Serialize for SecretEncryptKey[src]

impl<'de> Deserialize<'de> for SecretEncryptKey[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> UnsafeAny for T where
    T: Any