Trait hacspec_lib::hacspec_helper::NatMod
source · pub trait NatMod<const LEN: usize> {
const MODULUS: [u8; LEN];
const MODULUS_STR: &'static str;
const ZERO: [u8; LEN];
Show 24 methods
// Required methods
fn new(value: [u8; LEN]) -> Self;
fn value(&self) -> &[u8] ⓘ;
// Provided methods
fn fsub(self, rhs: Self) -> Self
where Self: Sized { ... }
fn fadd(self, rhs: Self) -> Self
where Self: Sized { ... }
fn fmul(self, rhs: Self) -> Self
where Self: Sized { ... }
fn pow(self, rhs: u128) -> Self
where Self: Sized { ... }
fn pow_felem(self, rhs: &Self) -> Self
where Self: Sized { ... }
fn inv(self) -> Self
where Self: Sized { ... }
fn inv0(self) -> Self
where Self: Sized { ... }
fn zero() -> Self
where Self: Sized { ... }
fn one() -> Self
where Self: Sized { ... }
fn two() -> Self
where Self: Sized { ... }
fn bit(&self, bit: u128) -> bool { ... }
fn pow2(x: usize) -> Self
where Self: Sized { ... }
fn neg(self) -> Self
where Self: Sized { ... }
fn from_u128(literal: u128) -> Self
where Self: Sized { ... }
fn from_le_bytes(bytes: &[u8]) -> Self
where Self: Sized { ... }
fn from_be_bytes(bytes: &[u8]) -> Self
where Self: Sized { ... }
fn to_le_bytes(self) -> [u8; LEN]
where Self: Sized { ... }
fn to_be_bytes(self) -> [u8; LEN]
where Self: Sized { ... }
fn to_hex(&self) -> String { ... }
fn from_hex(hex: &str) -> Self
where Self: Sized { ... }
fn pad(bytes: &[u8]) -> [u8; LEN] { ... }
fn from_bigint(x: BigUint) -> Self
where Self: Sized { ... }
}
Required Associated Constants§
Required Methods§
Provided Methods§
sourcefn fsub(self, rhs: Self) -> Selfwhere
Self: Sized,
fn fsub(self, rhs: Self) -> Selfwhere
Self: Sized,
Sub self with rhs
and return the result self - rhs % MODULUS
.
sourcefn fadd(self, rhs: Self) -> Selfwhere
Self: Sized,
fn fadd(self, rhs: Self) -> Selfwhere
Self: Sized,
Add self with rhs
and return the result self + rhs % MODULUS
.
sourcefn fmul(self, rhs: Self) -> Selfwhere
Self: Sized,
fn fmul(self, rhs: Self) -> Selfwhere
Self: Sized,
Multiply self with rhs
and return the result self * rhs % MODULUS
.
fn inv0(self) -> Selfwhere
Self: Sized,
fn bit(&self, bit: u128) -> bool
fn neg(self) -> Selfwhere
Self: Sized,
sourcefn from_u128(literal: u128) -> Selfwhere
Self: Sized,
fn from_u128(literal: u128) -> Selfwhere
Self: Sized,
Create a new [#ident
] from a u128
literal.
sourcefn from_le_bytes(bytes: &[u8]) -> Selfwhere
Self: Sized,
fn from_le_bytes(bytes: &[u8]) -> Selfwhere
Self: Sized,
Create a new [#ident
] from a little endian byte slice.
This computes bytes % MODULUS
sourcefn from_be_bytes(bytes: &[u8]) -> Selfwhere
Self: Sized,
fn from_be_bytes(bytes: &[u8]) -> Selfwhere
Self: Sized,
Create a new [#ident
] from a little endian byte slice.
This computes bytes % MODULUS
fn to_le_bytes(self) -> [u8; LEN]where
Self: Sized,
fn to_be_bytes(self) -> [u8; LEN]where
Self: Sized,
fn pad(bytes: &[u8]) -> [u8; LEN]
fn from_bigint(x: BigUint) -> Selfwhere
Self: Sized,
Object Safety§
This trait is not object safe.