# Struct hacspec_lib::prelude::U128

source · [−]`pub struct U128(pub u128);`

## Tuple Fields

`0: u128`

## Implementations

source### impl U128

### impl U128

#### pub fn classify<T>(x: T) -> U128 where

T: Into<u128>,

source#### pub fn declassify(self) -> u128

#### pub fn declassify(self) -> u128

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

#### pub fn zero() -> U128

#### pub fn one() -> U128

#### pub fn ones() -> U128

#### pub fn from_le_bytes(bytes: &[U8]) -> Vec<U128, Global>ⓘNotable traits for Vec<u8, A>`impl<A> Write for Vec<u8, A> where`

A: Allocator,

A: Allocator,

#### pub fn to_le_bytes(ints: &[U128]) -> Vec<U8, Global>ⓘNotable traits for Vec<u8, A>`impl<A> Write for Vec<u8, A> where`

A: Allocator,

A: Allocator,

#### pub fn from_be_bytes(bytes: &[U8]) -> Vec<U128, Global>ⓘNotable traits for Vec<u8, A>`impl<A> Write for Vec<u8, A> where`

A: Allocator,

A: Allocator,

#### pub fn to_be_bytes(ints: &[U128]) -> Vec<U8, Global>ⓘNotable traits for Vec<u8, A>`impl<A> Write for Vec<u8, A> where`

A: Allocator,

A: Allocator,

#### pub fn max_value() -> U128

source### impl U128

### impl U128

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

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

source### impl U128

### impl U128

source#### pub fn comp_eq(self, rhs: U128) -> U128

#### pub fn comp_eq(self, rhs: U128) -> U128

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: U128) -> U128

#### pub fn comp_ne(self, rhs: U128) -> U128

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: U128) -> U128

#### pub fn comp_gte(self, rhs: U128) -> U128

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: U128) -> U128

#### pub fn comp_gt(self, rhs: U128) -> U128

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

## Trait Implementations

source### impl AddAssign<U128> for U128

### impl AddAssign<U128> for U128

**Warning:** has wrapping semantics.

source#### fn add_assign(&mut self, rhs: U128)

#### fn add_assign(&mut self, rhs: U128)

Performs the `+=`

operation. Read more

source### impl BitAndAssign<U128> for U128

### impl BitAndAssign<U128> for U128

source#### fn bitand_assign(&mut self, rhs: U128)

#### fn bitand_assign(&mut self, rhs: U128)

Performs the `&=`

operation. Read more

source### impl BitOrAssign<U128> for U128

### impl BitOrAssign<U128> for U128

source#### fn bitor_assign(&mut self, rhs: U128)

#### fn bitor_assign(&mut self, rhs: U128)

Performs the `|=`

operation. Read more

source### impl BitXorAssign<U128> for U128

### impl BitXorAssign<U128> for U128

source#### fn bitxor_assign(&mut self, rhs: U128)

#### fn bitxor_assign(&mut self, rhs: U128)

Performs the `^=`

operation. Read more

source### impl Integer for U128

### impl Integer for U128

source#### fn ZERO() -> Self

#### fn ZERO() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn ONE() -> Self

#### fn ONE() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn TWO() -> Self

#### fn TWO() -> Self

*This function is within the hacspec subset of Rust: its signature and body use only hacspec constructs and
call functions whose signatures are in hacspec.*

source#### fn from_literal(val: u128) -> Self

#### fn from_literal(val: u128) -> Self

source#### fn from_hex_string(s: &String) -> Self

#### fn from_hex_string(s: &String) -> Self

*This function can be called from hacspec programs but its body features Rust constructs that are not part of hacspec*

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

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

`i`

of this integer.

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

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

