Skip to main content

Block8

Struct Block8 

Source
#[repr(transparent)]
pub struct Block8(pub u8);
Expand description

GF(2^8) in the tower basis: bit i is the coefficient of x^i modulo x^8 + x^4 + x^3 + x + 1, as in AES (FIPS-197 §4.2). The flat basis has the same modulus, and φ(a) = a^32.

Tuple Fields§

§0: u8

Implementations§

Source§

impl Block8

Source

pub const fn new(val: u8) -> Self

Builds the element from its tower-basis byte val.

Source

pub fn square(self) -> Self

Returns self^2; squaring is additive in characteristic 2.

Trait Implementations§

Source§

impl Add for Block8

Add (XOR)

Source§

type Output = Block8

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Block8

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl CanonicalDeserialize for Block8

Source§

fn deserialize(bytes: &[u8]) -> Result<Self, ()>

Reads an element from the start of bytes; ignores the rest. Read more
Source§

impl CanonicalSerialize for Block8

Source§

fn serialized_size(&self) -> usize

Returns the encoded length in bytes.
Source§

fn serialize(&self, writer: &mut [u8]) -> Result<(), ()>

Writes the encoding to the start of writer; later bytes are left as they are. Read more
Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Encodes self into a new Vec<u8> of serialized_size() bytes.
Source§

impl Clone for Block8

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Block8

Source§

impl Debug for Block8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Block8

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Block8

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Block8

Source§

impl FlatPromote<Block8> for Block128

Available on non-crate feature table-math only.
Source§

fn promote_flat(val: Flat<Block8>) -> Flat<Self>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl FlatPromote<Block8> for Block16

Source§

fn promote_flat(val: Flat<Block8>) -> Flat<Self>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl FlatPromote<Block8> for Block256

Source§

fn promote_flat(val: Flat<Block8>) -> Flat<Self>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<Block8>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl FlatPromote<Block8> for Block32

Source§

fn promote_flat(val: Flat<Block8>) -> Flat<Self>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl FlatPromote<Block8> for Block64

Source§

fn promote_flat(val: Flat<Block8>) -> Flat<Self>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl From<Bit> for Block8

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Block8> for Block128

Source§

fn from(val: Block8) -> Self

Converts to this type from the input type.
Source§

impl From<Block8> for Block16

Source§

fn from(val: Block8) -> Self

Converts to this type from the input type.
Source§

impl From<Block8> for Block256

Source§

fn from(val: Block8) -> Self

Converts to this type from the input type.
Source§

impl From<Block8> for Block32

Source§

fn from(val: Block8) -> Self

Converts to this type from the input type.
Source§

impl From<Block8> for Block64

Source§

fn from(val: Block8) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Block8

Source§

fn from(val: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Block8

Source§

fn from(val: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Block8

Source§

fn from(val: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Block8

Source§

fn from(val: u128) -> Self

Converts to this type from the input type.
Source§

impl HardwareField for Block8

Source§

fn to_hardware(self) -> Flat<Self>

Maps self to the flat basis: φ(self).
Source§

fn from_hardware(value: Flat<Self>) -> Self

Maps value back to the tower basis: φ⁻¹(value).
Source§

fn add_hardware(lhs: Flat<Self>, rhs: Flat<Self>) -> Flat<Self>

Adds two flat elements (XOR).
Source§

fn add_hardware_packed( lhs: PackedFlat<Self>, rhs: PackedFlat<Self>, ) -> PackedFlat<Self>

Adds two packed flat vectors lane by lane (XOR).
Source§

fn mul_hardware(lhs: Flat<Self>, rhs: Flat<Self>) -> Flat<Self>

Multiplies two flat elements.
Source§

fn mul_hardware_packed( lhs: PackedFlat<Self>, rhs: PackedFlat<Self>, ) -> PackedFlat<Self>

Multiplies two packed flat vectors lane by lane.
Source§

fn mul_hardware_scalar_packed( lhs: PackedFlat<Self>, rhs: Flat<Self>, ) -> PackedFlat<Self>

Multiplies every lane of lhs by the flat scalar rhs.
Source§

fn tower_bit_from_hardware(value: Flat<Self>, bit_idx: usize) -> u8

Returns bit bit_idx of φ⁻¹(value) without a full conversion; constant time in value. Read more
Source§

impl Mul for Block8

Mul (Galois Field Multiplication)

Source§

type Output = Block8

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Block8> for PackedBlock8

Source§

type Output = PackedBlock8

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Block8) -> Self

Performs the * operation. Read more
Source§

impl MulAssign for Block8

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl PackableField for Block8

Source§

const WIDTH: usize = PACKED_WIDTH_8

How many elements fit in one packed vector.
Source§

type Packed = PackedBlock8

The packed form; operators act lane by lane.
Source§

fn pack(chunk: &[Self]) -> Self::Packed

Packs chunk[..WIDTH] into one value; ignores the rest. Read more
Source§

fn unpack(packed: Self::Packed, output: &mut [Self])

Writes the lanes of packed to output[..WIDTH]; the rest of output is left as it is. Read more
Source§

impl PartialEq for Block8

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Block8

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Block8

Source§

impl Sub for Block8

Source§

type Output = Block8

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for Block8

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl TowerField for Block8

Source§

const BITS: usize = 8

Degree over GF(2): 2^BITS elements.
Source§

const ZERO: Self

The additive identity.
Source§

const ONE: Self

The multiplicative identity.
Source§

const EXTENSION_TAU: Self

τ of the next level, F[X] / (X^2 + X + τ), for Block8 up. Tr(τ) = 1 makes X^2 + X + τ irreducible.
Source§

fn invert(&self) -> Self

Returns self^-1, or 0 for 0. No branch on the value in the default build.
Source§

fn from_uniform_bytes(bytes: &[u8; 32]) -> Self

Builds the element from the first BITS bits of bytes, little-endian; ignores the rest.
Source§

impl Zeroize for Block8

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<F> FlatPromote<F> for F
where F: HardwareField,

Source§

fn promote_flat(val: Flat<F>) -> Flat<F>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.