pub struct FieldElement { /* private fields */ }

Implementations§

source§

impl FieldElement

source

pub const ZERO: FieldElement = _

FieldElement constant that’s equal to 0

source

pub const ONE: FieldElement = _

FieldElement constant that’s equal to 1

source

pub const TWO: FieldElement = _

FieldElement constant that’s equal to 2

source

pub const THREE: FieldElement = _

FieldElement constant that’s equal to 3

source

pub const MAX: FieldElement = _

Maximum value of FieldElement. Equals to 2^251 + 17 * 2^192.

source

pub const fn from_mont(data: [u64; 4]) -> FieldElement

Create a new FieldElement from its Montgomery representation

source

pub fn from_dec_str(value: &str) -> Result<FieldElement, FromStrError>

source

pub fn from_hex_be(value: &str) -> Result<FieldElement, FromStrError>

source

pub fn from_bytes_be( bytes: &[u8; 32] ) -> Result<FieldElement, FromByteArrayError>

Attempts to convert a big-endian byte representation of a field element into an element of this prime field. Returns error if the input is not canonical (is not smaller than the field’s modulus).

§Arguments
  • bytes: The byte array in big endian format
source

pub fn from_byte_slice_be( bytes: &[u8] ) -> Result<FieldElement, FromByteSliceError>

Same as from_bytes_be except this function takes a slice.

source

pub fn to_bits_le(self) -> [bool; 256]

Transforms FieldElement into little endian bit representation.

source

pub fn to_bytes_be(&self) -> [u8; 32]

Convert the field element into a big-endian byte representation

source

pub const fn into_mont(self) -> [u64; 4]

Transforms FieldElement into its Montgomery representation

source

pub fn invert(&self) -> Option<FieldElement>

source

pub fn sqrt(&self) -> Option<FieldElement>

source

pub fn double(&self) -> FieldElement

source

pub fn floor_div(&self, rhs: FieldElement) -> FieldElement

Performs a floor division. It’s not implemented as the Div trait on purpose to distinguish from the “felt division”.

Trait Implementations§

source§

impl Add for FieldElement

§

type Output = FieldElement

The resulting type after applying the + operator.
source§

fn add(self, rhs: FieldElement) -> <FieldElement as Add>::Output

Performs the + operation. Read more
source§

impl AddAssign for FieldElement

source§

fn add_assign(&mut self, rhs: FieldElement)

Performs the += operation. Read more
source§

impl AsRef<FieldElement> for FieldElement

source§

fn as_ref(&self) -> &FieldElement

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl BitAnd for FieldElement

§

type Output = FieldElement

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: FieldElement) -> <FieldElement as BitAnd>::Output

Performs the & operation. Read more
source§

impl BitOr for FieldElement

§

type Output = FieldElement

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: FieldElement) -> <FieldElement as BitOr>::Output

Performs the | operation. Read more
source§

impl Clone for FieldElement

source§

fn clone(&self) -> FieldElement

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FieldElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for FieldElement

source§

fn default() -> FieldElement

Returns the “default value” for a type. Read more
source§

impl Display for FieldElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl From<u128> for FieldElement

source§

fn from(value: u128) -> FieldElement

Converts to this type from the input type.
source§

impl From<u16> for FieldElement

source§

fn from(value: u16) -> FieldElement

Converts to this type from the input type.
source§

impl From<u32> for FieldElement

source§

fn from(value: u32) -> FieldElement

Converts to this type from the input type.
source§

impl From<u64> for FieldElement

source§

fn from(value: u64) -> FieldElement

Converts to this type from the input type.
source§

impl From<u8> for FieldElement

source§

fn from(value: u8) -> FieldElement

Converts to this type from the input type.
source§

impl From<usize> for FieldElement

source§

fn from(value: usize) -> FieldElement

Converts to this type from the input type.
source§

impl FromStr for FieldElement

§

type Err = FromStrError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<FieldElement, <FieldElement as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for FieldElement

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LowerHex for FieldElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
source§

impl Mul for FieldElement

§

type Output = FieldElement

The resulting type after applying the * operator.
source§

fn mul(self, rhs: FieldElement) -> <FieldElement as Mul>::Output

Performs the * operation. Read more
source§

impl MulAssign for FieldElement

source§

fn mul_assign(&mut self, rhs: FieldElement)

Performs the *= operation. Read more
source§

impl Neg for FieldElement

§

type Output = FieldElement

The resulting type after applying the - operator.
source§

fn neg(self) -> <FieldElement as Neg>::Output

Performs the unary - operation. Read more
source§

impl Ord for FieldElement

source§

fn cmp(&self, other: &FieldElement) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for FieldElement

source§

fn eq(&self, other: &FieldElement) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for FieldElement

source§

fn partial_cmp(&self, other: &FieldElement) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem for FieldElement

§

type Output = FieldElement

The resulting type after applying the % operator.
source§

fn rem(self, rhs: FieldElement) -> <FieldElement as Rem>::Output

Performs the % operation. Read more
source§

impl Sub for FieldElement

§

type Output = FieldElement

The resulting type after applying the - operator.
source§

fn sub(self, rhs: FieldElement) -> <FieldElement as Sub>::Output

Performs the - operation. Read more
source§

impl SubAssign for FieldElement

source§

fn sub_assign(&mut self, rhs: FieldElement)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a FieldElement> for FieldElement

source§

fn sum<I>(iter: I) -> FieldElement
where I: Iterator<Item = &'a FieldElement>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for FieldElement

source§

fn sum<I>(iter: I) -> FieldElement
where I: Iterator<Item = FieldElement>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl UpperHex for FieldElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
source§

impl Copy for FieldElement

source§

impl Eq for FieldElement

source§

impl StructuralPartialEq for FieldElement

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V