`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

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

`pos`

of this integer to bit `yi`

of integer `y`

.

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

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

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

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

#### const NUM_BITS: usize = 128usize

source### impl ModNumeric for U128

### impl ModNumeric for U128

source#### fn sub_mod(self, rhs: Self, n: Self) -> Self

#### fn sub_mod(self, rhs: Self, n: Self) -> Self

source#### fn add_mod(self, rhs: Self, n: Self) -> Self

#### fn add_mod(self, rhs: Self, n: Self) -> Self

`(self + rhs) % n`

source#### fn mul_mod(self, rhs: Self, n: Self) -> Self

#### fn mul_mod(self, rhs: Self, n: Self) -> Self

`(self * rhs) % n`

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

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

`(self ^ exp) % n`

TODO: implement

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

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

`self % n`

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

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

`self % n`

that always returns a positive integer

source### impl MulAssign<U128> for U128

### impl MulAssign<U128> for U128

**Warning:** has wrapping semantics.

source#### fn mul_assign(&mut self, rhs: U128)

#### fn mul_assign(&mut self, rhs: U128)

Performs the `*=`

operation. Read more

source### impl Numeric for U128

### impl Numeric for U128

source#### fn max_val() -> Self

#### fn max_val() -> Self

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

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

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

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

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

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

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

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

source#### fn exp(self, exp: u32) -> Self

#### 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

#### 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

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

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

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

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

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

**Declassifies**

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

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

**Declassifies**

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

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

**Declassifies**

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

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

**Declassifies**

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

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

**Declassifies**

source#### fn not_equal_bm(self, other: Self) -> Self

#### fn not_equal_bm(self, other: Self) -> Self

source#### fn equal_bm(self, other: Self) -> Self

#### fn equal_bm(self, other: Self) -> Self

source#### fn greater_than_bm(self, other: Self) -> Self

#### fn greater_than_bm(self, other: Self) -> Self

source#### fn greater_than_or_equal_bm(self, other: Self) -> Self

#### fn greater_than_or_equal_bm(self, other: Self) -> Self

source#### fn less_than_bm(self, other: Self) -> Self

#### fn less_than_bm(self, other: Self) -> Self

source#### fn less_than_or_equal_bm(self, other: Self) -> Self

#### fn less_than_or_equal_bm(self, other: Self) -> Self

source### impl SecretInteger for U128

### impl SecretInteger for U128

source#### fn classify(x: Self::PublicVersion) -> Self

#### fn classify(x: Self::PublicVersion) -> Self

#### type PublicVersion = u128

source### impl SecretIntegerCopy for U128

### impl SecretIntegerCopy for U128

#### type PublicVersionCopy = u128

#### fn classify(x: Self::PublicVersionCopy) -> Self

source### impl ShlAssign<usize> for U128

### impl ShlAssign<usize> for U128

source#### fn shl_assign(&mut self, rhs: usize)

#### fn shl_assign(&mut self, rhs: usize)

Performs the `<<=`

operation. Read more

source### impl ShrAssign<usize> for U128

### impl ShrAssign<usize> for U128

source#### fn shr_assign(&mut self, rhs: usize)

#### fn shr_assign(&mut self, rhs: usize)

Performs the `>>=`

operation. Read more

source### impl SubAssign<U128> for U128

### impl SubAssign<U128> for U128

**Warning:** has wrapping semantics.

source#### fn sub_assign(&mut self, rhs: U128)

#### fn sub_assign(&mut self, rhs: U128)

Performs the `-=`

operation. Read more

source### impl UnsignedSecretInteger for U128

### impl UnsignedSecretInteger for U128

source#### fn to_le_bytes(self) -> Seq<U8>

#### fn to_le_bytes(self) -> Seq<U8>

source#### fn to_be_bytes(self) -> Seq<U8>

#### fn to_be_bytes(self) -> Seq<U8>

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

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

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

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

### impl Copy for U128

### impl NumericCopy for U128

### impl UnsignedInteger for U128

### impl UnsignedIntegerCopy for U128

### impl UnsignedSecretIntegerCopy for U128

## Auto Trait Implementations

### impl RefUnwindSafe for U128

### impl Send for U128

### impl Sync for U128

### impl Unpin for U128

### impl UnwindSafe for U128

## Blanket Implementations

source### impl<T> BorrowMut<T> for T where

T: ?Sized,

### impl<T> BorrowMut<T> for T where

T: ?Sized,

const: unstable · source#### fn borrow_mut(&mut self) -> &mut T

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

Mutably borrows from an owned value. Read more