pub struct SignedEnvelope {
pub cert_chain: CertChain,
pub recipient: Recipient,
pub nonce: [u8; 24],
pub sequence: u64,
pub payload_cid: [u8; 32],
pub payload: ByteBuf,
pub agent_sig: SerdeSig,
}Expand description
A wire envelope, signed by the sender’s agent key.
Fields, in the order they’re produced by Self::new:
cert_chain— proves the sender’s agent identity.recipient— addressing tag.nonce— 24 random bytes; replay-protection scope.sequence— monotonic per-session counter.payload_cid— BLAKE3 ofpayload.payload— opaque bytes (the actual message).agent_sig— signature overENVELOPE_TAG || recipient_bytes || nonce || seq || payload_cid.
Fields§
§cert_chain: CertChain§recipient: Recipient§nonce: [u8; 24]§sequence: u64§payload_cid: [u8; 32]§payload: ByteBuf§agent_sig: SerdeSigImplementations§
Source§impl SignedEnvelope
impl SignedEnvelope
Sourcepub fn new(
sender: &AgentKey,
recipient: Recipient,
sequence: u64,
payload: Vec<u8>,
) -> Self
pub fn new( sender: &AgentKey, recipient: Recipient, sequence: u64, payload: Vec<u8>, ) -> Self
Build and sign a new envelope.
The 24-byte nonce is drawn from rand::thread_rng; callers
don’t manage it. The sequence is supplied by the caller —
it’s session-scoped state, not crate state.
Sourcepub fn verify(&self) -> Result<()>
pub fn verify(&self) -> Result<()>
Verify the envelope end-to-end:
- Cert chain is valid (user sig over agent metadata).
payload_cidmatches the actualpayloadBLAKE3.- Agent signature is valid over
(recipient, nonce, sequence, payload_cid).
Sourcepub fn sender_agent_fp(&self) -> Fingerprint
pub fn sender_agent_fp(&self) -> Fingerprint
Fingerprint of the sending agent.
Sourcepub fn sender_user_fp(&self) -> Fingerprint
pub fn sender_user_fp(&self) -> Fingerprint
Fingerprint of the user the sender belongs to.
Trait Implementations§
Source§impl Clone for SignedEnvelope
impl Clone for SignedEnvelope
Source§fn clone(&self) -> SignedEnvelope
fn clone(&self) -> SignedEnvelope
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SignedEnvelope
impl Debug for SignedEnvelope
Source§impl<'de> Deserialize<'de> for SignedEnvelope
impl<'de> Deserialize<'de> for SignedEnvelope
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for SignedEnvelope
Source§impl PartialEq for SignedEnvelope
impl PartialEq for SignedEnvelope
Source§fn eq(&self, other: &SignedEnvelope) -> bool
fn eq(&self, other: &SignedEnvelope) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SignedEnvelope
impl Serialize for SignedEnvelope
impl StructuralPartialEq for SignedEnvelope
Auto Trait Implementations§
impl Freeze for SignedEnvelope
impl RefUnwindSafe for SignedEnvelope
impl Send for SignedEnvelope
impl Sync for SignedEnvelope
impl Unpin for SignedEnvelope
impl UnsafeUnpin for SignedEnvelope
impl UnwindSafe for SignedEnvelope
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
Mutably borrows from an owned value. Read more