pub struct Block(/* private fields */);
Expand description
A 128-bit block. Uses SIMD operations where available.
Implementations§
Source§impl Block
impl Block
Sourcepub fn clmul(&self, rhs: &Self) -> (Self, Self)
pub fn clmul(&self, rhs: &Self) -> (Self, Self)
Carryless multiplication of two Blocks as polynomials over GF(2).
Returns (low, high) bits.
Sourcepub fn gf_mul(&self, rhs: &Self) -> Self
pub fn gf_mul(&self, rhs: &Self) -> Self
Multiplication over GF(2^128).
Uses the irreducible polynomial `x^128 + x^7 + x^2 + x + 1.
Sourcepub fn gf_reduce(low: &Self, high: &Self) -> Self
pub fn gf_reduce(low: &Self, high: &Self) -> Self
Reduce polynomial over GF(2) by x^128 + x^7 + x^2 + x + 1
.
pub fn gf_pow(&self, exp: u64) -> Block
Source§impl Block
impl Block
Sourcepub const MASK_LSB: Self
pub const MASK_LSB: Self
Mask to mask off the LSB of a Block.
let b = Block::ONES;
let masked = b & Block::MASK_LSB;
assert_eq!(masked, Block::ONES << 1)
Sourcepub const fn pack(low: u64, high: u64) -> Self
pub const fn pack(low: u64, high: u64) -> Self
Pack two u64
into a Block. Usable in const context.
In non-const contexts, using Block::from([low, high])
is likely
faster.
Sourcepub fn as_mut_bytes(&mut self) -> &mut [u8; 16]
pub fn as_mut_bytes(&mut self) -> &mut [u8; 16]
Mutable bytes of the block.
Sourcepub fn ro_hash(&self) -> Hash
pub fn ro_hash(&self) -> Hash
Hash the block with a random_oracle
.
Sourcepub fn from_choices(choices: &[Choice]) -> Self
pub fn from_choices(choices: &[Choice]) -> Self
Trait Implementations§
Source§impl BitAndAssign for Block
impl BitAndAssign for Block
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&=
operation. Read moreSource§impl BitOrAssign for Block
impl BitOrAssign for Block
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|=
operation. Read moreSource§impl BitXorAssign for Block
impl BitXorAssign for Block
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moreSource§impl ConditionallySelectable for Block
impl ConditionallySelectable for Block
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
Conditionally swap
self
and other
if choice == 1
; otherwise,
reassign both unto themselves. Read moreSource§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 Distribution<Block> for StandardUniform
impl Distribution<Block> for StandardUniform
impl Copy for Block
impl Eq for Block
impl Pod for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.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>
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