Struct curve25519_dalek::backend::serial::u64::field::FieldElement51[][src]

pub struct FieldElement51(pub(crate) [u64; 5]);
Expand description

A FieldElement51 represents an element of the field \( \mathbb Z / (2^{255} - 19)\).

In the 64-bit implementation, a FieldElement is represented in radix \(2^{51}\) as five u64s; the coefficients are allowed to grow up to \(2^{54}\) between reductions modulo \(p\).

Note

The curve25519_dalek::field module provides a type alias curve25519_dalek::field::FieldElement to either FieldElement51 or FieldElement2625.

The backend-specific type FieldElement51 should not be used outside of the curve25519_dalek::field module.

Tuple Fields

0: [u64; 5]

Implementations

Determine if this FieldElement is negative, in the sense used in the ed25519 paper: x is negative if the low bit is set.

Return

If negative, return Choice(1). Otherwise, return Choice(0).

Determine if this FieldElement is zero.

Return

If zero, return Choice(1). Otherwise, return Choice(0).

Compute (self^(2^250-1), self^11), used as a helper function within invert() and pow22523().

Given a slice of public FieldElements, replace each with its inverse.

All input FieldElements MUST be nonzero.

Given a nonzero field element, compute its inverse.

The inverse is computed as self^(p-2), since x^(p-2)x = x^(p-1) = 1 (mod p).

This function returns zero on input zero.

Raise this field element to the power (p-5)/8 = 2^252 -3.

Given FieldElements u and v, compute either sqrt(u/v) or sqrt(i*u/v) in constant time.

This function always returns the nonnegative square root.

Return

  • (Choice(1), +sqrt(u/v)) if v is nonzero and u/v is square;
  • (Choice(1), zero) if u is zero;
  • (Choice(0), zero) if v is zero and u is nonzero;
  • (Choice(0), +sqrt(i*u/v)) if u/v is nonsquare (so i*u/v is square).

Attempt to compute sqrt(1/self) in constant time.

Convenience wrapper around sqrt_ratio_i.

This function always returns the nonnegative square root.

Return

  • (Choice(1), +sqrt(1/self)) if self is a nonzero square;
  • (Choice(0), zero) if self is zero;
  • (Choice(0), +sqrt(i/self)) if self is a nonzero nonsquare;

Invert the sign of this field element

Construct zero.

Construct one.

Construct -1.

Given 64-bit input limbs, reduce to enforce the bound 2^(51 + epsilon).

Load a FieldElement51 from the low 255 bits of a 256-bit input.

Warning

This function does not check that the input used the canonical representative. It masks the high bit, but it will happily decode 2^255 - 18 to 1. Applications that require a canonical encoding of every field element should decode, re-encode to the canonical encoding, and check that the input was canonical.

Serialize this FieldElement51 to a 32-byte array. The encoding is canonical.

Given k > 0, return self^(2^k).

Returns the square of this field element.

Returns 2 times the square of this field element.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Select a or b according to choice. Read more

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more

Conditionally assign other to self, according to choice. Read more

Test equality between two FieldElements. Since the internal representation is not canonical, the field elements are normalized to wire format before comparison.

Formats the value using the given formatter. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Numeric cast from self to T.

Negate self if choice == Choice(1); otherwise, leave it unchanged. Read more

Performs the conversion.

Safe lossless bitwise transmute from T to Self.

Numeric cast from T to Self.

Performs the conversion.

Safe lossless bitwise transmute from self to T.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.