pub trait FiniteRing: 'static + Clone + Copy + Send + Sync + Default + Debug + Eq + PartialEq + Hash + Sized + ConstantTimeEq + ConditionallySelectable + AddAssign<Self> + SubAssign<Self> + MulAssign<Self> + Add<Self, Output = Self> + Sub<Self, Output = Self> + Mul<Self, Output = Self> + Neg<Output = Self> + Sum + Product + Zero + One + CanonicalSerialize {
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn from_uniform_bytes(x: &[u8; 16]) -> Self;
    fn random<R: Rng + ?Sized>(rng: &mut R) -> Self;

    // Provided methods
    fn random_nonzero<R: Rng + ?Sized>(rng: &mut R) -> Self { ... }
    fn pow(&self, n: u128) -> Self { ... }
    fn pow_bounded(&self, n: u128, bound: u16) -> Self { ... }
    fn pow_var_time(&self, n: u128) -> Self { ... }
}
Expand description

Types that implement this trait are finite rings.

Required Associated Constants§

source

const ZERO: Self

The additive identity element.

source

const ONE: Self

The multiplicative identity element.

Required Methods§

source

fn from_uniform_bytes(x: &[u8; 16]) -> Self

Construct an element from the given uniformly chosen random bytes.

source

fn random<R: Rng + ?Sized>(rng: &mut R) -> Self

Generate a random element.

Provided Methods§

source

fn random_nonzero<R: Rng + ?Sized>(rng: &mut R) -> Self

Generate a random non-zero element.

source

fn pow(&self, n: u128) -> Self

Compute self to the power of n.

§Constant-Time

This function will execute in constant-time, regardless of n’s value.

source

fn pow_bounded(&self, n: u128, bound: u16) -> Self

Compute self to the power of n, where n is guaranteed to be <= 2^bound.

§Constant-Time

This function is constant time in n, but not constant time in bound.

source

fn pow_var_time(&self, n: u128) -> Self

Compute self to the power of n, in non-constant time.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl FiniteRing for F2

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F40b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F45b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F56b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F61p

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F63b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F64b

source§

const ZERO: Self = _

source§

const ONE: Self = _

source§

impl FiniteRing for F128b

source§

const ZERO: Self = _

source§

const ONE: Self = _