../../.cargo/katex-header.html

Trait winter_math::StarkField

source ·
pub trait StarkField: FieldElement<BaseField = Self> {
    const MODULUS: Self::PositiveInteger;
    const MODULUS_BITS: u32;
    const GENERATOR: Self;
    const TWO_ADICITY: u32;
    const TWO_ADIC_ROOT_OF_UNITY: Self;

    // Required methods
    fn get_modulus_le_bytes() -> Vec<u8>;
    fn as_int(&self) -> Self::PositiveInteger;

    // Provided methods
    fn get_root_of_unity(n: u32) -> Self { ... }
    fn from_bytes_with_padding(bytes: &[u8]) -> Self { ... }
}
Expand description

Defines an element in a STARK-friendly finite field.

A STARK-friendly field is defined as a prime field with high two-addicity. That is, the the modulus of the field should be a prime number of the form k * 2^n + 1 (a Proth prime), where n is relatively large (e.g., greater than 32).

Required Associated Constants§

source

const MODULUS: Self::PositiveInteger

Prime modulus of the field. Must be of the form k * 2^n + 1 (a Proth prime). This ensures that the field has high 2-adicity.

source

const MODULUS_BITS: u32

The number of bits needed to represents Self::MODULUS.

source

const GENERATOR: Self

A multiplicative generator of the field.

source

const TWO_ADICITY: u32

Let Self::MODULUS = k * 2^n + 1; then, TWO_ADICITY is n.

source

const TWO_ADIC_ROOT_OF_UNITY: Self

Let Self::MODULUS = k * 2^n + 1; then, TWO_ADIC_ROOT_OF_UNITY is 2^n root of unity computed as Self::GENERATOR^k.

Required Methods§

source

fn get_modulus_le_bytes() -> Vec<u8>

Returns byte representation of the field modulus in little-endian byte order.

source

fn as_int(&self) -> Self::PositiveInteger

Returns a canonical integer representation of this field element.

Provided Methods§

source

fn get_root_of_unity(n: u32) -> Self

Returns the root of unity of order 2^n.

§Panics

Panics if the root of unity for the specified order does not exist in this field.

source

fn from_bytes_with_padding(bytes: &[u8]) -> Self

Converts a slice of bytes into a field element. Pads the slice if it is smaller than the number of bytes needed to represent an element.

§Panics

Panics if

  • the length of bytes is greater than the number of bytes needed to encode an element.
  • the value of the bytes is not a valid field element after padding

Object Safety§

This trait is not object safe.

Implementors§

source§

impl StarkField for winter_math::fields::f62::BaseElement

source§

const MODULUS: Self::PositiveInteger = {transmute(0x3fffc88000000001): <field::f62::BaseElement as field::traits::FieldElement>::PositiveInteger}

source§

const MODULUS_BITS: u32 = 62u32

source§

const GENERATOR: Self = _

source§

const TWO_ADICITY: u32 = 39u32

source§

const TWO_ADIC_ROOT_OF_UNITY: Self = _

source§

impl StarkField for winter_math::fields::f64::BaseElement

source§

const MODULUS: Self::PositiveInteger = {transmute(0xffffffff00000001): <field::f64::BaseElement as field::traits::FieldElement>::PositiveInteger}

source§

const MODULUS_BITS: u32 = 64u32

source§

const GENERATOR: Self = _

source§

const TWO_ADICITY: u32 = 32u32

source§

const TWO_ADIC_ROOT_OF_UNITY: Self = _

source§

impl StarkField for winter_math::fields::f128::BaseElement

source§

const MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): <field::f128::BaseElement as field::traits::FieldElement>::PositiveInteger}

source§

const MODULUS_BITS: u32 = 128u32

source§

const GENERATOR: Self = _

source§

const TWO_ADICITY: u32 = 40u32

source§

const TWO_ADIC_ROOT_OF_UNITY: Self = _