Struct ProjectivePoint

Source
pub struct ProjectivePoint {
    pub X: FieldElement,
    pub Y: FieldElement,
    pub Z: FieldElement,
}
Expand description

A ProjectivePoint represents a point on the Doppio Curve expressed over the Twisted Edwards Projective Coordinates eg. (X, Y, Z).

For Z1≠0 the point (X1:Y1:Z1) represents the affine point (x1= X1/Z1, y1= Y1/Z1) on EE,a,d. Projective coordinates represent x y as (X Y Z) satisfying the following equations:

x=X/Z

y=Y/Z

Expressing an elliptic curve in twisted Edwards form saves time in arithmetic, even when the same curve can be expressed in the Edwards form.

Fields§

§X: FieldElement§Y: FieldElement§Z: FieldElement

Implementations§

Source§

impl ProjectivePoint

Source

pub fn new_from_y_coord( y: &FieldElement, sign: Choice, ) -> Option<ProjectivePoint>

This function tries to build a Point over the Doppio Curve from a Y coordinate and a Choice that determines the Sign o the X coordinate that the user wants to use.

The function gets X by solving: +-X = mod_sqrt((y^2 -1)/(dy^2 - a)).

The sign of x is choosen with a Choice parameter.

For Choice(0) -> Negative result. For Choice(1) -> Positive result.

Then Z is always equal to 1.

§Returns

Some(ProjectivePoint) if there exists a result for the mod_sqrt and None if the resulting x^2 isn’t a QR modulo FIELD_L.

Source

pub fn new_random_point() -> ProjectivePoint

This function tries to build a Point over the Doppio Curve from a random Y coordinate and a random Choice that determines the Sign o the X coordinate.

Trait Implementations§

Source§

impl<'a, 'b> Add<&'b ProjectivePoint> for &'a ProjectivePoint

Source§

