Struct curve25519_dalek::curve::ExtendedPoint
[−]
[src]
pub struct ExtendedPoint { /* fields omitted */ }
An ExtendedPoint
is a point on the curve in 𝗣³(𝔽ₚ).
A point (x,y) in the affine model corresponds to (x:y:1:xy).
Methods
impl ExtendedPoint
[src]
fn compress(&self) -> CompressedPoint
Convert this point to a CompressedPoint
fn edwards_to_montgomery_x(&self) -> FieldElement
XXX rewrite We only need the x-coordinate of the curve25519 point, which I'll call u. The isomorphism is u=(y+1)/(1-y), since y=Y/Z, this gives u=(Y+Z)/(Z-Y). We know that Z=1, thus u=(Y+1)/(1-Y).
impl ExtendedPoint
[src]
fn scalar_mult(&self, a: &Scalar) -> ExtendedPoint
Scalar multiplication: compute a * self
.
Uses a window of size 4. Note: for scalar multiplication of
the basepoint, basepoint_mult
is approximately 4x faster.
fn basepoint_mult(a: &Scalar) -> ExtendedPoint
Construct an ExtendedPoint
from a Scalar
, a
, by
computing the multiple aB
of the basepoint B
.
Precondition: the scalar must be reduced.
The computation proceeds as follows, as described on page 13
of the Ed25519 paper. Write the scalar a
in radix 16 with
coefficients in [-8,8), i.e.,
a = a_0 + a_1*161 + ... + a_63*1663,
with -8 ≤ a_i < 8. Then
a*B = a_0*B + a_1*161*B + ... + a_63*1663*B.
Grouping even and odd coefficients gives
a*B = a_0*160*B + a_2*162*B + ... + a_62*1662*B + a_1*161*B + a_3*163*B + ... + a_63*1663*B = (a_0*160*B + a_2*162*B + ... + a_62*1662*B) + 16*(a_1*160*B + a_3*162*B + ... + a_63*1662*B).
We then use the select_precomputed_point
function, which
takes -8 ≤ x < 8
and [16^2i * B, ..., 8 * 16^2i * B]
,
and returns x * 16^2i * B
in constant time.
fn mult_by_pow_2(&self, k: u32) -> ExtendedPoint
Compute 2^k * self
by successive doublings.
Requires k > 0
.
impl ExtendedPoint
[src]
fn to_uniform_representative(&self) -> Option<[u8; 32]>
Use Elligator2 to try to convert self
to a uniformly random
string.
Returns Some<[u8;32]>
if self
is in the image of the
Elligator2 map. For a random point on the curve, this happens
with probability 1/2. Otherwise, returns None
.
fn from_uniform_representative(bytes: &[u8; 32]) -> ExtendedPoint
Use Elligator2 to convert a uniformly random string to a curve point.
Trait Implementations
impl Copy for ExtendedPoint
[src]
impl Clone for ExtendedPoint
[src]
fn clone(&self) -> ExtendedPoint
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Identity for ExtendedPoint
[src]
fn identity() -> ExtendedPoint
Returns the identity element of the curve. Can be used as a constructor. Read more
impl<'a, 'b> Add<&'b CachedPoint> for &'a ExtendedPoint
[src]
type Output = CompletedPoint
The resulting type after applying the +
operator
fn add(self, other: &'b CachedPoint) -> CompletedPoint
The method for the +
operator
impl<'a, 'b> Sub<&'b CachedPoint> for &'a ExtendedPoint
[src]
type Output = CompletedPoint
The resulting type after applying the -
operator
fn sub(self, other: &'b CachedPoint) -> CompletedPoint
The method for the -
operator
impl<'a, 'b> Add<&'b PreComputedPoint> for &'a ExtendedPoint
[src]
type Output = CompletedPoint
The resulting type after applying the +
operator
fn add(self, other: &'b PreComputedPoint) -> CompletedPoint
The method for the +
operator
impl<'a, 'b> Sub<&'b PreComputedPoint> for &'a ExtendedPoint
[src]
type Output = CompletedPoint
The resulting type after applying the -
operator
fn sub(self, other: &'b PreComputedPoint) -> CompletedPoint
The method for the -
operator
impl<'a, 'b> Add<&'b ExtendedPoint> for &'a ExtendedPoint
[src]
type Output = ExtendedPoint
The resulting type after applying the +
operator
fn add(self, other: &'b ExtendedPoint) -> ExtendedPoint
The method for the +
operator
impl<'a, 'b> Sub<&'b ExtendedPoint> for &'a ExtendedPoint
[src]
type Output = ExtendedPoint
The resulting type after applying the -
operator
fn sub(self, other: &'b ExtendedPoint) -> ExtendedPoint
The method for the -
operator
impl<'a> Neg for &'a ExtendedPoint
[src]
type Output = ExtendedPoint
The resulting type after applying the -
operator
fn neg(self) -> ExtendedPoint
The method for the unary -
operator