pub struct FieldElement(pub(crate) ConstMontyForm<MODULUS, { MODULUS::LIMBS }>);Tuple Fields§
§0: ConstMontyForm<MODULUS, { MODULUS::LIMBS }>Implementations§
Source§impl FieldElement
impl FieldElement
pub const A_PLUS_TWO_OVER_FOUR: Self
pub const DECAF_FACTOR: Self
pub const EDWARDS_D: Self
pub const J: Self
pub const MINUS_ONE: Self
pub const NEG_EDWARDS_D: Self
pub const NEG_FOUR_TIMES_TWISTED_D: Self
pub const ONE: Self
pub const TWO: Self
pub const TWISTED_D: Self
pub const TWO_TIMES_TWISTED_D: Self
pub const Z: Self
pub const ZERO: Self
pub fn is_negative(&self) -> Choice
pub fn is_zero(&self) -> Choice
pub fn square(&self) -> Self
Sourcefn square_n<const N: u32>(&self) -> FieldElement
fn square_n<const N: u32>(&self) -> FieldElement
Squares a field element n times
pub fn is_square(&self) -> Choice
pub fn unchecked_sqrt(&self) -> FieldElement
pub fn to_bytes(self) -> [u8; 56]
pub fn to_bytes_extended(self) -> [u8; 57]
pub fn from_bytes(bytes: &[u8; 56]) -> Self
pub fn from_bytes_extended(bytes: &[u8; 57]) -> Self
pub fn from_repr(bytes: &[u8; 56]) -> CtOption<Self>
pub fn double(&self) -> Self
Sourcepub(crate) fn inverse_square_root(&self) -> (FieldElement, Choice)
pub(crate) fn inverse_square_root(&self) -> (FieldElement, Choice)
Computes the inverse square root of a field element Returns the result and a boolean to indicate whether self was a Quadratic residue
Sourcepub(crate) fn sqrt_ratio(
u: &FieldElement,
v: &FieldElement,
) -> (FieldElement, Choice)
pub(crate) fn sqrt_ratio( u: &FieldElement, v: &FieldElement, ) -> (FieldElement, Choice)
Computes the square root ratio of two elements
pub(crate) fn div_by_2(&self) -> FieldElement
pub(crate) fn map_to_curve_elligator2(&self) -> AffinePoint
pub(crate) fn map_to_curve_decaf448(&self) -> TwistedExtendedPoint
Trait Implementations§
Source§impl Add<&FieldElement> for &FieldElement
impl Add<&FieldElement> for &FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
+ operator.Source§fn add(self, other: &FieldElement) -> FieldElement
fn add(self, other: &FieldElement) -> FieldElement
Performs the
+ operation. Read moreSource§impl<'b> Add<&'b FieldElement> for FieldElement
impl<'b> Add<&'b FieldElement> for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
+ operator.Source§fn add(self, rhs: &'b FieldElement) -> FieldElement
fn add(self, rhs: &'b FieldElement) -> FieldElement
Performs the
+ operation. Read moreSource§impl<'a> Add<FieldElement> for &'a FieldElement
impl<'a> Add<FieldElement> for &'a FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
+ operator.Source§fn add(self, rhs: FieldElement) -> FieldElement
fn add(self, rhs: FieldElement) -> FieldElement
Performs the
+ operation. Read moreSource§impl Add for FieldElement
impl Add for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
+ operator.Source§fn add(self, rhs: FieldElement) -> FieldElement
fn add(self, rhs: FieldElement) -> FieldElement
Performs the
+ operation. Read moreSource§impl AddAssign<&FieldElement> for FieldElement
impl AddAssign<&FieldElement> for FieldElement
Source§fn add_assign(&mut self, other: &FieldElement)
fn add_assign(&mut self, other: &FieldElement)
Performs the
+= operation. Read moreSource§impl AddAssign for FieldElement
impl AddAssign for FieldElement
Source§fn add_assign(&mut self, other: FieldElement)
fn add_assign(&mut self, other: FieldElement)
Performs the
+= operation. Read moreSource§impl BatchInvert for FieldElement
impl BatchInvert for FieldElement
Source§fn batch_invert_in_place(
elements: &mut [Self],
scratch_space: &mut [Self],
) -> Self
fn batch_invert_in_place( elements: &mut [Self], scratch_space: &mut [Self], ) -> Self
Inverts each field element in
elements (when non-zero). Zero-valued elements are
left as zero. Read moreSource§fn batch_invert_in_place_vartime(
elements: &mut [Self],
scratch_space: &mut [Self],
) -> Self
fn batch_invert_in_place_vartime( elements: &mut [Self], scratch_space: &mut [Self], ) -> Self
Variable-time batch inversion. Read more
Source§impl Clone for FieldElement
impl Clone for FieldElement
Source§fn clone(&self) -> FieldElement
fn clone(&self) -> FieldElement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ConditionallySelectable for FieldElement
impl ConditionallySelectable for FieldElement
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
Conditionally swap
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl ConstantTimeEq for FieldElement
impl ConstantTimeEq for FieldElement
Source§impl Debug for FieldElement
impl Debug for FieldElement
Source§impl Default for FieldElement
impl Default for FieldElement
Source§fn default() -> FieldElement
fn default() -> FieldElement
Returns the “default value” for a type. Read more
Source§impl Display for FieldElement
impl Display for FieldElement
Source§impl Field for FieldElement
impl Field for FieldElement
Source§fn try_random<R: TryRng + ?Sized>(rng: &mut R) -> Result<Self, R::Error>
fn try_random<R: TryRng + ?Sized>(rng: &mut R) -> Result<Self, R::Error>
Returns an element chosen uniformly at random using a user-provided fallible RNG. Read more
Source§fn invert(&self) -> CtOption<Self>
fn invert(&self) -> CtOption<Self>
Computes the multiplicative inverse of this element,
failing if the element is zero.
Source§fn sqrt(&self) -> CtOption<Self>
fn sqrt(&self) -> CtOption<Self>
Returns the square root of the field element, if it is
quadratic residue. Read more
Source§fn sqrt_ratio(num: &Self, div: &Self) -> (Choice, Self)
fn sqrt_ratio(num: &Self, div: &Self) -> (Choice, Self)
Computes: Read more
Source§fn random<R>(rng: &mut R) -> Self
fn random<R>(rng: &mut R) -> Self
Returns an element chosen uniformly at random using a user-provided infallible RNG. Read more
Source§fn is_zero_vartime(&self) -> bool
fn is_zero_vartime(&self) -> bool
Returns true iff this element is zero. Read more
Source§impl LowerHex for FieldElement
impl LowerHex for FieldElement
Source§impl Mul<&FieldElement> for &FieldElement
impl Mul<&FieldElement> for &FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
* operator.Source§fn mul(self, other: &FieldElement) -> FieldElement
fn mul(self, other: &FieldElement) -> FieldElement
Performs the
* operation. Read moreSource§impl<'b> Mul<&'b FieldElement> for FieldElement
impl<'b> Mul<&'b FieldElement> for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
* operator.Source§fn mul(self, rhs: &'b FieldElement) -> FieldElement
fn mul(self, rhs: &'b FieldElement) -> FieldElement
Performs the
* operation. Read moreSource§impl<'a> Mul<FieldElement> for &'a FieldElement
impl<'a> Mul<FieldElement> for &'a FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
* operator.Source§fn mul(self, rhs: FieldElement) -> FieldElement
fn mul(self, rhs: FieldElement) -> FieldElement
Performs the
* operation. Read moreSource§impl Mul for FieldElement
impl Mul for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
* operator.Source§fn mul(self, rhs: FieldElement) -> FieldElement
fn mul(self, rhs: FieldElement) -> FieldElement
Performs the
* operation. Read moreSource§impl MulAssign<&FieldElement> for FieldElement
impl MulAssign<&FieldElement> for FieldElement
Source§fn mul_assign(&mut self, other: &FieldElement)
fn mul_assign(&mut self, other: &FieldElement)
Performs the
*= operation. Read moreSource§impl MulAssign for FieldElement
impl MulAssign for FieldElement
Source§fn mul_assign(&mut self, other: FieldElement)
fn mul_assign(&mut self, other: FieldElement)
Performs the
*= operation. Read moreSource§impl Neg for &FieldElement
impl Neg for &FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn neg(self) -> FieldElement
fn neg(self) -> FieldElement
Performs the unary
- operation. Read moreSource§impl Neg for FieldElement
impl Neg for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn neg(self) -> FieldElement
fn neg(self) -> FieldElement
Performs the unary
- operation. Read moreSource§impl PartialEq for FieldElement
impl PartialEq for FieldElement
Source§impl<'a> Product<&'a FieldElement> for FieldElement
impl<'a> Product<&'a FieldElement> for FieldElement
Source§impl Product for FieldElement
impl Product for FieldElement
Source§impl Reduce<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>, B1>, B0>, B0>>> for FieldElement
impl Reduce<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>, B1>, B0>, B0>>> for FieldElement
Source§impl Reduce<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B0>, B0>, B0>>> for FieldElement
impl Reduce<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B0>, B0>, B0>>> for FieldElement
Source§impl Sub<&FieldElement> for &FieldElement
impl Sub<&FieldElement> for &FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn sub(self, other: &FieldElement) -> FieldElement
fn sub(self, other: &FieldElement) -> FieldElement
Performs the
- operation. Read moreSource§impl<'b> Sub<&'b FieldElement> for FieldElement
impl<'b> Sub<&'b FieldElement> for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn sub(self, rhs: &'b FieldElement) -> FieldElement
fn sub(self, rhs: &'b FieldElement) -> FieldElement
Performs the
- operation. Read moreSource§impl<'a> Sub<FieldElement> for &'a FieldElement
impl<'a> Sub<FieldElement> for &'a FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn sub(self, rhs: FieldElement) -> FieldElement
fn sub(self, rhs: FieldElement) -> FieldElement
Performs the
- operation. Read moreSource§impl Sub for FieldElement
impl Sub for FieldElement
Source§type Output = FieldElement
type Output = FieldElement
The resulting type after applying the
- operator.Source§fn sub(self, rhs: FieldElement) -> FieldElement
fn sub(self, rhs: FieldElement) -> FieldElement
Performs the
- operation. Read moreSource§impl SubAssign<&FieldElement> for FieldElement
impl SubAssign<&FieldElement> for FieldElement
Source§fn sub_assign(&mut self, other: &FieldElement)
fn sub_assign(&mut self, other: &FieldElement)
Performs the
-= operation. Read moreSource§impl SubAssign for FieldElement
impl SubAssign for FieldElement
Source§fn sub_assign(&mut self, other: FieldElement)
fn sub_assign(&mut self, other: FieldElement)
Performs the
-= operation. Read moreSource§impl<'a> Sum<&'a FieldElement> for FieldElement
impl<'a> Sum<&'a FieldElement> for FieldElement
Source§fn sum<I: Iterator<Item = &'a FieldElement>>(iter: I) -> Self
fn sum<I: Iterator<Item = &'a FieldElement>>(iter: I) -> Self
Takes an iterator and generates
Self from the elements by “summing up”
the items.Source§impl Sum for FieldElement
impl Sum for FieldElement
Source§impl UpperHex for FieldElement
impl UpperHex for FieldElement
impl Copy for FieldElement
impl DefaultIsZeroes for FieldElement
impl Eq for FieldElement
Auto Trait Implementations§
impl Freeze for FieldElement
impl RefUnwindSafe for FieldElement
impl Send for FieldElement
impl Sync for FieldElement
impl Unpin for FieldElement
impl UnsafeUnpin for FieldElement
impl UnwindSafe for FieldElement
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
Mutably borrows from an owned value. Read more