Struct curve25519_dalek::montgomery::CompressedMontgomeryU [] [src]

pub struct CompressedMontgomeryU(pub [u8; 32]);

In "Montgomery u" format, as used in X25519, a point (u,v) on the Montgomery curve

v2 = u * (u2 + 486662*u + 1)

is represented just by u. Note that we use (u,v) instead of (x,y) for Montgomery coordinates to avoid confusion with Edwards coordinates. For Montgomery curves, it is possible to compute the u-coordinate of n(u,v) just from n and u, so it is not necessary to use v for a Diffie-Hellman key exchange.

Methods

impl CompressedMontgomeryU
[src]

[src]

View this CompressedMontgomeryU as an array of bytes.

[src]

Convert this CompressedMontgomeryU to an array of bytes.

[src]

Attempt to decompress to an ExtendedPoint.

Note

Since there are two curve points with the same u-coordinate, the u-coordinate does not fully specify a point. That is, roundtripping between an ExtendedPoint and a CompressedMontgomeryU discards its sign bit.

Warning

This function is not constant time.

Return

An Option<ExtendedPoint>, which will be None if either condition holds:

  • u = -1, or
  • v is not square.

[src]

Decompress this CompressedMontgomeryU to a MontgomeryPoint.

Going from affine to projective coordinates, we have:

    u → U/W

Returns

A projective MontgomeryPoint corresponding to this compressed point.

[src]

Given a Montgomery u coordinate, compute an Edwards y via y = (u-1)/(u+1).

Return

A FieldElement corresponding to this coordinate, but in Edwards form.

[src]

Given a Montgomery u coordinate, compute the corresponding Montgomery v coordinate by computing the right-hand side of the Montgomery field equation, v² = u(u² + Au +1).

Return

A tuple of (u8, FieldElement), where the u8 is 1 if the v² was actually a square and 0 if otherwise, along with a FieldElement: the Montgomery v corresponding to this u.

[src]

Given Montgomery coordinates (u, v), recover the Edwards x coordinate.

Inputs

  • u and v are both &FieldElements, corresponding the the (u, v) coordinates of this CompressedMontgomeryU.
  • sign is an &u8.

Explanation of choice of sign

Original Signal behaviour:

  • 1u8 will leave x negative if it is negative, and will negate x if it is positive, and
  • 0u8 will leave x positive if it is positive, and will negate x if it is negative.

Hence, if sign is 1u8, the returned x will be negative. Otherwise, if sign is 0u8, the returned x will be positive.

Return

A FieldElement, the Edwards x coordinate, by using (u, v) to convert from Montgomery to Edwards form via the right-hand side of the equation: x=(u/v)*sqrt(-A-2).

Trait Implementations

impl Copy for CompressedMontgomeryU
[src]

impl Clone for CompressedMontgomeryU
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for CompressedMontgomeryU
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for CompressedMontgomeryU
[src]

[src]

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

[src]

This method tests for !=.

impl Eq for CompressedMontgomeryU
[src]