hacspec_lib::prelude

Struct U32Word

Source
pub struct U32Word(pub [U8; 4]);
Expand description

Fixed length byte array.

Tuple Fields§

§0: [U8; 4]

Implementations§

Source§

impl U32Word

Source

pub fn new() -> Self

Source

pub fn length() -> usize

Source

pub fn from_array(v: [U8; 4]) -> Self

Source

pub fn from_native_slice(v: &[U8]) -> Self

Source§

impl U32Word

Source

pub fn from_slice<A: SeqTrait<U8>>(input: &A, start: usize, len: usize) -> Self

Source

pub fn concat<A: SeqTrait<U8>>(&self, next: &A) -> Seq<U8>

Source

pub fn from_slice_range<A: SeqTrait<U8>>(input: &A, r: Range<usize>) -> Self

Source

pub fn slice(&self, start_out: usize, len: usize) -> Seq<U8>

Source

pub fn slice_range(&self, r: Range<usize>) -> Seq<U8>

Source

pub fn num_chunks(&self, chunk_size: usize) -> usize

Source

pub fn get_chunk_len(&self, chunk_size: usize, chunk_number: usize) -> usize

Source

pub fn get_chunk( &self, chunk_size: usize, chunk_number: usize, ) -> (usize, Seq<U8>)

Source

pub fn set_chunk<A: SeqTrait<U8>>( self, chunk_size: usize, chunk_number: usize, input: &A, ) -> Self

Source§

impl U32Word

Source

pub fn from_vec(x: Vec<U8>) -> U32Word

Source

pub fn from_seq<T: SeqTrait<U8>>(x: &T) -> U32Word

Source§

impl U32Word

Source

pub fn from_hex(s: &str) -> U32Word

Read hex string to Bytes.

Source§

impl U32Word

Warning: declassifies secret integer types.

Source

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

Source§

impl U32Word

Source

pub fn to_be_bytes(&self) -> Seq<U8>

Source

pub fn to_le_bytes(&self) -> Seq<U8>

Source§

impl U32Word

Source

pub fn from_public_slice(v: &[u8]) -> U32Word

Source

pub fn to_public_array(&self) -> [u8; 4]

Source

pub fn from_public_array(v: [u8; 4]) -> U32Word

Create an array from a regular Rust array.

§Examples
use hacspec_lib::prelude::*;

bytes!(Block, 5);
let b = Block::from_public_array([1, 2, 3, 4, 5]);
Source§

impl U32Word

Source

pub fn to_be_U32s(&self) -> Seq<U32>

Source

pub fn to_le_U32s(&self) -> Seq<U32>

Source

pub fn to_be_U64s(&self) -> Seq<U64>

Source

pub fn to_le_U64s(&self) -> Seq<U64>

Source

pub fn to_U128s_be(&self) -> Seq<U128>

Source

pub fn to_U128s_le(&self) -> Seq<U128>

Source

pub fn to_hex(&self) -> String

Trait Implementations§

Source§

impl Add for U32Word

Warning: wraps on overflow.

Source§

type Output = U32Word

The resulting type after applying the + operator.
Source§

fn add(self, rhs: U32Word) -> U32Word

Performs the + operation. Read more
Source§

impl BitAnd for U32Word

Source§

type Output = U32Word

The resulting type after applying the & operator.
Source§

