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§

source

const MODULUS: [u8; LEN]

source

const MODULUS_STR: &'static str

source

const ZERO: [u8; LEN]

Required Methods§

source

fn new(value: [u8; LEN]) -> Self

source

fn value(&self) -> &[u8]

Provided Methods§

source

fn fsub(self, rhs: Self) -> Self
where Self: Sized,

Sub self with rhs and return the result self - rhs % MODULUS.

source

fn fadd(self, rhs: Self) -> Self
where Self: Sized,

Add self with rhs and return the result self + rhs % MODULUS.

source

fn fmul(self, rhs: Self) -> Self
where Self: Sized,

Multiply self with rhs and return the result self * rhs % MODULUS.

source

fn pow(self, rhs: u128) -> Self
where Self: Sized,

self ^ rhs % MODULUS.

source

fn pow_felem(self, rhs: &Self) -> Self
where Self: Sized,

self ^ rhs % MODULUS.

source

fn inv(self) -> Self
where Self: Sized,

Invert self and return the result self ^ -1 % MODULUS.

source

fn inv0(self) -> Self
where Self: Sized,

source

fn zero() -> Self
where Self: Sized,

Zero element

source

fn one() -> Self
where Self: Sized,

One element

source

fn two() -> Self
where Self: Sized,

One element

source

fn bit(&self, bit: u128) -> bool

source

fn pow2(x: usize) -> Self
where Self: Sized,

Returns 2 to the power of the argument

source

fn neg(self) -> Self
where Self: Sized,

source

fn from_u128(literal: u128) -> Self
where Self: Sized,

Create a new [#ident] from a u128 literal.

source

fn from_le_bytes(bytes: &[u8]) -> Self
where Self: Sized,

Create a new [#ident] from a little endian byte slice.

This computes bytes % MODULUS

source

fn from_be_bytes(bytes: &[u8]) -> Self
where Self: Sized,

Create a new [#ident] from a little endian byte slice.

This computes bytes % MODULUS

source

fn to_le_bytes(self) -> [u8; LEN]
where Self: Sized,

source

fn to_be_bytes(self) -> [u8; LEN]
where Self: Sized,

source

fn to_hex(&self) -> String

Get hex string representation of this.

source

fn from_hex(hex: &str) -> Self
where Self: Sized,

New from hex string

source

fn pad(bytes: &[u8]) -> [u8; LEN]

source

fn from_bigint(x: BigUint) -> Self
where Self: Sized,

Object Safety§

This trait is not object safe.

Implementors§