hacspec_lib::prelude

Struct U8

Source
pub struct U8(pub u8);

Tuple Fields§

§0: u8

Implementations§

Source§

impl U8

Source

pub fn classify<T>(x: T) -> U8
where T: Into<u8>,

Source

pub fn declassify(self) -> u8

Warning: use with caution, breaks the constant-time guarantee.

Source

pub fn zero() -> U8

Source

pub fn one() -> U8

Source

pub fn ones() -> U8

Source

pub fn from_le_bytes(bytes: &[U8]) -> Vec<U8>

Source

pub fn to_le_bytes(ints: &[U8]) -> Vec<U8>

Source

pub fn from_be_bytes(bytes: &[U8]) -> Vec<U8>

Source

pub fn to_be_bytes(ints: &[U8]) -> Vec<U8>

Source

pub fn max_value() -> U8

Source§

impl U8

Source

pub fn checked_add(self, rhs: U8) -> U8

Warning: panics when overflow.

Source§

impl U8

Source

pub fn checked_sub(self, rhs: U8) -> U8

Warning: panics when overflow.

Source§

impl U8

Source

pub fn checked_mul(self, rhs: U8) -> U8

Warning: panics when overflow.

Source§

impl U8

Source

pub fn rotate_left(self, rotval: usize) -> U8

Source

pub fn rotate_right(self, rotval: usize) -> U8

Source§

impl U8

§Constant-time comparison operators

Source

pub fn comp_eq(self, rhs: U8) -> U8

Produces a new integer which is all ones if the two arguments are equal and all zeroes otherwise. With inspiration from Wireguard.

Source

pub fn comp_ne(self, rhs: U8) -> U8

Produces a new integer which is all ones if the first argument is different from the second argument, and all zeroes otherwise.

Source

pub fn comp_gte(self, rhs: U8) -> U8

Produces a new integer which is all ones if the first argument is greater than or equal to the second argument, and all zeroes otherwise. With inspiration from WireGuard.

Source

pub fn comp_gt(self, rhs: U8) -> U8

Produces a new integer which is all ones if the first argument is strictly greater than the second argument, and all zeroes otherwise.

Source

pub fn comp_lte(self, rhs: U8) -> U8

Produces a new integer which is all ones if the first argument is less than or equal to the second argument, and all zeroes otherwise.

Source

pub fn comp_lt(self, rhs: U8) -> U8

Produces a new integer which is all ones if the first argument is strictly less than the second argument, and all zeroes otherwise.

Trait Implementations§

Source§

impl Add for U8

Warning: has wrapping semantics.

Source§

type Output = U8

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for U8

Warning: has wrapping semantics.

Source§

fn add_assign(&mut self, rhs: U8)

Performs the += operation. Read more
Source§

impl BitAnd for U8

Source§

type Output = U8

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: U8) -> U8

Performs the & operation. Read more
Source§

impl BitAndAssign for U8

Source§

fn bitand_assign(&mut self, rhs: U8)

Performs the &= operation. Read more
Source§

impl BitOr for U8

Source§

type Output = U8

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: U8) -> U8

Performs the | operation. Read more
Source§

impl BitOrAssign for U8

Source§

fn bitor_assign(&mut self, rhs: U8)

Performs the |= operation. Read more
Source§

impl BitXor for U8

Source§

type Output = U8

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: U8) -> U8

Performs the ^ operation. Read more
Source§

impl BitXorAssign for U8

Source§

fn bitxor_assign(&mut self, rhs: U8)

Performs the ^= operation. Read more
Source§

impl Clone for U8

Source§

fn clone(&self) -> U8

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 U8

Source§

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

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

impl Default for U8

Source§

fn default() -> U8

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

impl Display for U8

Source§

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

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

impl From<I8> for U8

Source§

fn from(x: I8) -> U8

Converts to this type from the input type.
Source§

impl From<U128> for U8

Warning: wrapping semantics.

Source§

fn from(x: U128) -> U8

Converts to this type from the input type.
Source§

impl From<U16> for U8

Warning: wrapping semantics.

Source§

fn from(x: U16) -> U8

Converts to this type from the input type.
Source§

impl From<U32> for U8

Warning: wrapping semantics.

Source§

fn from(x: U32) -> U8

Converts to this type from the input type.
Source§

impl From<U64> for U8

Warning: wrapping semantics.

Source§

fn from(x: U64) -> U8

Converts to this type from the input type.
Source§

impl From<U8> for I8

Warning: wrapping semantics.

Source§

fn from(x: U8) -> I8

