It is available not only std environment but also no_std. Also Intel SGX is supported. If you feel interested, visit my repository to see other examples, check algorithms used, and give a star
-------------------------
#[derive(Debug, Serialize, Deserialize)]
struct Message {
content: String,
sender: String,
}// This is the trick!
impl SerdeEncryptSharedKey for Message {}
let shared_key = [0u8; 32]; // or read from your filesystem?
let msg = Message {
content: "I you.".to_string(),
sender: "Alice".to_string(),
};// Encrypt and serialize the serde struct
let encrypted_message = msg.encrypt(&shared_key)?;
let serialized_encrypted_message: Vec<u8> = encrypted_message.serialize()?;
// Deserialize and decrypt
let encrypted_message = EncryptedMessage::deserialize(serialized_encrypted_message)?;
let msg = Message::decrypt_owned(&encrypted_message, &shared_key)
-------------------------
SerdeEncryptPublicKey trait is also provided mainly for secure shared-key exchange (using ECDH algorithm internally).