pub struct StreamKeys {
pub topic: String,
pub mac_key: Zeroizing<[u8; 32]>,
pub enc_key: Zeroizing<[u8; 32]>,
pub ctrl_topic: String,
pub ctrl_mac_key: Zeroizing<[u8; 32]>,
}Expand description
Derived keys for E2E authenticated streaming.
Contains:
topic: 64-char hex string derived from DH, used as ZMQ subscription prefixmac_key: 32-byte HMAC key for MAC chain verificationctrl_topic: 64-char hex string for control channel (consumer → producer)ctrl_mac_key: 32-byte HMAC key for control channel authentication
Both client and server derive identical keys from their DH shared secret.
Fields§
§topic: StringTopic for ZMQ PUB/SUB routing (64 hex chars = 32 bytes encoded).
mac_key: Zeroizing<[u8; 32]>HMAC key for MAC chain (zeroized on drop).
enc_key: Zeroizing<[u8; 32]>AES-256-GCM key for transport-level AEAD of stream payloads (#321,
zeroized on drop). Distinct from mac_key via its own derivation context
("hyprstream stream-keys v1 enc"). The mesh stream plane seals each
Data/Complete payload under this key; the chained HMAC still runs over the
(now-encrypted) block, so ordering / anti-replay are unchanged.
ctrl_topic: StringControl channel topic (64 hex chars, derived from same DH secret).
ctrl_mac_key: Zeroizing<[u8; 32]>Control channel HMAC key (zeroized on drop).
Implementations§
Source§impl StreamKeys
impl StreamKeys
Sourcepub fn new(topic: String, mac_key: [u8; 32]) -> Self
pub fn new(topic: String, mac_key: [u8; 32]) -> Self
Create from raw topic and mac_key bytes.
The AEAD enc_key is deterministically derived from mac_key via a
dedicated context so this constructor stays source-compatible while still
producing a stable, non-zero, key-separated AEAD key.
Sourcepub fn with_ctrl(
topic: String,
mac_key: [u8; 32],
enc_key: [u8; 32],
ctrl_topic: String,
ctrl_mac_key: [u8; 32],
) -> Self
pub fn with_ctrl( topic: String, mac_key: [u8; 32], enc_key: [u8; 32], ctrl_topic: String, ctrl_mac_key: [u8; 32], ) -> Self
Create with both data and control channel keys plus the AEAD enc_key.
Sourcepub fn topic_prefix_bytes(&self) -> EnvelopeResult<[u8; 16]>
pub fn topic_prefix_bytes(&self) -> EnvelopeResult<[u8; 16]>
Get the first 16 bytes of topic as bytes (for first block’s prevMac).
In the MAC chain, block 0 uses topic[..16] as prevMac.
§Errors
Returns error if topic is not valid hex (should never happen with properly derived keys).
Trait Implementations§
Source§impl Clone for StreamKeys
impl Clone for StreamKeys
Source§fn clone(&self) -> StreamKeys
fn clone(&self) -> StreamKeys
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StreamKeys
impl RefUnwindSafe for StreamKeys
impl Send for StreamKeys
impl Sync for StreamKeys
impl Unpin for StreamKeys
impl UnsafeUnpin for StreamKeys
impl UnwindSafe for StreamKeys
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