[][src]Trait ff::PrimeField

pub trait PrimeField: Field + From<u64> {
    type Repr: Default + AsRef<[u8]> + AsMut<[u8]>;
    type ReprBits: BitView + Send + Sync;

    pub const NUM_BITS: u32;
    pub const CAPACITY: u32;
    pub const S: u32;

    pub fn from_repr(_: Self::Repr) -> Option<Self>;
pub fn to_repr(&self) -> Self::Repr;
pub fn to_le_bits(&self) -> FieldBits<Self::ReprBits>;
pub fn is_odd(&self) -> bool;
pub fn char_le_bits() -> FieldBits<Self::ReprBits>;
pub fn multiplicative_generator() -> Self;
pub fn root_of_unity() -> Self; pub fn from_str(s: &str) -> Option<Self> { ... }
pub fn is_even(&self) -> bool { ... } }

This represents an element of a prime field.

Associated Types

type Repr: Default + AsRef<[u8]> + AsMut<[u8]>[src]

The prime field can be converted back and forth into this binary representation.

type ReprBits: BitView + Send + Sync[src]

The backing store for a bit representation of a prime field element.

Loading content...

Associated Constants

pub const NUM_BITS: u32[src]

How many bits are needed to represent an element of this field.

pub const CAPACITY: u32[src]

How many bits of information can be reliably stored in the field element.

This is usually Self::NUM_BITS - 1.

pub const S: u32[src]

An integer s satisfying the equation 2^s * t = modulus - 1 with t odd.

This is the number of leading zero bits in the little-endian bit representation of modulus - 1.

Loading content...

Required methods

pub fn from_repr(_: Self::Repr) -> Option<Self>[src]

Attempts to convert a byte representation of a field element into an element of this prime field, failing if the input is not canonical (is not smaller than the field's modulus).

The byte representation is interpreted with the same endianness as elements returned by PrimeField::to_repr.

pub fn to_repr(&self) -> Self::Repr[src]

Converts an element of the prime field into the standard byte representation for this field.

The endianness of the byte representation is implementation-specific. Generic encodings of field elements should be treated as opaque.

pub fn to_le_bits(&self) -> FieldBits<Self::ReprBits>[src]

Converts an element of the prime field into a little-endian sequence of bits.

pub fn is_odd(&self) -> bool[src]

Returns true iff this element is odd.

pub fn char_le_bits() -> FieldBits<Self::ReprBits>[src]

Returns the bits of the field characteristic (the modulus) in little-endian order.

pub fn multiplicative_generator() -> Self[src]

Returns a fixed multiplicative generator of modulus - 1 order. This element must also be a quadratic nonresidue.

It can be calculated using SageMath as GF(modulus).primitive_element().

Implementations of this method MUST ensure that this is the generator used to derive Self::root_of_unity.

pub fn root_of_unity() -> Self[src]

Returns the 2^s root of unity.

It can be calculated by exponentiating Self::multiplicative_generator by t, where t = (modulus - 1) >> Self::S.

Loading content...

Provided methods

pub fn from_str(s: &str) -> Option<Self>[src]

Interpret a string of numbers as a (congruent) prime field element. Does not accept unnecessary leading zeroes or a blank string.

pub fn is_even(&self) -> bool[src]

Returns true iff this element is even.

Loading content...

Implementors

Loading content...