[][src]Struct safe_crypto::PublicEncryptKey

pub struct PublicEncryptKey { /* fields omitted */ }

The public key used encrypt data that can only be decrypted by the corresponding secret key, which is represented by SecretEncryptKey. Use gen_encrypt_keypair() to generate a public and secret key pair.

Methods

impl PublicEncryptKey[src]

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

Construct public key from bytes. Useful when it was serialised before.

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

Convert the PublicEncryptKey into the raw underlying bytes. For anyone who wants to store the public key.

pub fn anonymously_encrypt<T>(&self, plaintext: &T) -> Result<Vec<u8>, Error> where
    T: Serialize
[src]

Encrypts serialisable plaintext using anonymous encryption.

Anonymous encryption will use an ephemeral public key, so the recipient won't be able to tell who sent the ciphertext. If you wish to encrypt bytestring plaintext, use anonymously_encrypt_bytes. To use authenticated encryption, use SharedSecretKey.

Returns ciphertext in case of success. Can return an Error in case of a serialisation error.

pub fn anonymously_encrypt_bytes(&self, plaintext: &[u8]) -> Vec<u8>[src]

Encrypts bytestring plaintext using anonymous encryption.

Anonymous encryption will use an ephemeral public key, so the recipient won't be able to tell who sent the ciphertext. To use authenticated encryption, use SharedSecretKey.

Returns ciphertext in case of success.

Trait Implementations

impl Eq for PublicEncryptKey[src]

impl Ord for PublicEncryptKey[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl PartialEq<PublicEncryptKey> for PublicEncryptKey[src]

impl Copy for PublicEncryptKey[src]

impl Clone for PublicEncryptKey[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialOrd<PublicEncryptKey> for PublicEncryptKey[src]

impl Debug for PublicEncryptKey[src]

impl Display for PublicEncryptKey[src]

impl Hash for PublicEncryptKey[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for PublicEncryptKey[src]

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

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<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