Struct dalek_ff_group::FieldElement
source · pub struct FieldElement(/* private fields */);Expand description
A constant-time implementation of the Ed25519 field.
Implementations§
source§impl FieldElement
impl FieldElement
sourcepub fn from_square(value: [u8; 32]) -> FieldElement
pub fn from_square(value: [u8; 32]) -> FieldElement
Interpret the value as a little-endian integer, square it, and reduce it into a FieldElement.
sourcepub fn pow(&self, other: FieldElement) -> FieldElement
pub fn pow(&self, other: FieldElement) -> FieldElement
Perform an exponentiation.
sourcepub fn sqrt_ratio_i(u: FieldElement, v: FieldElement) -> (Choice, FieldElement)
pub fn sqrt_ratio_i(u: FieldElement, v: FieldElement) -> (Choice, FieldElement)
The square root of u/v, as used for Ed25519 point decoding (RFC 8032 5.1.3) and within Ristretto (5.1 Extracting an Inverse Square Root).
The result is only a valid square root if the Choice is true. RFC 8032 simply fails if there isn’t a square root, leaving any return value undefined. Ristretto explicitly returns 0 or sqrt((SQRT_M1 * u) / v).
Trait Implementations§
source§impl<'a> Add<&'a FieldElement> for FieldElement
impl<'a> Add<&'a FieldElement> for FieldElement
§type Output = FieldElement
type Output = FieldElement
+ operator.source§impl Add for FieldElement
impl Add for FieldElement
§type Output = FieldElement
type Output = FieldElement
+ operator.source§impl<'a> AddAssign<&'a FieldElement> for FieldElement
impl<'a> AddAssign<&'a FieldElement> for FieldElement
source§fn add_assign(&mut self, other: &'a FieldElement)
fn add_assign(&mut self, other: &'a FieldElement)
+= 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)
+= operation. Read moresource§impl Clone for FieldElement
impl Clone for FieldElement
source§fn clone(&self) -> FieldElement
fn clone(&self) -> FieldElement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl ConditionallySelectable for FieldElement
impl ConditionallySelectable for FieldElement
source§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
source§impl Field for FieldElement
impl Field for FieldElement
source§fn random(rng: impl RngCore) -> Self
fn random(rng: impl RngCore) -> Self
source§fn invert(&self) -> CtOption<Self>
fn invert(&self) -> CtOption<Self>
source§fn sqrt(&self) -> CtOption<Self>
fn sqrt(&self) -> CtOption<Self>
source§fn sqrt_ratio(u: &FieldElement, v: &FieldElement) -> (Choice, FieldElement)
fn sqrt_ratio(u: &FieldElement, v: &FieldElement) -> (Choice, FieldElement)
source§fn is_zero_vartime(&self) -> bool
fn is_zero_vartime(&self) -> bool
source§impl From<u128> for FieldElement
impl From<u128> for FieldElement
source§fn from(a: u128) -> FieldElement
fn from(a: u128) -> FieldElement
source§impl From<u16> for FieldElement
impl From<u16> for FieldElement
source§fn from(a: u16) -> FieldElement
fn from(a: u16) -> FieldElement
source§impl From<u32> for FieldElement
impl From<u32> for FieldElement
source§fn from(a: u32) -> FieldElement
fn from(a: u32) -> FieldElement
source§impl From<u64> for FieldElement
impl From<u64> for FieldElement
source§fn from(a: u64) -> FieldElement
fn from(a: u64) -> FieldElement
source§impl From<u8> for FieldElement
impl From<u8> for FieldElement
source§fn from(a: u8) -> FieldElement
fn from(a: u8) -> FieldElement
source§impl<'a> Mul<&'a FieldElement> for FieldElement
impl<'a> Mul<&'a FieldElement> for FieldElement
§type Output = FieldElement
type Output = FieldElement
* operator.source§impl Mul for FieldElement
impl Mul for FieldElement
§type Output = FieldElement
type Output = FieldElement
* operator.source§impl<'a> MulAssign<&'a FieldElement> for FieldElement
impl<'a> MulAssign<&'a FieldElement> for FieldElement
source§fn mul_assign(&mut self, other: &'a FieldElement)
fn mul_assign(&mut self, other: &'a FieldElement)
*= 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)
*= operation. Read moresource§impl<'a> Neg for &'a FieldElement
impl<'a> Neg for &'a FieldElement
source§impl Neg for FieldElement
impl Neg for FieldElement
source§impl PartialEq for FieldElement
impl PartialEq for FieldElement
source§fn eq(&self, other: &FieldElement) -> bool
fn eq(&self, other: &FieldElement) -> bool
self and other values to be equal, and is used
by ==.source§impl PrimeField for FieldElement
impl PrimeField for FieldElement
§type Repr = [u8; 32]
type Repr = [u8; 32]
source§const MODULUS: &'static str = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"
const MODULUS: &'static str = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"
source§const CAPACITY: u32 = 254u32
const CAPACITY: u32 = 254u32
source§const MULTIPLICATIVE_GENERATOR: Self = _
const MULTIPLICATIVE_GENERATOR: Self = _
modulus - 1 order. This element must also be
a quadratic nonresidue. Read moresource§const ROOT_OF_UNITY: Self = _
const ROOT_OF_UNITY: Self = _
2^s root of unity. Read moresource§const ROOT_OF_UNITY_INV: Self = _
const ROOT_OF_UNITY_INV: Self = _
Self::ROOT_OF_UNITY.source§fn from_repr(bytes: [u8; 32]) -> CtOption<Self>
fn from_repr(bytes: [u8; 32]) -> CtOption<Self>
source§fn to_repr(&self) -> [u8; 32]
fn to_repr(&self) -> [u8; 32]
source§fn from_str_vartime(s: &str) -> Option<Self>
fn from_str_vartime(s: &str) -> Option<Self>
source§impl PrimeFieldBits for FieldElement
impl PrimeFieldBits for FieldElement
source§fn to_le_bits(&self) -> FieldBits<Self::ReprBits>
fn to_le_bits(&self) -> FieldBits<Self::ReprBits>
source§fn char_le_bits() -> FieldBits<Self::ReprBits>
fn char_le_bits() -> FieldBits<Self::ReprBits>
source§impl<'a> Product<&'a FieldElement> for FieldElement
impl<'a> Product<&'a FieldElement> for FieldElement
source§fn product<I: Iterator<Item = &'a FieldElement>>(iter: I) -> FieldElement
fn product<I: Iterator<Item = &'a FieldElement>>(iter: I) -> FieldElement
Self from the elements by
multiplying the items.source§impl Product for FieldElement
impl Product for FieldElement
source§fn product<I: Iterator<Item = FieldElement>>(iter: I) -> FieldElement
fn product<I: Iterator<Item = FieldElement>>(iter: I) -> FieldElement
Self from the elements by
multiplying the items.source§impl<'a> Sub<&'a FieldElement> for FieldElement
impl<'a> Sub<&'a FieldElement> for FieldElement
§type Output = FieldElement
type Output = FieldElement
- operator.source§impl Sub for FieldElement
impl Sub for FieldElement
§type Output = FieldElement
type Output = FieldElement
- operator.source§impl<'a> SubAssign<&'a FieldElement> for FieldElement
impl<'a> SubAssign<&'a FieldElement> for FieldElement
source§fn sub_assign(&mut self, other: &'a FieldElement)
fn sub_assign(&mut self, other: &'a FieldElement)
-= 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)
-= 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) -> FieldElement
fn sum<I: Iterator<Item = &'a FieldElement>>(iter: I) -> FieldElement
Self from the elements by
“summing up” the items.source§impl Sum for FieldElement
impl Sum for FieldElement
source§fn sum<I: Iterator<Item = FieldElement>>(iter: I) -> FieldElement
fn sum<I: Iterator<Item = FieldElement>>(iter: I) -> FieldElement
Self from the elements by
“summing up” the items.impl Copy for FieldElement
impl Eq for FieldElement
impl StructuralPartialEq 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 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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> ConditionallyNegatable for T
impl<T> ConditionallyNegatable for T
source§fn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes