pub struct ChunkCipher { /* private fields */ }Expand description
ChunkCipher wraps the ChaCha20-Poly1305 key used to encrypt and decrypt
chunk data before/after RLNC coding.
Production path: create via ChunkCipher::for_user which derives a
CEK from the owner’s identity secret and the plaintext chunk hash.
Implementations§
Source§impl ChunkCipher
impl ChunkCipher
Sourcepub fn for_user(secret_material: &[u8; 32], plaintext_hash: &[u8; 32]) -> Self
pub fn for_user(secret_material: &[u8; 32], plaintext_hash: &[u8; 32]) -> Self
Derive the Content Encryption Key for a chunk and build a cipher.
secret_material comes from crate::identity::Identity::secret_material.
plaintext_hash is BLAKE3(chunk_data) computed before encryption.
cek = BLAKE3_keyed(secret_material, "billpouch/cek/v1" || plaintext_hash)Sourcepub fn from_raw_key(key: [u8; 32]) -> Self
pub fn from_raw_key(key: [u8; 32]) -> Self
Build a cipher from a raw 32-byte key.
Useful for tests and for future key-wrapping schemes.
Auto Trait Implementations§
impl Freeze for ChunkCipher
impl RefUnwindSafe for ChunkCipher
impl Send for ChunkCipher
impl Sync for ChunkCipher
impl Unpin for ChunkCipher
impl UnwindSafe for ChunkCipher
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
§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>
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