Skip to main content

Ring

Trait Ring 

Source
pub trait Ring: Additive + Multiplicative {
    // Required method
    fn one() -> Self;

    // Provided method
    fn exp(&self, bits_le: &[u64]) -> Self { ... }
}
Expand description

An instance of a mathematical Ring.

This combines Additive and Multiplicative, and introduces a neutral element for multiplication, Ring::one.

§Properties

Implementations are expected to be commutative rings:

  • Additive and Multiplicative laws both hold,
  • Ring::one satisfies 1 * a = a,
  • multiplication satisfies (a + b) * c = a * c + b * c,
  • Ring::exp satisfies a.exp(&[]) = 1, a.exp(&[1]) = a, and a.exp(m + n) = a.exp(m) * a.exp(n).

Required Methods§

Source

fn one() -> Self

The neutral element for multiplication.

Multiplying by this element does nothing.

Provided Methods§

Source

fn exp(&self, bits_le: &[u64]) -> Self

Exponentiate this number by a positive integer.

To support arbitrary positive integers, we expect to see 64 bit limbs in little endian order.

For example, for a 256 bit integer, we expect a slice of 4 elements, starting with the lowest 64 bits.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Ring for F