pub struct EphemeralEcdhContent {
pub ciphertext: Vec<u8>,
pub nonce: [u8; 12],
pub ephemeral_public: [u8; 32],
}Expand description
Ephemeral ECDH ChaCha20-Poly1305 encrypted content Simple public key encryption using ephemeral X25519 keys Anyone can encrypt for the recipient using only their public key
Fields§
§ciphertext: Vec<u8>Encrypted data + authentication tag
nonce: [u8; 12]ChaCha20-Poly1305 nonce (12 bytes)
ephemeral_public: [u8; 32]Ephemeral X25519 public key (generated randomly for each message)
Implementations§
Source§impl EphemeralEcdhContent
impl EphemeralEcdhContent
Sourcepub fn encrypt(
plaintext: &[u8],
recipient_ed25519_public: &VerifyingKey,
) -> Result<Self, CryptoError>
pub fn encrypt( plaintext: &[u8], recipient_ed25519_public: &VerifyingKey, ) -> Result<Self, CryptoError>
Encrypt data using ephemeral X25519 ECDH
Generates a random ephemeral key pair for each message
Anyone can encrypt for the recipient using only their Ed25519 public key
Sourcepub fn decrypt(
&self,
recipient_ed25519_key: &SigningKey,
) -> Result<Vec<u8>, CryptoError>
pub fn decrypt( &self, recipient_ed25519_key: &SigningKey, ) -> Result<Vec<u8>, CryptoError>
Decrypt data using ephemeral X25519 ECDH Recipient uses their Ed25519 private key + stored ephemeral public key
Trait Implementations§
Source§impl Clone for EphemeralEcdhContent
impl Clone for EphemeralEcdhContent
Source§fn clone(&self) -> EphemeralEcdhContent
fn clone(&self) -> EphemeralEcdhContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EphemeralEcdhContent
impl Debug for EphemeralEcdhContent
Source§impl<'de> Deserialize<'de> for EphemeralEcdhContent
impl<'de> Deserialize<'de> for EphemeralEcdhContent
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 PartialEq for EphemeralEcdhContent
impl PartialEq for EphemeralEcdhContent
Source§impl Serialize for EphemeralEcdhContent
impl Serialize for EphemeralEcdhContent
impl Eq for EphemeralEcdhContent
impl StructuralPartialEq for EphemeralEcdhContent
Auto Trait Implementations§
impl Freeze for EphemeralEcdhContent
impl RefUnwindSafe for EphemeralEcdhContent
impl Send for EphemeralEcdhContent
impl Sync for EphemeralEcdhContent
impl Unpin for EphemeralEcdhContent
impl UnwindSafe for EphemeralEcdhContent
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more