pub struct EncryptionKey {
pub key: [u8; 32],
pub key_id: Vec<u8>,
pub created_at: u64,
pub derivation_info: Option<KeyDerivationInfo>,
}Expand description
ChaCha20-Poly1305 encryption key
Fields§
§key: [u8; 32]The actual key bytes (32 bytes for ChaCha20)
key_id: Vec<u8>Key identifier
created_at: u64When this key was created
derivation_info: Option<KeyDerivationInfo>Optional derivation info (for mnemonic-derived keys)
Implementations§
Source§impl EncryptionKey
impl EncryptionKey
Sourcepub fn from_mnemonic(
mnemonic: &MnemonicPhrase,
passphrase: &str,
context: &str,
timestamp: u64,
) -> Result<Self, CryptoError>
pub fn from_mnemonic( mnemonic: &MnemonicPhrase, passphrase: &str, context: &str, timestamp: u64, ) -> Result<Self, CryptoError>
Derive an encryption key from a mnemonic phrase
Sourcepub fn from_mnemonic_with_salt(
mnemonic: &MnemonicPhrase,
passphrase: &str,
context: &str,
salt: &[u8; 32],
timestamp: u64,
) -> Result<Self, CryptoError>
pub fn from_mnemonic_with_salt( mnemonic: &MnemonicPhrase, passphrase: &str, context: &str, salt: &[u8; 32], timestamp: u64, ) -> Result<Self, CryptoError>
Derive an encryption key from a mnemonic phrase with specific salt (for key recovery)
Sourcepub fn encrypt_content(
&self,
plaintext: &[u8],
) -> Result<ChaCha20Poly1305Content, CryptoError>
pub fn encrypt_content( &self, plaintext: &[u8], ) -> Result<ChaCha20Poly1305Content, CryptoError>
Encrypt data to minimal ChaCha20Poly1305Content (no key_id for wire protocol)
Sourcepub fn decrypt_content(
&self,
content: &ChaCha20Poly1305Content,
) -> Result<Vec<u8>, CryptoError>
pub fn decrypt_content( &self, content: &ChaCha20Poly1305Content, ) -> Result<Vec<u8>, CryptoError>
Decrypt ChaCha20Poly1305Content (assumes correct key based on channel context)
Trait Implementations§
Source§impl Clone for EncryptionKey
impl Clone for EncryptionKey
Source§fn clone(&self) -> EncryptionKey
fn clone(&self) -> EncryptionKey
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 EncryptionKey
impl Debug for EncryptionKey
Source§impl<'de> Deserialize<'de> for EncryptionKey
impl<'de> Deserialize<'de> for EncryptionKey
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 EncryptionKey
impl PartialEq for EncryptionKey
Source§impl Serialize for EncryptionKey
impl Serialize for EncryptionKey
impl Eq for EncryptionKey
impl StructuralPartialEq for EncryptionKey
Auto Trait Implementations§
impl Freeze for EncryptionKey
impl RefUnwindSafe for EncryptionKey
impl Send for EncryptionKey
impl Sync for EncryptionKey
impl Unpin for EncryptionKey
impl UnwindSafe for EncryptionKey
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