Converts to this type from the input type.
Source§

impl From<U8> for U128

Source§

fn from(x: U8) -> U128

Converts to this type from the input type.
Source§

impl From<U8> for U16

Source§

fn from(x: U8) -> U16

Converts to this type from the input type.
Source§

impl From<U8> for U32

Source§

fn from(x: U8) -> U32

Converts to this type from the input type.
Source§

impl From<U8> for U64

Source§

fn from(x: U8) -> U64

Converts to this type from the input type.
Source§

impl From<u8> for U8

Source§

fn from(x: u8) -> U8

Converts to this type from the input type.
Source§

impl From<usize> for U8

Source§

fn from(x: usize) -> U8

Converts to this type from the input type.
Source§

impl Integer for U8

Source§

fn get_bit(self, i: usize) -> Self

Get bit i of this integer.

Source§

fn set_bit(self, b: Self, i: usize) -> Self

Set bit i of this integer to b and return the result. Bit b has to be 0 or 1.

Source§

fn set(self, pos: usize, y: Self, yi: usize) -> Self

Set bit pos of this integer to bit yi of integer y.

Source§

const NUM_BITS: usize = 8usize

Source§

fn ZERO() -> Self

Source§

fn ONE() -> Self

Source§

fn TWO() -> Self

Source§

fn from_literal(val: u128) -> Self

Get an integer with value val.
Source§

fn from_hex_string(s: &String) -> Self

Read a hex string (starting with 0x) into an Integer.
Source§

fn rotate_left(self, n: usize) -> Self

Source§

fn rotate_right(self, n: usize) -> Self

Source§

impl LowerHex for U8

Source§

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

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

impl ModNumeric for U8

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 TODO: implement

Source§

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

self % n

Source§

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

self % n that always returns a positive integer

Source§

fn absolute(self) -> Self

|self|

Source§

impl Mul for U8

Warning: has wrapping semantics.

Source§

type Output = U8

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign for U8

Warning: has wrapping semantics.

Source§

fn mul_assign(&mut self, rhs: U8)

Performs the *= operation. Read more
Source§

impl Neg for U8

Source§

type Output = U8

The resulting type after applying the - operator.
Source§

fn neg(self) -> U8

Performs the unary - operation. Read more
Source§

impl Not for U8

Source§

type Output = U8

The resulting type after applying the ! operator.
Source§

fn not(self) -> U8

Performs the unary ! operation. Read more
Source§

impl Numeric for U8

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. Note: the exponent exp MUST NOT be secret.

Source§

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

self ^ exp where exp is a Self. Here both, base and exponent, are secret. TODO: implement

Source§

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

Division.

Source§

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

Invert self modulo n. FIXME: make ct

Source§

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

Declassifies

Source§

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

Declassifies

Source§

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

Declassifies

Source§

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

Declassifies

Source§

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

Declassifies

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 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 SecretInteger for U8

Source§

impl SecretIntegerCopy for U8

Source§

impl SeqTrait<U8> for U128Word

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 SeqTrait<U8> for U16Word

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 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 SeqTrait<U8> for U64Word

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 U8

Source§

type Output = U8

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

fn shl(self, rhs: usize) -> U8

Performs the << operation. Read more
Source§

impl ShlAssign<usize> for U8

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl Shr<usize> for U8

Source§

type Output = U8

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

fn shr(self, rhs: usize) -> U8

Performs the >> operation. Read more
Source§

impl ShrAssign<usize> for U8

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl Sub for U8

Warning: has wrapping semantics.

Source§

type Output = U8

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for U8

Warning: has wrapping semantics.

Source§

fn sub_assign(&mut self, rhs: U8)

Performs the -= operation. Read more
Source§

impl UnsignedSecretInteger for U8

Source§

fn to_le_bytes(self) -> Seq<U8>

Source§

fn to_be_bytes(self) -> Seq<U8>

Source§

fn from_le_bytes(x: &Seq<U8>) -> Self

Source§

fn from_be_bytes(x: &Seq<U8>) -> Self

Source§

fn get_byte(self, i: usize) -> Self

Get byte i of this integer.
Source§

impl Copy for U8

Source§

impl NumericCopy for U8

Source§

impl UnsignedInteger for U8

Source§

impl UnsignedIntegerCopy for U8

Source§

impl UnsignedSecretIntegerCopy for U8

Auto Trait Implementations§

§

impl Freeze for U8

§

impl RefUnwindSafe for U8

§

impl Send for U8

§

impl Sync for U8

§

impl Unpin for U8

§

impl UnwindSafe for U8

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.