pub struct XFieldElement {
    pub coefficients: [BFieldElement; 3],
}

Fields§

§coefficients: [BFieldElement; 3]

Implementations§

source§

impl XFieldElement

source

pub fn shah_polynomial() -> Polynomial<BFieldElement>

source

pub const fn new(coefficients: [BFieldElement; 3]) -> Self

source

pub const fn new_u64(coeffs: [u64; 3]) -> Self

source

pub const fn new_const(element: BFieldElement) -> Self

source

pub fn unlift(&self) -> Option<BFieldElement>

source

pub fn sample(digest: &Digest) -> Self

Derive a sample XFieldElement from a random Digest.

The specific elements of the digest (element 2, 3 and 4) were chosen because the tasm equivalent of this function can more efficiently pop elements 0 and 1, leading to a more efficient sample_weights() implementation:

https://github.com/Neptune-Crypto/twenty-first/pull/66#discussion_r1049771105

source

pub fn xgcd( x: Polynomial<BFieldElement>, y: Polynomial<BFieldElement> ) -> (Polynomial<BFieldElement>, Polynomial<BFieldElement>, Polynomial<BFieldElement>)

source

pub fn increment(&mut self, index: usize)

source

pub fn decrement(&mut self, index: usize)

Trait Implementations§

source§

impl Add<BFieldElement> for XFieldElement

§

type Output = XFieldElement

The resulting type after applying the + operator.
source§

fn add(self, other: BFieldElement) -> Self

Performs the + operation. Read more
source§

impl Add<XFieldElement> for BFieldElement

The bfe + xfe -> xfe instance belongs to BFieldElement.

§

type Output = XFieldElement

The resulting type after applying the + operator.
source§

fn add(self, other: XFieldElement) -> XFieldElement

Performs the + operation. Read more
source§

impl Add<XFieldElement> for XFieldElement

§

type Output = XFieldElement

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
source§

impl AddAssign<BFieldElement> for XFieldElement

source§

fn add_assign(&mut self, rhs: BFieldElement)

Performs the += operation. Read more
source§

impl AddAssign<XFieldElement> for XFieldElement

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl BFieldCodec for XFieldElement

source§

fn decode(sequence: &[BFieldElement]) -> Result<Box<Self>>

source§

fn encode(&self) -> Vec<BFieldElement>

source§

fn static_length() -> Option<usize>

Returns the length in number of BFieldElements if it is known at compile-time. Otherwise, None.
source§

impl Clone for XFieldElement

source§

fn clone(&self) -> XFieldElement

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 CyclicGroupGenerator for XFieldElement

source§

impl Debug for XFieldElement

source§

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

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

impl<'de> Deserialize<'de> for XFieldElement

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for XFieldElement

source§

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

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

impl Distribution<XFieldElement> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> XFieldElement

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Div<XFieldElement> for XFieldElement

§

type Output = XFieldElement

The resulting type after applying the / operator.
source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
source§

impl Emojihash for XFieldElement

source§

impl FiniteField for XFieldElement

source§

fn batch_inversion(input: Vec<Self>) -> Vec<Self>

Montgomery Batch Inversion
source§

fn square(self) -> Self

source§

impl From<BFieldElement> for XFieldElement

source§

fn from(bfe: BFieldElement) -> Self

Converts to this type from the input type.
source§

impl From<Polynomial<BFieldElement>> for XFieldElement

source§

fn from(poly: Polynomial<BFieldElement>) -> Self

Converts to this type from the input type.
source§

impl From<XFieldElement> for Digest

source§

fn from(xfe: XFieldElement) -> Self

Interpret the XFieldElement as a Digest. No hashing is performed. This interpretation can be useful for the AlgebraicHasher trait and, by extension, allows building MerkleTrees directly from XFieldElements.

source§

impl From<XFieldElement> for Polynomial<BFieldElement>

source§

fn from(item: XFieldElement) -> Self

Converts to this type from the input type.
source§

impl From<u32> for XFieldElement

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl FromVecu8 for XFieldElement

source§

fn from_vecu8(bytes: Vec<u8>) -> Self

source§

impl Hash for XFieldElement

source§

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

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 Inverse for XFieldElement

source§

fn inverse(&self) -> Self

source§

fn inverse_or_zero(&self) -> Self

source§

impl ModPowU32 for XFieldElement

source§

fn mod_pow_u32(&self, exp: u32) -> Self

source§

impl ModPowU64 for XFieldElement

source§

fn mod_pow_u64(&self, exponent: u64) -> Self

source§

impl Mul<BFieldElement> for XFieldElement

XField * BField means scalar multiplication of the BFieldElement onto each coefficient of the XField.

§

type Output = XFieldElement

The resulting type after applying the * operator.
source§

fn mul(self, other: BFieldElement) -> Self

Performs the * operation. Read more
source§

impl Mul<XFieldElement> for BFieldElement

§

type Output = XFieldElement

The resulting type after applying the * operator.
source§

fn mul(self, other: XFieldElement) -> XFieldElement

Performs the * operation. Read more
source§

impl Mul<XFieldElement> for XFieldElement

XField * XField means:

(ax^2 + bx + c) * (dx^2 + ex + f) (mod x^3 - x + 1)

= adx^4 + aex^3 + afx^2

  • bdx^3 + bex^2 + bfx
  • cdx^2 + cex + cf

= adx^4 + (ae + bd)x^3 + (af + be + cd)x^2 + (bf + ce)x + cf (mod x^3 - x + 1)

§

type Output = XFieldElement

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
source§

impl MulAssign<BFieldElement> for XFieldElement

source§

fn mul_assign(&mut self, rhs: BFieldElement)

Performs the *= operation. Read more
source§

impl MulAssign<XFieldElement> for XFieldElement

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Neg for XFieldElement

§

type Output = XFieldElement

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl New for XFieldElement

source§

fn new_from_usize(&self, value: usize) -> Self

source§

impl One for XFieldElement

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl PartialEq<XFieldElement> for XFieldElement

source§

fn eq(&self, other: &XFieldElement) -> 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 PrimitiveRootOfUnity for XFieldElement

source§

impl Serialize for XFieldElement

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<BFieldElement> for XFieldElement

Subtracting a BFieldElement from an XFieldElement

self - other = self + (-other)

This overloads to Add and Neg

§

type Output = XFieldElement

The resulting type after applying the - operator.
source§

fn sub(self, other: BFieldElement) -> Self

Performs the - operation. Read more
source§

impl Sub<XFieldElement> for BFieldElement

§

type Output = XFieldElement

The resulting type after applying the - operator.
source§

fn sub(self, other: XFieldElement) -> XFieldElement

Performs the - operation. Read more
source§

impl Sub<XFieldElement> for XFieldElement

§

type Output = XFieldElement

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
source§

impl SubAssign<BFieldElement> for XFieldElement

source§

fn sub_assign(&mut self, rhs: BFieldElement)

Performs the -= operation. Read more
source§

impl SubAssign<XFieldElement> for XFieldElement

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl Sum<XFieldElement> for XFieldElement

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

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

impl TryFrom<&[BFieldElement]> for XFieldElement

§

type Error = String

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

fn try_from(value: &[BFieldElement]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Digest> for XFieldElement

§

type Error = &'static str

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

fn try_from(digest: Digest) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec<BFieldElement, Global>> for XFieldElement

§

type Error = String

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

fn try_from(value: Vec<BFieldElement>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Zero for XFieldElement

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Copy for XFieldElement

source§

impl Eq for XFieldElement

source§

impl StructuralEq for XFieldElement

source§

impl StructuralPartialEq for XFieldElement

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,