pub struct ByteMatrix(/* private fields */);Expand description
An F_2-linear map on a byte, held the way the affine-byte instruction reads it.
Output bit i is the parity of the input byte against byte 7 - i of the quadword.
out[i] = XOR over b of row[7 - i][b] * in[b]Squaring, scaling by a constant, a basis change and a linearized polynomial all fit here.
Tabulated once, each becomes a single instruction per register.
Implementations§
Source§impl ByteMatrix
impl ByteMatrix
Sourcepub const fn from_images(images: [u8; 8]) -> Self
pub const fn from_images(images: [u8; 8]) -> Self
The map sending basis vector 1 << b to entry b of the argument.
A linear map is pinned down by where it sends each of the eight basis vectors.
Sourcepub const fn compose(self, first: Self) -> Self
pub const fn compose(self, first: Self) -> Self
The map applying the argument first and this one second.
Sourcepub const fn to_quadword(self) -> u64
pub const fn to_quadword(self) -> u64
The row layout the affine-byte instruction takes as its matrix operand.
Sourcepub const fn from_quadword(rows: u64) -> Self
pub const fn from_quadword(rows: u64) -> Self
The map already held in that row layout.
Every quadword is a matrix, so this cannot fail.
Sourcepub fn apply_slice(self, bytes: &mut [u8])
pub fn apply_slice(self, bytes: &mut [u8])
Replaces every byte of the slice with its image.
Inlined so a caller with a fixed-length block sweeps it without a call.
Trait Implementations§
Source§impl Clone for ByteMatrix
impl Clone for ByteMatrix
impl Copy for ByteMatrix
Source§impl Debug for ByteMatrix
impl Debug for ByteMatrix
Source§impl Default for ByteMatrix
impl Default for ByteMatrix
impl Eq for ByteMatrix
Source§impl Hash for ByteMatrix
impl Hash for ByteMatrix
Source§impl PartialEq for ByteMatrix
impl PartialEq for ByteMatrix
impl StructuralPartialEq for ByteMatrix
Auto Trait Implementations§
impl Freeze for ByteMatrix
impl RefUnwindSafe for ByteMatrix
impl Send for ByteMatrix
impl Sync for ByteMatrix
impl Unpin for ByteMatrix
impl UnsafeUnpin for ByteMatrix
impl UnwindSafe for ByteMatrix
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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