pub struct BaseElement(/* private fields */);
Expand description
Represents a base field element.
Internal values are stored in their canonical form in the range [0, M). The backing type is
u128
.
Implementations§
Trait Implementations§
source§impl Add for BaseElement
impl Add for BaseElement
source§impl AddAssign for BaseElement
impl AddAssign for BaseElement
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl AsBytes for BaseElement
impl AsBytes for BaseElement
source§impl Clone for BaseElement
impl Clone for BaseElement
source§fn clone(&self) -> BaseElement
fn clone(&self) -> BaseElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BaseElement
impl Debug for BaseElement
source§impl Default for BaseElement
impl Default for BaseElement
source§fn default() -> BaseElement
fn default() -> BaseElement
source§impl Deserializable for BaseElement
impl Deserializable for BaseElement
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl Display for BaseElement
impl Display for BaseElement
source§impl Div for BaseElement
impl Div for BaseElement
source§impl DivAssign for BaseElement
impl DivAssign for BaseElement
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moresource§impl ExtensibleField<2> for BaseElement
impl ExtensibleField<2> for BaseElement
Defines a quadratic extension of the base field over an irreducible polynomial x2 - x - 1. Thus, an extension element is defined as α + β * φ, where φ is a root of this polynomial, and α and β are base field elements.
source§fn mul(a: [Self; 2], b: [Self; 2]) -> [Self; 2]
fn mul(a: [Self; 2], b: [Self; 2]) -> [Self; 2]
a
and b
in the field defined by this extension.source§fn mul_base(a: [Self; 2], b: Self) -> [Self; 2]
fn mul_base(a: [Self; 2], b: Self) -> [Self; 2]
a
and b
in the field defined by this extension. b
represents
an element in the base field.source§fn frobenius(x: [Self; 2]) -> [Self; 2]
fn frobenius(x: [Self; 2]) -> [Self; 2]
x
in the field defined by this extension.source§fn square(a: [Self; N]) -> [Self; N]
fn square(a: [Self; N]) -> [Self; N]
a
in the field defined by this extension.source§fn is_supported() -> bool
fn is_supported() -> bool
source§impl ExtensibleField<3> for BaseElement
impl ExtensibleField<3> for BaseElement
Cubic extension for this field is not implemented as quadratic extension already provides sufficient security level.
source§fn mul(_a: [Self; 3], _b: [Self; 3]) -> [Self; 3]
fn mul(_a: [Self; 3], _b: [Self; 3]) -> [Self; 3]
a
and b
in the field defined by this extension.source§fn mul_base(_a: [Self; 3], _b: Self) -> [Self; 3]
fn mul_base(_a: [Self; 3], _b: Self) -> [Self; 3]
a
and b
in the field defined by this extension. b
represents
an element in the base field.source§fn frobenius(_x: [Self; 3]) -> [Self; 3]
fn frobenius(_x: [Self; 3]) -> [Self; 3]
x
in the field defined by this extension.source§fn is_supported() -> bool
fn is_supported() -> bool
source§impl FieldElement for BaseElement
impl FieldElement for BaseElement
source§const EXTENSION_DEGREE: usize = 1usize
const EXTENSION_DEGREE: usize = 1usize
Self::BaseField
. For prime fields,
extension degree should be set to 1.source§const ELEMENT_BYTES: usize = 16usize
const ELEMENT_BYTES: usize = 16usize
source§const IS_CANONICAL: bool = true
const IS_CANONICAL: bool = true
source§type PositiveInteger = u128
type PositiveInteger = u128
Self::BaseField
with no loss of precision.source§type BaseField = BaseElement
type BaseField = BaseElement
BaseField
should be set
to Self
.source§fn inv(self) -> Self
fn inv(self) -> Self
source§fn base_element(&self, i: usize) -> Self::BaseField
fn base_element(&self, i: usize) -> Self::BaseField
i
. Read moresource§fn slice_as_base_elements(elements: &[Self]) -> &[Self::BaseField]
fn slice_as_base_elements(elements: &[Self]) -> &[Self::BaseField]
source§fn slice_from_base_elements(elements: &[Self::BaseField]) -> &[Self]
fn slice_from_base_elements(elements: &[Self::BaseField]) -> &[Self]
source§fn elements_as_bytes(elements: &[Self]) -> &[u8] ⓘ
fn elements_as_bytes(elements: &[Self]) -> &[u8] ⓘ
source§unsafe fn bytes_as_elements(
bytes: &[u8],
) -> Result<&[Self], DeserializationError>
unsafe fn bytes_as_elements( bytes: &[u8], ) -> Result<&[Self], DeserializationError>
source§fn exp(self, power: Self::PositiveInteger) -> Self
fn exp(self, power: Self::PositiveInteger) -> Self
power
parameter.source§fn exp_vartime(self, power: Self::PositiveInteger) -> Self
fn exp_vartime(self, power: Self::PositiveInteger) -> Self
power
parameter.
This function is expressly variable time, to speed-up verifier computations.source§impl From<u16> for BaseElement
impl From<u16> for BaseElement
source§impl From<u32> for BaseElement
impl From<u32> for BaseElement
source§impl From<u64> for BaseElement
impl From<u64> for BaseElement
source§impl From<u8> for BaseElement
impl From<u8> for BaseElement
source§impl Mul for BaseElement
impl Mul for BaseElement
source§impl MulAssign for BaseElement
impl MulAssign for BaseElement
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moresource§impl Neg for BaseElement
impl Neg for BaseElement
source§impl PartialEq for BaseElement
impl PartialEq for BaseElement
source§impl Randomizable for BaseElement
impl Randomizable for BaseElement
source§const VALUE_SIZE: usize = 16usize
const VALUE_SIZE: usize = 16usize
Self
in bytes. Read moresource§fn from_random_bytes(bytes: &[u8]) -> Option<Self>
fn from_random_bytes(bytes: &[u8]) -> Option<Self>
Self
if the set of bytes forms a valid value, otherwise returns None.source§impl Serializable for BaseElement
impl Serializable for BaseElement
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
source§impl StarkField for BaseElement
impl StarkField for BaseElement
source§const MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): <field::f128::BaseElement as field::traits::FieldElement>::PositiveInteger}
const MODULUS: Self::PositiveInteger = {transmute(0xffffffffffffffffffffd30000000001): <field::f128::BaseElement as field::traits::FieldElement>::PositiveInteger}
sage: MODULUS = 2^128 - 45 * 2^40 + 1
sage: GF(MODULUS).is_prime_field()
True
sage: GF(MODULUS).order()
340282366920938463463374557953744961537
source§const TWO_ADICITY: u32 = 40u32
const TWO_ADICITY: u32 = 40u32
sage: is_odd((MODULUS - 1) / 2^40)
True
source§const TWO_ADIC_ROOT_OF_UNITY: Self = _
const TWO_ADIC_ROOT_OF_UNITY: Self = _
sage: k = (MODULUS - 1) / 2^40
sage: GF(MODULUS).primitive_element()^k
23953097886125630542083529559205016746
source§const MODULUS_BITS: u32 = 128u32
const MODULUS_BITS: u32 = 128u32
Self::MODULUS
.source§fn get_modulus_le_bytes() -> Vec<u8>
fn get_modulus_le_bytes() -> Vec<u8>
source§fn as_int(&self) -> Self::PositiveInteger
fn as_int(&self) -> Self::PositiveInteger
source§fn get_root_of_unity(n: u32) -> Self
fn get_root_of_unity(n: u32) -> Self
n
. Read moresource§fn from_bytes_with_padding(bytes: &[u8]) -> Self
fn from_bytes_with_padding(bytes: &[u8]) -> Self
source§impl Sub for BaseElement
impl Sub for BaseElement
source§impl SubAssign for BaseElement
impl SubAssign for BaseElement
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moresource§impl<'a> TryFrom<&'a [u8]> for BaseElement
impl<'a> TryFrom<&'a [u8]> for BaseElement
source§impl TryFrom<u128> for BaseElement
impl TryFrom<u128> for BaseElement
impl Copy for BaseElement
impl Eq for BaseElement
impl StructuralPartialEq for BaseElement
Auto Trait Implementations§
impl Freeze for BaseElement
impl RefUnwindSafe for BaseElement
impl Send for BaseElement
impl Sync for BaseElement
impl Unpin for BaseElement
impl UnwindSafe for BaseElement
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)