pub struct ResponseEnvelope {
pub request_id: u64,
pub payload: Vec<u8>,
pub encrypted_response: Option<Vec<u8>>,
pub sig: [u8; 64],
pub cnf: [u8; 32],
pub cose: Vec<u8>,
pub policy: CryptoPolicy,
pub server_challenge: Option<Vec<u8>>,
}Expand description
Signed response envelope for E2E authenticated responses.
All RPC responses are signed to prevent MITM attacks on response data (e.g., server’s DH public key in StreamInfo).
§Security (#275 — Hybrid parity with SignedEnvelope)
The signing-data is request_id || payload, binding the response to a
specific request and ensuring the payload hasn’t been tampered with. The
authoritative authentication mechanism is the COSE composite cose —
the pinned EdDSA + ML-DSA-65 composite over that signing-data, bound to
RESPONSE_ENVELOPE_TYPE_ID via the COSE
external_aad so it can NEVER verify as a request signature.
sig/cnf remain populated with the raw EdDSA signature + signer public
key for backward compatibility and signer-pubkey advertisement, but the
COSE composite is what verify* enforces.
Fields§
§request_id: u64Request ID this response corresponds to
payload: Vec<u8>Serialized inner response
encrypted_response: Option<Vec<u8>>HyKEM COSE_Encrypt0 carrying a ResponsePlaintext. When present the
outer payload is empty and the hybrid signature covers these bytes.
sig: [u8; 64]Ed25519 signature (64 bytes) over request_id || payload
cnf: [u8; 32]Ed25519 public key of the signer (32 bytes)
cose: Vec<u8>#275: CBOR-encoded nested COSE composite signature (detached).
Authoritative authentication mechanism, mirroring SignedEnvelope::cose.
Production carries the pinned EdDSA + ML-DSA-65 composite over the
response signing-data (request_id || payload), bound to the
distinct RESPONSE_ENVELOPE_TYPE_ID domain. The ML-DSA-65 verifying key
is resolved by kid from a PqTrustStore (kid-anchored), not embedded.
policy: CryptoPolicySignature suite marker. Production construction always uses Hybrid.
server_challenge: Option<Vec<u8>>v16 §4.7: the server’s current unattributed-proof challenge, carried uniformly on every pre-handler denial.
Bound into the signing transcript when present (see
ResponseEnvelope::bind_server_challenge), so it can neither be
stripped nor substituted in flight. Absent on ordinary responses, where
the transcript is unchanged.
Implementations§
Source§impl ResponseEnvelope
impl ResponseEnvelope
Sourcepub fn new_signed_hybrid(
request_id: u64,
payload: Vec<u8>,
signing_key: &SigningKey,
pq_signing_key: &MlDsaSigningKey,
) -> Self
pub fn new_signed_hybrid( request_id: u64, payload: Vec<u8>, signing_key: &SigningKey, pq_signing_key: &MlDsaSigningKey, ) -> Self
Create and dual-sign a response with Ed25519 + ML-DSA-65 (Hybrid).
Sourcepub fn new_signed_with_policy(
request_id: u64,
payload: Vec<u8>,
signing_key: &SigningKey,
pq_signing_key: Option<&MlDsaSigningKey>,
policy: CryptoPolicy,
) -> Result<Self>
pub fn new_signed_with_policy( request_id: u64, payload: Vec<u8>, signing_key: &SigningKey, pq_signing_key: Option<&MlDsaSigningKey>, policy: CryptoPolicy, ) -> Result<Self>
Create and sign a response under an explicit [CryptoPolicy].
Mirrors SignedEnvelope::new_signed_with_policy:
Hybrid: EdDSA + ML-DSA-65 nested composite;pq_signing_keyMUST beSome; absence is a fail-closed construction error returned asErr.
sig/cnf are always populated with the raw EdDSA signature + signer
public key. The COSE build is fail-closed: a missing mandatory PQ
key or a COSE encoding error is propagated as Err rather than
silently emitting an empty (fail-open) composite, matching the request
side.
Sourcepub fn new_signed_with_challenge(
request_id: u64,
payload: Vec<u8>,
server_challenge: Option<Vec<u8>>,
signing_key: &SigningKey,
pq_signing_key: Option<&MlDsaSigningKey>,
policy: CryptoPolicy,
) -> Result<Self>
pub fn new_signed_with_challenge( request_id: u64, payload: Vec<u8>, server_challenge: Option<Vec<u8>>, signing_key: &SigningKey, pq_signing_key: Option<&MlDsaSigningKey>, policy: CryptoPolicy, ) -> Result<Self>
Create and sign a response that also advertises the server’s current challenge in the fixed response slot (§4.7).
The challenge is part of the signed transcript, so a denial’s challenge is as authentic as its payload.
Sourcepub fn new_signed_encrypted(
request_id: u64,
payload: Vec<u8>,
signing_key: &SigningKey,
pq_signing_key: &MlDsaSigningKey,
recipient: &RecipientPublic,
request_iat: i64,
request_nonce: &[u8; 16],
service_domain: &str,
) -> EnvelopeResult<Self>
pub fn new_signed_encrypted( request_id: u64, payload: Vec<u8>, signing_key: &SigningKey, pq_signing_key: &MlDsaSigningKey, recipient: &RecipientPublic, request_iat: i64, request_nonce: &[u8; 16], service_domain: &str, ) -> EnvelopeResult<Self>
Seal a unary response to the request’s one-shot recipient, then hybrid-sign the ciphertext in the response signature domain.
Sourcepub fn new_signed_encrypted_with_challenge(
request_id: u64,
payload: Vec<u8>,
server_challenge: Option<Vec<u8>>,
signing_key: &SigningKey,
pq_signing_key: &MlDsaSigningKey,
recipient: &RecipientPublic,
request_iat: i64,
request_nonce: &[u8; 16],
service_domain: &str,
) -> EnvelopeResult<Self>
pub fn new_signed_encrypted_with_challenge( request_id: u64, payload: Vec<u8>, server_challenge: Option<Vec<u8>>, signing_key: &SigningKey, pq_signing_key: &MlDsaSigningKey, recipient: &RecipientPublic, request_iat: i64, request_nonce: &[u8; 16], service_domain: &str, ) -> EnvelopeResult<Self>
Seal a unary response that also advertises the server’s current challenge, so a denial on a confidential carrier carries one too.
The challenge is a public server value and rides in the cleartext slot — a client that cannot yet form an admissible proof must be able to read it — but it is bound into the sealed response’s signature transcript, so it can be neither stripped nor substituted.
Sourcepub fn verify_with(
&self,
expected_pubkey: Option<&VerifyingKey>,
pq_store: Option<&dyn PqTrustStore>,
verify_policy: CryptoPolicy,
) -> Result<()>
pub fn verify_with( &self, expected_pubkey: Option<&VerifyingKey>, pq_store: Option<&dyn PqTrustStore>, verify_policy: CryptoPolicy, ) -> Result<()>
Verify with an explicit kid-anchored PQ trust store and verify policy.
Mirrors SignedEnvelope::verify_with’s mandatory-hybrid semantics:
pq_store: whenSome, resolves the trust-anchored ML-DSA-65 key for the response’s EdDSA signer (cnf); the outer COSE entry must verify against it and its kid must match (kid-anchoring).verify_policy = Hybridrequires an anchored ML-DSA-65 key and the intact outer signature. Unanchored and classical-only responses fail.
Sourcepub fn cnf_key(&self) -> Result<VerifyingKey>
pub fn cnf_key(&self) -> Result<VerifyingKey>
Get the signer’s public key.
Trait Implementations§
Source§impl Clone for ResponseEnvelope
impl Clone for ResponseEnvelope
Source§fn clone(&self) -> ResponseEnvelope
fn clone(&self) -> ResponseEnvelope
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 ResponseEnvelope
impl Debug for ResponseEnvelope
Source§impl FromCapnp for ResponseEnvelope
impl FromCapnp for ResponseEnvelope
Auto Trait Implementations§
impl Freeze for ResponseEnvelope
impl RefUnwindSafe for ResponseEnvelope
impl Send for ResponseEnvelope
impl Sync for ResponseEnvelope
impl Unpin for ResponseEnvelope
impl UnsafeUnpin for ResponseEnvelope
impl UnwindSafe for ResponseEnvelope
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