pub struct StreamDecoder { /* private fields */ }Expand description
Incremental decoder that accumulates ciphertext via update
and decodes at finalize using a pre-received
entropy snapshot and commitment.
§Example
use kk_crypto::{StreamDecoder, StreamEncoder};
let secret = b"our-shared-secret";
// Sender side (streaming encode)
let mut enc = StreamEncoder::new(secret).unwrap();
enc.update(b"Hello ");
enc.update(b"KK!");
let packet = enc.finalize().unwrap();
// Receiver side (streaming decode)
let mut dec = StreamDecoder::new(
secret,
packet.entropy_snapshot.clone(),
packet.commitment.clone(),
);
dec.update(&packet.ciphertext);
let plaintext = dec.finalize().unwrap();
assert_eq!(plaintext, b"Hello KK!");Implementations§
Source§impl StreamDecoder
impl StreamDecoder
Sourcepub fn new(
shared_secret: &[u8],
snapshot: EntropySnapshot,
commitment: TemporalCommitment,
) -> Self
pub fn new( shared_secret: &[u8], snapshot: EntropySnapshot, commitment: TemporalCommitment, ) -> Self
Create a new streaming decoder.
The caller must supply the entropy snapshot and commitment from the packet header (typically received before the ciphertext body).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamDecoder
impl RefUnwindSafe for StreamDecoder
impl Send for StreamDecoder
impl Sync for StreamDecoder
impl Unpin for StreamDecoder
impl UnsafeUnpin for StreamDecoder
impl UnwindSafe for StreamDecoder
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
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>
Converts
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>
Converts
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