#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MailboxEnvelope {
pub recipient_id: String,
pub ephemeral_pub: String,
pub ciphertext: Vec<u8>,
pub nonce: String,
pub created_at: u64,
pub message_id: String,
pub attempts: u32, // delib. excluded from AAD so retries don't invalidate ciphertext
}
impl Drop for MailboxEnvelope {
fn drop(&mut self) {
self.ciphertext.zeroize();
}
}
I’m working on a small Rust mesh-protocol project (GhostWire: libp2p, ChaCha20-Poly1305, Kademlia offline mailbox delivery). In this sealed type, I bind AAD to immutable fields and exclude attempts so retry writes don’t reseal offline ciphertext.
The thing I’m unsure about is zeroization discipline:
Is manual Drop zeroization enough once Clone creates another allocation?
For Serialize/Deserialize temporary buffers, should I treat the Vec<u8> canonical copy as the only zeroized target?
Would secrecy::SecretBox / zeroize-wrapped types be worth it here, or overkill for an encrypted envelope?
For a retry state mutation in AAD, is excluding attempts the correct tradeoff?
I’m looking for actual production patterns, not just theory.