pub struct AgentMessage {
pub message_id: String,
pub from: AgentIdentity,
pub to: AgentIdentity,
pub message_type: AgentMessageType,
pub payload: Vec<u8>,
pub timestamp: Timestamp,
pub signature: Option<Vec<u8>>,
pub pq_signature: Option<Vec<u8>>,
pub reply_to: Option<String>,
}Expand description
A message between agents on Tenzro Network
Wave 3d hybrid signing: signed messages carry BOTH signature (Ed25519
classical) and pq_signature (ML-DSA-65). When the message is signed,
both legs are Some(_). When the message is unsigned (trusted
single-process tests), both legs are None. Mixing — one Some, one
None — is rejected by the router.
Fields§
§message_id: StringMessage ID
from: AgentIdentitySender agent
to: AgentIdentityRecipient agent
message_type: AgentMessageTypeMessage type
payload: Vec<u8>Message payload
timestamp: TimestampMessage timestamp
signature: Option<Vec<u8>>Classical Ed25519 message signature (None when unsigned)
pq_signature: Option<Vec<u8>>Post-quantum ML-DSA-65 message signature (3309 bytes when signed,
None when unsigned). Must be present whenever signature is present.
reply_to: Option<String>Reply-to message ID (if this is a reply)
Implementations§
Source§impl AgentMessage
impl AgentMessage
Sourcepub fn new(
from: AgentIdentity,
to: AgentIdentity,
message_type: AgentMessageType,
payload: Vec<u8>,
) -> Self
pub fn new( from: AgentIdentity, to: AgentIdentity, message_type: AgentMessageType, payload: Vec<u8>, ) -> Self
Creates a new agent message
Sourcepub fn as_reply_to(self, message_id: String) -> Self
pub fn as_reply_to(self, message_id: String) -> Self
Sets the message as a reply to another message
Sourcepub fn with_signature(self, signature: Vec<u8>) -> Self
pub fn with_signature(self, signature: Vec<u8>) -> Self
Adds a classical-only signature to the message.
Wave 3d hybrid signing: this is the classical (Ed25519) leg only.
Production agent message production should call with_hybrid_signature
instead so both legs are populated; the router rejects messages with
only the classical leg present.
Sourcepub fn with_hybrid_signature(self, classical: Vec<u8>, pq: Vec<u8>) -> Self
pub fn with_hybrid_signature(self, classical: Vec<u8>, pq: Vec<u8>) -> Self
Adds a full hybrid (Ed25519 + ML-DSA-65) signature to the message.
Sourcepub fn signing_data(&self) -> Vec<u8> ⓘ
pub fn signing_data(&self) -> Vec<u8> ⓘ
Returns the canonical bytes that should be signed.
This deliberately excludes the signature field so that signing
followed by verifying yields a stable hash. The encoding is a simple
length-prefixed concatenation of the message-determining fields:
signing_data = len(message_id) || message_id
|| from.agent_id_len || from.agent_id || from.address
|| to.agent_id_len || to.agent_id || to.address
|| message_type_tag (u8)
|| payload_len (u64 LE) || payload
|| timestamp_millis (i64 LE)
|| reply_to_present (u8) [|| reply_to_len || reply_to]All len() fields are encoded as little-endian u64 for
deterministic, length-prefixed framing. This avoids ambiguity attacks
where two different field arrangements collide into the same byte
stream (e.g. concatenating two strings without a length prefix).
Sourcepub fn hash(&self) -> Hash
pub fn hash(&self) -> Hash
Computes the SHA-256 hash of the message’s canonical signing data.
This is the value passed to a signer when producing the
signature field, and the value verified against the public key
when validating an inbound message. Because it is computed from
Self::signing_data, the signature field itself is not
included in the hash, so signing is idempotent.
Trait Implementations§
Source§impl Clone for AgentMessage
impl Clone for AgentMessage
Source§fn clone(&self) -> AgentMessage
fn clone(&self) -> AgentMessage
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 AgentMessage
impl Debug for AgentMessage
Source§impl<'de> Deserialize<'de> for AgentMessage
impl<'de> Deserialize<'de> for AgentMessage
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>,
impl Eq for AgentMessage
Source§impl PartialEq for AgentMessage
impl PartialEq for AgentMessage
Source§fn eq(&self, other: &AgentMessage) -> bool
fn eq(&self, other: &AgentMessage) -> bool
self and other values to be equal, and is used by ==.