Struct twenty_first::shared_math::x_field_element::XFieldElement
source · pub struct XFieldElement {
pub coefficients: [BFieldElement; 3],
}
Fields§
§coefficients: [BFieldElement; 3]
Implementations§
source§impl XFieldElement
impl XFieldElement
pub fn shah_polynomial() -> Polynomial<BFieldElement>
pub const fn new(coefficients: [BFieldElement; 3]) -> Self
pub const fn new_u64(coeffs: [u64; 3]) -> Self
pub const fn new_const(element: BFieldElement) -> Self
pub fn unlift(&self) -> Option<BFieldElement>
sourcepub fn sample(digest: &Digest) -> Self
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
pub fn xgcd( x: Polynomial<BFieldElement>, y: Polynomial<BFieldElement> ) -> (Polynomial<BFieldElement>, Polynomial<BFieldElement>, Polynomial<BFieldElement>)
pub fn increment(&mut self, index: usize)
pub fn decrement(&mut self, index: usize)
Trait Implementations§
source§impl Add<BFieldElement> for XFieldElement
impl Add<BFieldElement> for XFieldElement
§type Output = XFieldElement
type Output = XFieldElement
+
operator.source§fn add(self, other: BFieldElement) -> Self
fn add(self, other: BFieldElement) -> Self
+
operation. Read moresource§impl Add<XFieldElement> for BFieldElement
impl Add<XFieldElement> for BFieldElement
The bfe + xfe -> xfe
instance belongs to BFieldElement.
§type Output = XFieldElement
type Output = XFieldElement
+
operator.source§fn add(self, other: XFieldElement) -> XFieldElement
fn add(self, other: XFieldElement) -> XFieldElement
+
operation. Read moresource§impl Add<XFieldElement> for XFieldElement
impl Add<XFieldElement> for XFieldElement
source§impl AddAssign<BFieldElement> for XFieldElement
impl AddAssign<BFieldElement> for XFieldElement
source§fn add_assign(&mut self, rhs: BFieldElement)
fn add_assign(&mut self, rhs: BFieldElement)
+=
operation. Read moresource§impl AddAssign<XFieldElement> for XFieldElement
impl AddAssign<XFieldElement> for XFieldElement
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl BFieldCodec for XFieldElement
impl BFieldCodec for XFieldElement
source§impl Clone for XFieldElement
impl Clone for XFieldElement
source§fn clone(&self) -> XFieldElement
fn clone(&self) -> XFieldElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl CyclicGroupGenerator for XFieldElement
impl CyclicGroupGenerator for XFieldElement
source§impl Debug for XFieldElement
impl Debug for XFieldElement
source§impl<'de> Deserialize<'de> for XFieldElement
impl<'de> Deserialize<'de> for XFieldElement
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Display for XFieldElement
impl Display for XFieldElement
source§impl Distribution<XFieldElement> for Standard
impl Distribution<XFieldElement> for Standard
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> XFieldElement
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> XFieldElement
T
, using rng
as the source of randomness.source§impl Div<XFieldElement> for XFieldElement
impl Div<XFieldElement> for XFieldElement
source§impl FiniteField for XFieldElement
impl FiniteField for XFieldElement
source§impl From<BFieldElement> for XFieldElement
impl From<BFieldElement> for XFieldElement
source§fn from(bfe: BFieldElement) -> Self
fn from(bfe: BFieldElement) -> Self
source§impl From<Polynomial<BFieldElement>> for XFieldElement
impl From<Polynomial<BFieldElement>> for XFieldElement
source§fn from(poly: Polynomial<BFieldElement>) -> Self
fn from(poly: Polynomial<BFieldElement>) -> Self
source§impl From<XFieldElement> for Digest
impl From<XFieldElement> for Digest
source§fn from(xfe: XFieldElement) -> Self
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
MerkleTree
s directly from XFieldElement
s.
source§impl From<XFieldElement> for Polynomial<BFieldElement>
impl From<XFieldElement> for Polynomial<BFieldElement>
source§fn from(item: XFieldElement) -> Self
fn from(item: XFieldElement) -> Self
source§impl From<u32> for XFieldElement
impl From<u32> for XFieldElement
source§impl FromVecu8 for XFieldElement
impl FromVecu8 for XFieldElement
fn from_vecu8(bytes: Vec<u8>) -> Self
source§impl Hash for XFieldElement
impl Hash for XFieldElement
source§impl Inverse for XFieldElement
impl Inverse for XFieldElement
source§impl ModPowU32 for XFieldElement
impl ModPowU32 for XFieldElement
fn mod_pow_u32(&self, exp: u32) -> Self
source§impl ModPowU64 for XFieldElement
impl ModPowU64 for XFieldElement
fn mod_pow_u64(&self, exponent: u64) -> Self
source§impl Mul<BFieldElement> for XFieldElement
impl Mul<BFieldElement> for XFieldElement
XField * BField means scalar multiplication of the BFieldElement onto each coefficient of the XField.
§type Output = XFieldElement
type Output = XFieldElement
*
operator.source§fn mul(self, other: BFieldElement) -> Self
fn mul(self, other: BFieldElement) -> Self
*
operation. Read moresource§impl Mul<XFieldElement> for BFieldElement
impl Mul<XFieldElement> for BFieldElement
§type Output = XFieldElement
type Output = XFieldElement
*
operator.source§fn mul(self, other: XFieldElement) -> XFieldElement
fn mul(self, other: XFieldElement) -> XFieldElement
*
operation. Read moresource§impl Mul<XFieldElement> for XFieldElement
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)
source§impl MulAssign<BFieldElement> for XFieldElement
impl MulAssign<BFieldElement> for XFieldElement
source§fn mul_assign(&mut self, rhs: BFieldElement)
fn mul_assign(&mut self, rhs: BFieldElement)
*=
operation. Read moresource§impl MulAssign<XFieldElement> for XFieldElement
impl MulAssign<XFieldElement> for XFieldElement
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moresource§impl Neg for XFieldElement
impl Neg for XFieldElement
source§impl New for XFieldElement
impl New for XFieldElement
fn new_from_usize(&self, value: usize) -> Self
source§impl One for XFieldElement
impl One for XFieldElement
source§impl PartialEq<XFieldElement> for XFieldElement
impl PartialEq<XFieldElement> for XFieldElement
source§fn eq(&self, other: &XFieldElement) -> bool
fn eq(&self, other: &XFieldElement) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PrimitiveRootOfUnity for XFieldElement
impl PrimitiveRootOfUnity for XFieldElement
fn primitive_root_of_unity(n: u64) -> Option<XFieldElement>
source§impl Serialize for XFieldElement
impl Serialize for XFieldElement
source§impl Sub<BFieldElement> for XFieldElement
impl Sub<BFieldElement> for XFieldElement
Subtracting a BFieldElement from an XFieldElement
self - other = self + (-other)
This overloads to Add and Neg
§type Output = XFieldElement
type Output = XFieldElement
-
operator.source§fn sub(self, other: BFieldElement) -> Self
fn sub(self, other: BFieldElement) -> Self
-
operation. Read moresource§impl Sub<XFieldElement> for BFieldElement
impl Sub<XFieldElement> for BFieldElement
§type Output = XFieldElement
type Output = XFieldElement
-
operator.source§fn sub(self, other: XFieldElement) -> XFieldElement
fn sub(self, other: XFieldElement) -> XFieldElement
-
operation. Read moresource§impl Sub<XFieldElement> for XFieldElement
impl Sub<XFieldElement> for XFieldElement
source§impl SubAssign<BFieldElement> for XFieldElement
impl SubAssign<BFieldElement> for XFieldElement
source§fn sub_assign(&mut self, rhs: BFieldElement)
fn sub_assign(&mut self, rhs: BFieldElement)
-=
operation. Read moresource§impl SubAssign<XFieldElement> for XFieldElement
impl SubAssign<XFieldElement> for XFieldElement
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more