Type Definition curve25519_dalek::field::FieldElement [] [src]

type FieldElement = FieldElement32;

A FieldElement represents an element of the field GF(2255 - 19).

Methods

impl FieldElement
[src]

[src]

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 1u8. Otherwise, return 0u8.

[src]

Determine if this FieldElement is zero.

Return

If zero, return 1u8. Otherwise, return 0u8.

[src]

Determine if this FieldElement is non-zero.

Return

If non-zero, return 1u8. Otherwise, return 0u8.

[src]

Given a nonzero field element, compute its inverse.

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

[src]

Raise this field element to the power (p-5)/8 = 2252 -3. Used in decoding.

[src]

Given FieldElements u and v, attempt to compute sqrt(u/v) in constant time.

This function always returns the nonnegative square root, if it exists.

It would be much better to use an Option type here, but doing so forces the caller to branch, which we don't want to do. This seems like the least bad solution.

Return

  • (1u8, sqrt(u/v)) if v is nonzero and u/v is square;
  • (0u8, zero) if v is zero;
  • (0u8, garbage) if u/v is nonsquare.

[src]

For self a nonzero square, compute 1/sqrt(self) in constant time.

It would be much better to use an Option type here, but doing so forces the caller to branch, which we don't want to do. This seems like the least bad solution.

Return

  • (1u8, 1/sqrt(self)) if self is a nonzero square;
  • (0u8, zero) if self is zero;
  • (0u8, garbage) if self is nonsquare.

[src]

chi calculates self^((p-1)/2).

Return

  • If this element is a non-zero square, returns 1.
  • If it is zero, returns 0.
  • If it is non-square, returns -1.

Trait Implementations

impl Eq for FieldElement
[src]

impl PartialEq for FieldElement
[src]

[src]

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

Warning

This comparison is not constant time. It could easily be made to be, but the main use of an Eq implementation is for branching, so it seems pointless to do so.

1.0.0
[src]

This method tests for !=.

impl Equal for FieldElement
[src]

[src]

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

Returns

1u8 if the two FieldElements are equal, and 0u8 otherwise.