fn add(self, other: &'b ProjectivePoint) -> ProjectivePoint

Add two ProjectivePoints and give the resulting ProjectivePoint. This implementation is specific for curves with a = -1 as Doppio is.

Bernstein D.J., Birkner P., Joye M., Lange T., Peters C. (2008) Twisted Edwards Curves. In: Vaudenay S. (eds) Progress in Cryptology – AFRICACRYPT 2008. AFRICACRYPT 2008. Lecture Notes in Computer Science, vol 5023. Springer, Berlin, Heidelberg. See: https://eprint.iacr.org/2008/013.pdf - Section 6.

Source§

type Output = ProjectivePoint

The resulting type after applying the + operator.
Source§

impl Add for ProjectivePoint

Source§

fn add(self, other: ProjectivePoint) -> ProjectivePoint

Add two ProjectivePoints and give the resulting ProjectivePoint. This implementation is specific for curves with a = -1 as Doppio is.

Bernstein D.J., Birkner P., Joye M., Lange T., Peters C. (2008) Twisted Edwards Curves. In: Vaudenay S. (eds) Progress in Cryptology – AFRICACRYPT 2008. AFRICACRYPT 2008. Lecture Notes in Computer Science, vol 5023. Springer, Berlin, Heidelberg. See: https://eprint.iacr.org/2008/013.pdf - Section 6.

Source§

type Output = ProjectivePoint

The resulting type after applying the + operator.
Source§

impl Clone for ProjectivePoint

Source§

fn clone(&self) -> ProjectivePoint

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ConstantTimeEq for ProjectivePoint

Source§

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

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl Debug for ProjectivePoint

Source§

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

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

impl Default for ProjectivePoint

Source§

fn default() -> ProjectivePoint

Returns the default ProjectivePoint Extended Coordinates: (0, 1, 1).

Source§

impl<'a> Double for &'a ProjectivePoint

Source§

fn double(self) -> ProjectivePoint

Double the given point following: This implementation is specific for curves with a = -1 as Doppio is.

/// Bernstein D.J., Birkner P., Joye M., Lange T., Peters C. (2008) Twisted Edwards Curves. In: Vaudenay S. (eds) Progress in Cryptology – AFRICACRYPT 2008. AFRICACRYPT 2008. Lecture Notes in Computer Science, vol 5023. Springer, Berlin, Heidelberg. See: https://eprint.iacr.org/2008/013.pdf - Section 6.

Cost: 3M+ 4S+ +7a + 1D.

Source§

type Output = ProjectivePoint

Source§

impl<'a> From<&'a AffinePoint> for ProjectivePoint

Source§

fn from(point: &'a AffinePoint) -> ProjectivePoint

The key idea of projective coordinates is that instead of performing every division immediately, we defer the divisions by multiplying them into a denominator.

In affine form, each elliptic curve point has 2 coordinates, like (x,y). In the new projective form, each point will have 3 coordinates, like (X,Y,Z), with the restriction that Z is never zero.

The forward mapping is given by (x,y)→(xz,yz,z), for any non-zero z (usually chosen to be 1 for convenience).

Source§

impl<'a> From<&'a EdwardsPoint> for ProjectivePoint

Source§

fn from(point: &'a EdwardsPoint) -> ProjectivePoint

Given (X:Y:T:Z) in εε, passing to ε is cost-free by simply ignoring T.

Twisted Edwards Curves Revisited - Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson, Section 3.

Source§

impl<'a> From<&'a ProjectivePoint> for AffinePoint

Source§

fn from(point: &'a ProjectivePoint) -> AffinePoint

Reduce the point from Projective to Affine coordinates computing: (XZinv, YZinv, Z*Zinv).

And once Z coord = 1 we can simply remove it.

Twisted Edwards Curves Revisited - Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson.

Source§

impl<'a> From<&'a ProjectivePoint> for EdwardsPoint

Source§

fn from(point: &'a ProjectivePoint) -> EdwardsPoint

Given (X:Y:Z) in ε passing to εε can beperformed in 3M+ 1S by computing (XZ, YZ, X*Y, Z^2).

Twisted Edwards Curves Revisited - Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson, Section 3.

Source§

impl Identity for ProjectivePoint

Source§

fn identity() -> ProjectivePoint

Returns the Edwards Point identity value = (0, 1, 1).

Source§

impl<'a, 'b> Mul<&'a Scalar> for &'b ProjectivePoint

Source§

fn mul(self, scalar: &'a Scalar) -> ProjectivePoint

Scalar multiplication: compute Scalar * self. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

Source§

type Output = ProjectivePoint

The resulting type after applying the * operator.
Source§

impl Mul<Scalar> for ProjectivePoint

Source§

fn mul(self, scalar: Scalar) -> ProjectivePoint

Scalar multiplication: compute Scalar * self. This implementation uses the algorithm: add_and_doubling which is the standard one for this operations and also adds less constraints on R1CS.

Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004). Guide to Elliptic Curve Cryptography. Springer Professional Computing. New York: Springer-Verlag.

Source§

type Output = ProjectivePoint

The resulting type after applying the * operator.
Source§

impl<'a> Neg for &'a ProjectivePoint

Source§

fn neg(self) -> ProjectivePoint

Negates an ProjectivePoint giving it as a result. Since the negative of a point is (-X:Y:Z:-T), it gives as a result: (-X, Y, Z, -T).

Source§

type Output = ProjectivePoint

The resulting type after applying the - operator.
Source§

impl Neg for ProjectivePoint

Source§

fn neg(self) -> ProjectivePoint

Negates an ProjectivePoint giving it as a result

Source§

type Output = ProjectivePoint

The resulting type after applying the - operator.
Source§

impl PartialEq for ProjectivePoint

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> Sub<&'b ProjectivePoint> for &'a ProjectivePoint

Source§

fn sub(self, other: &'b ProjectivePoint) -> ProjectivePoint

Add two ProjectivePoints, negating the second one, This implementation is specific for curves with a = -1 as Doppio is.

Bernstein D.J., Birkner P., Joye M., Lange T., Peters C. (2008) Twisted Edwards Curves. In: Vaudenay S. (eds) Progress in Cryptology – AFRICACRYPT 2008. AFRICACRYPT 2008. Lecture Notes in Computer Science, vol 5023. Springer, Berlin, Heidelberg. See: https://eprint.iacr.org/2008/013.pdf - Section 6.

Source§

type Output = ProjectivePoint

The resulting type after applying the - operator.
Source§

impl Sub for ProjectivePoint

Source§

fn sub(self, other: ProjectivePoint) -> ProjectivePoint

Add two ProjectivePoints, negating the second one, This implementation is specific for curves with a = -1 as Doppio is.

Bernstein D.J., Birkner P., Joye M., Lange T., Peters C. (2008) Twisted Edwards Curves. In: Vaudenay S. (eds) Progress in Cryptology – AFRICACRYPT 2008. AFRICACRYPT 2008. Lecture Notes in Computer Science, vol 5023. Springer, Berlin, Heidelberg. See: https://eprint.iacr.org/2008/013.pdf - Section 6.

Source§

type Output = ProjectivePoint

The resulting type after applying the - operator.
Source§

impl Copy for ProjectivePoint

Source§

impl Eq for ProjectivePoint

Auto Trait Implementations§

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> Clear for T

Source§

fn clear(&mut self)

Completely overwrites this value.
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> InitializableFromZeroed for T
where T: Default,

Source§

unsafe fn initialize(place: *mut T)

Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V