pub struct RequestEnvelope {Show 13 fields
pub request_id: u64,
pub payload: Vec<u8>,
pub iat: i64,
pub nonce: [u8; 16],
pub authorization: Authorization,
pub delegation_token: Option<String>,
pub wth: Option<[u8; 32]>,
pub client_dh_public: Option<[u8; 32]>,
pub client_kem_public: Option<RecipientPublic>,
pub response_kem_recipient: Option<RecipientPublic>,
pub service_domain: Option<String>,
pub proof_cwt: Option<Vec<u8>>,
pub authorization_witness: Option<SensitiveBytes>,
}Expand description
Unsigned envelope wrapping an RPC request.
This struct contains all request metadata and is signed by SignedEnvelope.
The entire serialized RequestEnvelope is covered by the signature.
§Replay Protection
Legacy: nonce + iat nonce-cache replay. Superseded by v16 proof CWT
cti-based replay admission (§4.5). Retained for dual-read wire compat;
the proof-CWT path is fail-closed when present.
Fields§
§request_id: u64DEPRECATED: replaced by proof CWT cti. Retained for wire compat.
payload: Vec<u8>Serialized inner request (e.g., RegistryRequest, InferenceRequest)
iat: i64Unix timestamp in milliseconds for expiration check
nonce: [u8; 16]DEPRECATED: replaced by proof CWT cti replay admission.
Authorization context
delegation_token: Option<String>Delegation token relayed by a trusted service (e.g., OAI, MCP adapter).
Reserved. Serialized in the envelope and covered by the signature, but not yet consumed server-side. Intended for bearer delegation flows where a gateway service forwards a user’s JWT on their behalf. Server-side extraction will be added when the delegation trust model is finalized.
wth: Option<[u8; 32]>DEPRECATED: replaced by proof CWT credential_hash (-70001).
client_dh_public: Option<[u8; 32]>Client’s ephemeral DH public key for stream key derivation. Present on streaming requests; the server uses this with its own ephemeral keypair to derive the shared secret for HMAC chain keys.
client_kem_public: Option<RecipientPublic>Fresh, suite-complete HyKEM recipient for identified stream setup.
This is authenticated inside the request envelope and is distinct from
both the legacy classical DH field and the one-shot unary-response
recipient. The server must bind it into an [IdentifiedStreamBinding]
before deriving or releasing stream epoch keys.
response_kem_recipient: Option<RecipientPublic>Fresh per-call hybrid-KEM recipient for the unary response. This is
distinct from both legacy client_dh_public and stream-plane
clientKemPublic, and is carried only inside a sealed network request.
service_domain: Option<String>Canonical destination service. On untrusted carriers this is required, carried only in the signed+sealed request, and checked by dispatch.
proof_cwt: Option<Vec<u8>>v16 proof CWT (application/vnd.hyprstream.proof+cwt). When present,
carries the canonical request body, credential hash, response binding,
and one 128-bit request_id replacing requestId+nonce. Servers verify
this in the dispatch pipeline; the legacy nonce-based replay cache is
the fallback during dual-read migration.
Read-only mediated-authorization proof, never a dispatch credential.
Implementations§
Source§impl RequestEnvelope
impl RequestEnvelope
Sourcepub fn new(payload: Vec<u8>) -> Self
pub fn new(payload: Vec<u8>) -> Self
Create a new request envelope with fresh request ID, nonce, and timestamp.
Set authorization context.
Sourcepub fn with_jwt_token(self, token: String) -> Self
pub fn with_jwt_token(self, token: String) -> Self
Set opaque JWT token as IdJag authorization.
Sourcepub fn with_delegation_token(self, token: String) -> Self
pub fn with_delegation_token(self, token: String) -> Self
Set delegation token for relay by a trusted service.
Sourcepub fn with_wth_of(self, jwt: &str) -> Self
pub fn with_wth_of(self, jwt: &str) -> Self
Bind this proof to a specific WIT by storing SHA-256(jwt). Call this on cached-identity requests where jwtToken is omitted.
Sourcepub fn with_client_dh_public(self, key: [u8; 32]) -> Self
pub fn with_client_dh_public(self, key: [u8; 32]) -> Self
Set the client’s ephemeral DH public key for stream key derivation.
Sourcepub fn with_client_kem_public(
self,
recipient: RecipientPublic,
) -> EnvelopeResult<Self>
pub fn with_client_kem_public( self, recipient: RecipientPublic, ) -> EnvelopeResult<Self>
Set the identified stream’s ephemeral, pinned-suite HyKEM recipient.
Sourcepub fn with_response_kem_recipient(self, recipient: RecipientPublic) -> Self
pub fn with_response_kem_recipient(self, recipient: RecipientPublic) -> Self
Set the one-shot HyKEM recipient for the corresponding unary response.
Sourcepub fn with_service_domain(
self,
service_domain: impl Into<String>,
) -> Result<Self>
pub fn with_service_domain( self, service_domain: impl Into<String>, ) -> Result<Self>
Bind the request to one canonical destination service.
Sourcepub fn with_proof_cwt(self, proof_cwt: Vec<u8>) -> Self
pub fn with_proof_cwt(self, proof_cwt: Vec<u8>) -> Self
Attach a v16 proof CWT to this envelope.
Sourcepub fn jwt_token(&self) -> Option<&str>
pub fn jwt_token(&self) -> Option<&str>
Extract the JWT string from authorization, if it’s an IdJag.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize this envelope to canonical Cap’n Proto bytes for signing.
SECURITY: This method MUST produce deterministic output for cryptographic signatures to work correctly. We use Cap’n Proto’s canonical form as specified in the encoding spec: https://capnproto.org/encoding.html#canonicalization
Canonical form guarantees:
- Same logical data → identical bytes (always)
- Preorder encoding (deterministic pointer ordering)
- Single segment (no segment boundary ambiguity)
- Truncated trailing zeros (no padding differences)
- No packing (binary format is deterministic)
- No segment table framing (redundant for signing)
These bytes are what gets signed in a SignedEnvelope.
Trait Implementations§
Source§impl Clone for RequestEnvelope
impl Clone for RequestEnvelope
Source§fn clone(&self) -> RequestEnvelope
fn clone(&self) -> RequestEnvelope
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 RequestEnvelope
impl Debug for RequestEnvelope
Source§impl FromCapnp for RequestEnvelope
impl FromCapnp for RequestEnvelope
Auto Trait Implementations§
impl Freeze for RequestEnvelope
impl RefUnwindSafe for RequestEnvelope
impl Send for RequestEnvelope
impl Sync for RequestEnvelope
impl Unpin for RequestEnvelope
impl UnsafeUnpin for RequestEnvelope
impl UnwindSafe for RequestEnvelope
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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