pub struct SecureMessage {
pub type: MessageType,
pub payload: String,
}Expand description
An encrypted message model defines a secure message that has been encrypted using the Sirius’s SDK libraries.
Please note: The strategy to encrypt and decrypt should be consistent between the different SDKs. A client may send a transaction using a different encryption strategy than the recipient. Even though the same encryption algorithm is used, the outcome may still be different depending on the encoding process.
The encryption strategy this SDK uses is UTF-8 and hex encodings: “plain text” string -> utf8 byte array -> encrypted byte array -> hex string
Fields§
§type: MessageTypeMessage type
payload: StringMessage payload.
Implementations§
Source§impl SecureMessage
impl SecureMessage
Sourcepub fn create(
sender_account: &Account,
recipient_public_account: &PublicAccount,
payload: &str,
) -> Result<Self>
pub fn create( sender_account: &Account, recipient_public_account: &PublicAccount, payload: &str, ) -> Result<Self>
Creates an encrypted message from [plainTextMessage].
The message is encrypted using a shared key generated by the [senderPrivateKey] and the [recipient_public_key]. The recipient can decrypt this message using this shared key by taking the sender’s public key and the recipient’s public key.
Sourcepub fn from_hex_payload(payload: &str) -> Result<Self>
pub fn from_hex_payload(payload: &str) -> Result<Self>
It creates a SecureMessage from the payload hex without the 01 prefix.
The 01 prefix will be attached to the final payload.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
It creates a SecureMessage from the given bytes.
Sourcepub fn decrypt(
&self,
recipient_account: &Account,
sender_public_account: PublicAccount,
) -> Result<PlainMessage>
pub fn decrypt( &self, recipient_account: &Account, sender_public_account: PublicAccount, ) -> Result<PlainMessage>
Decrypts an SecureMessage.
Returns a PlainMessage.
Trait Implementations§
Source§impl Clone for SecureMessage
impl Clone for SecureMessage
Source§fn clone(&self) -> SecureMessage
fn clone(&self) -> SecureMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more