fn bitand(self, _rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitOr for U32Word

Source§

type Output = U32Word

The resulting type after applying the | operator.
Source§

fn bitor(self, _rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitXor for U32Word

Source§

type Output = U32Word

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl Clone for U32Word

Source§

fn clone(&self) -> U32Word

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for U32Word

Warning: declassifies secret integer types.

Source§

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

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

impl Default for U32Word

Source§

fn default() -> Self

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

impl Index<RangeFull> for U32Word

Source§

type Output = [U8]

The returned type after indexing.
Source§

fn index(&self, r: RangeFull) -> &[U8]

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<i32> for U32Word

Source§

type Output = U8

The returned type after indexing.
Source§

fn index(&self, i: i32) -> &U8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<u32> for U32Word

Source§

type Output = U8

The returned type after indexing.
Source§

fn index(&self, i: u32) -> &U8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<u8> for U32Word

Source§

type Output = U8

The returned type after indexing.
Source§

fn index(&self, i: u8) -> &U8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for U32Word

Source§

type Output = U8

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &U8

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<i32> for U32Word

Source§

fn index_mut(&mut self, i: i32) -> &mut U8

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<u32> for U32Word

Source§

fn index_mut(&mut self, i: u32) -> &mut U8

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<u8> for U32Word

Source§

fn index_mut(&mut self, i: u8) -> &mut U8

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for U32Word

Source§

fn index_mut(&mut self, i: usize) -> &mut U8

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl ModNumeric for U32Word

Source§

fn sub_mod(self, _rhs: Self, _n: Self) -> Self

(self - rhs) % n.

Source§

fn add_mod(self, _rhs: Self, _n: Self) -> Self

(self + rhs) % n

Source§

fn mul_mod(self, _rhs: Self, _n: Self) -> Self

(self * rhs) % n

Source§

fn pow_mod(self, _exp: Self, _n: Self) -> Self

(self ^ exp) % n

Source§

fn modulo(self, _n: Self) -> Self

self % n

Source§

fn absolute(self) -> Self

|self| (coefficient-wise)

Source§

fn signed_modulo(self, _n: Self) -> Self

self % n that always returns a positive integer
Source§

impl Mul for U32Word

Warning: wraps on overflow.

Source§

type Output = U32Word

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: U32Word) -> U32Word

Performs the * operation. Read more
Source§

impl Not for U32Word

Source§

type Output = U32Word

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Numeric for U32Word

Source§

fn max_val() -> Self

Return largest value that can be represented.

Source§

fn exp(self, _exp: u32) -> Self

self ^ exp where exp is a u32.

Source§

fn pow_self(self, _exp: Self) -> Self

self ^ exp where exp is a Self.

Source§

fn divide(self, _rhs: Self) -> Self

Division.

Source§

fn inv(self, _n: Self) -> Self

Invert self modulo n.

Source§

fn wrap_add(self, rhs: Self) -> Self

Source§

fn wrap_sub(self, rhs: Self) -> Self

Source§

fn wrap_mul(self, rhs: Self) -> Self

Source§

fn wrap_div(self, _rhs: Self) -> Self

Source§

fn equal(self, other: Self) -> bool

Source§

fn greater_than(self, _other: Self) -> bool

Source§

fn greater_than_or_equal(self, _other: Self) -> bool

Source§

fn less_than(self, _other: Self) -> bool

Source§

fn less_than_or_equal(self, _other: Self) -> bool

Source§

fn not_equal_bm(self, _other: Self) -> Self

Source§

fn equal_bm(self, _other: Self) -> Self

Source§

fn greater_than_bm(self, _other: Self) -> Self

Source§

fn greater_than_or_equal_bm(self, _other: Self) -> Self

Source§

fn less_than_bm(self, _other: Self) -> Self

Source§

fn less_than_or_equal_bm(self, _other: Self) -> Self

Source§

impl Rem for U32Word

Warning: panics on division by 0.

Source§

type Output = U32Word

The resulting type after applying the % operator.
Source§

fn rem(self, _rhs: U32Word) -> U32Word

Performs the % operation. Read more
Source§

impl SeqTrait<U8> for U32Word

Source§

fn create(x: usize) -> Self

Source§

fn len(&self) -> usize

Source§

fn iter(&self) -> Iter<'_, U8>

Source§

fn update_slice<A: SeqTrait<U8>>( self, start_out: usize, v: &A, start_in: usize, len: usize, ) -> Self

Update this sequence with l elements of v, starting at start_in, at start_out. Read more
Source§

fn update<A: SeqTrait<U8>>(self, start: usize, v: &A) -> Self

Update this sequence with v starting at start. Read more
Source§

fn update_start<A: SeqTrait<U8>>(self, v: &A) -> Self

Source§

impl Shl<usize> for U32Word

Source§

type Output = U32Word

The resulting type after applying the << operator.
Source§

fn shl(self, _rhs: usize) -> Self::Output

Performs the << operation. Read more
Source§

impl Shr<usize> for U32Word

Source§

type Output = U32Word

The resulting type after applying the >> operator.
Source§

fn shr(self, _rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl Sub for U32Word

Warning: wraps on underflow.

Source§

type Output = U32Word

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: U32Word) -> U32Word

Performs the - operation. Read more
Source§

impl Copy for U32Word

Source§

impl NumericCopy for U32Word

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.