Skip to main content

Fe

Struct Fe 

Source
pub struct Fe(pub [u64; 5]);
Expand description

A field element modulo 2^255 - 19.

Tuple Fields§

§0: [u64; 5]

Implementations§

Source§

impl Fe

Source

pub const ZERO: Fe

The additive identity.

Source

pub const ONE: Fe

The multiplicative identity.

Source

pub const fn from_u64(v: u64) -> Fe

A small integer as a field element.

Source

pub fn add(&self, other: &Fe) -> Fe

Field addition.

Source

pub fn sub(&self, other: &Fe) -> Fe

Field subtraction, via self + 2p - other so limbs stay non-negative.

Source

pub fn neg(&self) -> Fe

Field negation.

Source

pub fn mul(&self, other: &Fe) -> Fe

Field multiplication.

Source

pub fn square(&self) -> Fe

Field squaring.

Source

pub fn square_n(&self, n: usize) -> Fe

Repeated squaring, self^(2^n).

Source

pub fn mul121666(&self) -> Fe

Multiplication by the Montgomery ladder constant a24 = 121666.

Source

pub fn invert(&self) -> Fe

Multiplicative inverse, self^(p-2), with inverse(0) == 0.

Uses the standard addition chain: 254 squarings and 11 multiplications.

Source

pub fn pow22523(&self) -> Fe

self^((p-5)/8), the exponent used to take square roots.

Source

pub fn from_bytes(bytes: &[u8; 32]) -> Fe

Decode 32 little-endian bytes, ignoring the top bit as RFC 7748 requires.

Source

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

Encode as 32 little-endian bytes, fully reduced modulo p.

Source

pub fn cswap(a: &mut Fe, b: &mut Fe, choice: Choice)

Constant-time conditional swap.

Source

pub fn cmov(a: &mut Fe, b: &Fe, choice: Choice)

Constant-time conditional move: a = b when choice is true.

Source

pub fn is_zero(&self) -> Choice

Constant-time test for zero.

Source

pub fn ct_eq(&self, other: &Fe) -> Choice

Constant-time equality.

Source

pub fn is_negative(&self) -> Choice

The least significant bit of the canonical encoding — the “sign” used by Edwards point compression.

Trait Implementations§

Source§

impl Clone for Fe

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Fe

Source§

impl Debug for Fe

Source§

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

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

impl Eq for Fe

Source§

impl PartialEq for Fe

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Fe

Auto Trait Implementations§

§

impl Freeze for Fe

§

impl RefUnwindSafe for Fe

§

impl Send for Fe

§

impl Sync for Fe

§

impl Unpin for Fe

§

impl UnsafeUnpin for Fe

§

impl UnwindSafe for Fe

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.