pub struct PrivateMessage {
pub timestamp: u64,
pub encrypted_sender: Vec<u8>,
pub encrypted_content: Vec<u8>,
pub signature_bytes: Vec<u8>,
}Expand description
A private message with encrypted sender and content
Fields§
§timestamp: u64§encrypted_sender: Vec<u8>§encrypted_content: Vec<u8>§signature_bytes: Vec<u8>Implementations§
Source§impl PrivateMessage
impl PrivateMessage
Sourcepub fn new(
sender_keypair: &Keypair,
recipient_pk: &PublicKey,
content: &str,
) -> Result<Self>
pub fn new( sender_keypair: &Keypair, recipient_pk: &PublicKey, content: &str, ) -> Result<Self>
Create a new encrypted message
Sourcepub fn decrypt_content(
&self,
receiver_keypair: &Keypair,
other_participant: &PublicKey,
) -> Result<String>
pub fn decrypt_content( &self, receiver_keypair: &Keypair, other_participant: &PublicKey, ) -> Result<String>
Decrypt the message content
Sourcepub fn decrypt_sender(
&self,
receiver_keypair: &Keypair,
other_participant: &PublicKey,
) -> Result<String>
pub fn decrypt_sender( &self, receiver_keypair: &Keypair, other_participant: &PublicKey, ) -> Result<String>
Decrypt the sender public key
Sourcepub fn verify_signature(
&self,
decrypted_content: &str,
decrypted_sender: &str,
) -> Result<bool>
pub fn verify_signature( &self, decrypted_content: &str, decrypted_sender: &str, ) -> Result<bool>
Verify the message signature
Sourcepub fn generate_id() -> String
pub fn generate_id() -> String
Generate a unique message ID
Trait Implementations§
Source§impl Clone for PrivateMessage
impl Clone for PrivateMessage
Source§fn clone(&self) -> PrivateMessage
fn clone(&self) -> PrivateMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 PrivateMessage
impl Debug for PrivateMessage
Source§impl<'de> Deserialize<'de> for PrivateMessage
impl<'de> Deserialize<'de> for PrivateMessage
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
Auto Trait Implementations§
impl Freeze for PrivateMessage
impl RefUnwindSafe for PrivateMessage
impl Send for PrivateMessage
impl Sync for PrivateMessage
impl Unpin for PrivateMessage
impl UnsafeUnpin for PrivateMessage
impl UnwindSafe for PrivateMessage
Blanket Implementations§
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