pub struct DmEnvelope {
pub protocol_version: u16,
pub request_id: [u8; 16],
pub sender_agent_id: [u8; 32],
pub sender_machine_id: [u8; 32],
pub recipient_agent_id: [u8; 32],
pub created_at_unix_ms: u64,
pub expires_at_unix_ms: u64,
pub body: DmBody,
pub signature: Vec<u8>,
}Expand description
A direct-message envelope, signed by the sender’s ML-DSA-65 agent key
and (for Payload variants) encrypted to the recipient’s ML-KEM-768
public key.
See docs/design/dm-over-gossip.md for the full spec.
Fields§
§protocol_version: u16Wire-format protocol version. Receivers reject envelopes whose
protocol_version > self.max_protocol_version.
request_id: [u8; 16]128-bit per-message id. Random on first send; reused on retries of the same logical message to enable recipient dedupe.
sender_agent_id: [u8; 32]Sender’s AgentId (32 bytes, SHA-256 of ML-DSA-65 pubkey).
sender_machine_id: [u8; 32]Sender’s MachineId. Populates trust-policy evaluation.
recipient_agent_id: [u8; 32]Recipient’s AgentId. Receivers drop envelopes addressed to a different agent_id (defence-in-depth; topic filtering normally prevents this).
created_at_unix_ms: u64Sender-local unix-ms timestamp at envelope creation.
expires_at_unix_ms: u64Envelope expiry. Receivers drop envelopes past this time.
body: DmBodyKind — Payload or Ack.
signature: Vec<u8>ML-DSA-65 signature over the domain-separated envelope bytes
computed via build_signed_bytes().
Implementations§
Source§impl DmEnvelope
impl DmEnvelope
Sourcepub fn signed_bytes(&self) -> Result<Vec<u8>>
pub fn signed_bytes(&self) -> Result<Vec<u8>>
Domain-separated bytes to sign. Only depends on the fields covered
by the signature — signature itself is excluded.
Sourcepub fn aead_aad(&self) -> Vec<u8> ⓘ
pub fn aead_aad(&self) -> Vec<u8> ⓘ
AAD used for the inner-payload AEAD. Only meaningful for
DmBody::Payload; callers may still build it ahead of time for
general use.
Sourcepub fn to_wire_bytes(&self) -> Result<Vec<u8>>
pub fn to_wire_bytes(&self) -> Result<Vec<u8>>
Serialize envelope with postcard for over-the-wire transport.
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_wire_bytes(bytes: &[u8]) -> Result<Self>
Deserialize envelope from the wire. Enforces the envelope-size cap.
Sourcepub fn dedupe_key(&self) -> DedupeKey
pub fn dedupe_key(&self) -> DedupeKey
Dedupe key for this envelope.
Trait Implementations§
Source§impl Clone for DmEnvelope
impl Clone for DmEnvelope
Source§fn clone(&self) -> DmEnvelope
fn clone(&self) -> DmEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DmEnvelope
impl Debug for DmEnvelope
Source§impl<'de> Deserialize<'de> for DmEnvelope
impl<'de> Deserialize<'de> for DmEnvelope
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>,
Auto Trait Implementations§
impl Freeze for DmEnvelope
impl RefUnwindSafe for DmEnvelope
impl Send for DmEnvelope
impl Sync for DmEnvelope
impl Unpin for DmEnvelope
impl UnsafeUnpin for DmEnvelope
impl UnwindSafe for DmEnvelope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more