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;

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

    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

The additive identity element.

The multiplicative identity element.

Required Methods

Construct an element from the given uniformly chosen random bytes.

Generate a random element.

Provided Methods

Generate a random non-zero element.

Compute self to the power of n.

Constant-Time

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

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.

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

Implementors