Trait lambdaworks_math::field::traits::IsPrimeField

source ·
pub trait IsPrimeField: IsField {
    type RepresentativeType: IsUnsignedInteger;

    // Required methods
    fn representative(a: &Self::BaseType) -> Self::RepresentativeType;
    fn from_hex(hex_string: &str) -> Result<Self::BaseType, CreationError>;
    fn to_hex(a: &Self::BaseType) -> String;
    fn field_bit_size() -> usize;

    // Provided methods
    fn modulus_minus_one() -> Self::RepresentativeType { ... }
    fn legendre_symbol(a: &Self::BaseType) -> LegendreSymbol { ... }
    fn sqrt(a: &Self::BaseType) -> Option<(Self::BaseType, Self::BaseType)> { ... }
}

Required Associated Types§

Required Methods§

source

fn representative(a: &Self::BaseType) -> Self::RepresentativeType

Returns the integer representative in the range [0, p-1], where p the modulus

source

fn from_hex(hex_string: &str) -> Result<Self::BaseType, CreationError>

Creates a BaseType from a Hex String 0x is optional Returns an CreationError::InvalidHexStringif the value is not a hexstring

source

fn to_hex(a: &Self::BaseType) -> String

Creates a hexstring from a FieldElement without 0x.

source

fn field_bit_size() -> usize

Returns the number of bits of the max element of the field, as per field documentation, not internal representation. This is log2(max FE) rounded up

Provided Methods§

source

fn modulus_minus_one() -> Self::RepresentativeType

source

fn legendre_symbol(a: &Self::BaseType) -> LegendreSymbol

source

fn sqrt(a: &Self::BaseType) -> Option<(Self::BaseType, Self::BaseType)>

Returns the two square roots of self if they exist and None otherwise

Object Safety§

This trait is not object safe.

Implementors§